mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-06 03:40:56 -08:00
Allow regexp-quote to return its argument
* src/search.c (Fregexp_quote): Only allocate a new string if needed. * doc/lispref/searching.texi (Regexp Functions): * etc/NEWS (Incompatible Lisp Changes): Document.
This commit is contained in:
parent
84567150e7
commit
a773a64748
3 changed files with 13 additions and 4 deletions
|
|
@ -1562,6 +1562,9 @@ whitespace:
|
|||
(concat "\\s-" (regexp-quote string) "\\s-"))
|
||||
@end group
|
||||
@end example
|
||||
|
||||
The returned string may be @var{string} itself if it does not contain
|
||||
any special characters.
|
||||
@end defun
|
||||
|
||||
@cindex optimize regexp
|
||||
|
|
|
|||
4
etc/NEWS
4
etc/NEWS
|
|
@ -2157,6 +2157,10 @@ valid event type.
|
|||
be specified in image specs representing the entire bitmap as a single
|
||||
bool vector.
|
||||
|
||||
+++
|
||||
** 'regexp-quote' may return its argument string.
|
||||
If the argument needs no quoting, it can be returned instead of a copy.
|
||||
|
||||
|
||||
* Lisp Changes in Emacs 27.1
|
||||
|
||||
|
|
|
|||
10
src/search.c
10
src/search.c
|
|
@ -3138,10 +3138,12 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0,
|
|||
}
|
||||
|
||||
Lisp_Object result
|
||||
= make_specified_string (temp,
|
||||
SCHARS (string) + backslashes_added,
|
||||
out - temp,
|
||||
STRING_MULTIBYTE (string));
|
||||
= (backslashes_added > 0
|
||||
? make_specified_string (temp,
|
||||
SCHARS (string) + backslashes_added,
|
||||
out - temp,
|
||||
STRING_MULTIBYTE (string))
|
||||
: string);
|
||||
SAFE_FREE ();
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue