summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2019-09-23 18:56:30 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2019-09-25 18:09:42 +0200
commita773a6474897356cd78aeea092d2c1a51ede23f9 (patch)
tree9935673b464dc14a03a70a36c6ce7756404f0337 /src/search.c
parent84567150e757ee3991a4b4f96a27080f92cb6d48 (diff)
downloademacs-a773a6474897356cd78aeea092d2c1a51ede23f9.tar.gz
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.
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/search.c b/src/search.c
index 1e57d2ecbe5..9d95dcbca58 100644
--- a/src/search.c
+++ b/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;
}