aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/search.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/search.c b/src/search.c
index bdd2ef92843..f9b45c8eca6 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2323,13 +2323,21 @@ since only regular expressions have distinguished subexpressions. */)
2323 substart = search_regs.start[sub]; 2323 substart = search_regs.start[sub];
2324 subend = search_regs.end[sub]; 2324 subend = search_regs.end[sub];
2325 } 2325 }
2326 else if (c >= '1' && c <= '9' && c <= search_regs.num_regs + '0') 2326 else if (c >= '1' && c <= '9')
2327 { 2327 {
2328 if (search_regs.start[c - '0'] >= 0) 2328 if (search_regs.start[c - '0'] >= 0
2329 && c <= search_regs.num_regs + '0')
2329 { 2330 {
2330 substart = search_regs.start[c - '0']; 2331 substart = search_regs.start[c - '0'];
2331 subend = search_regs.end[c - '0']; 2332 subend = search_regs.end[c - '0'];
2332 } 2333 }
2334 else
2335 {
2336 /* If that subexp did not match,
2337 replace \\N with nothing. */
2338 substart = 0;
2339 subend = 0;
2340 }
2333 } 2341 }
2334 else if (c == '\\') 2342 else if (c == '\\')
2335 delbackslash = 1; 2343 delbackslash = 1;
@@ -2507,8 +2515,16 @@ since only regular expressions have distinguished subexpressions. */)
2507 } 2515 }
2508 2516
2509 if (really_changed) 2517 if (really_changed)
2510 newtext = make_string (substed, substed_len); 2518 {
2519 if (buf_multibyte)
2520 {
2521 int nchars = multibyte_chars_in_text (substed, substed_len);
2511 2522
2523 newtext = make_multibyte_string (substed, nchars, substed_len);
2524 }
2525 else
2526 newtext = make_unibyte_string (substed, substed_len);
2527 }
2512 xfree (substed); 2528 xfree (substed);
2513 } 2529 }
2514 2530
@@ -2900,3 +2916,6 @@ syms_of_search ()
2900 defsubr (&Sset_match_data); 2916 defsubr (&Sset_match_data);
2901 defsubr (&Sregexp_quote); 2917 defsubr (&Sregexp_quote);
2902} 2918}
2919
2920/* arch-tag: a6059d79-0552-4f14-a2cb-d379a4e3c78f
2921 (do not change this comment) */