Commit 76fc1ea2 authored by Kenichi Handa's avatar Kenichi Handa
Browse files

Sync.to HEAD.

parent bd7ca8fe
...@@ -2323,13 +2323,21 @@ since only regular expressions have distinguished subexpressions. */) ...@@ -2323,13 +2323,21 @@ since only regular expressions have distinguished subexpressions. */)
substart = search_regs.start[sub]; substart = search_regs.start[sub];
subend = search_regs.end[sub]; subend = search_regs.end[sub];
} }
else if (c >= '1' && c <= '9' && c <= search_regs.num_regs + '0') else if (c >= '1' && c <= '9')
{ {
if (search_regs.start[c - '0'] >= 0) if (search_regs.start[c - '0'] >= 0
&& c <= search_regs.num_regs + '0')
{ {
substart = search_regs.start[c - '0']; substart = search_regs.start[c - '0'];
subend = search_regs.end[c - '0']; subend = search_regs.end[c - '0'];
} }
else
{
/* If that subexp did not match,
replace \\N with nothing. */
substart = 0;
subend = 0;
}
} }
else if (c == '\\') else if (c == '\\')
delbackslash = 1; delbackslash = 1;
...@@ -2507,8 +2515,16 @@ since only regular expressions have distinguished subexpressions. */) ...@@ -2507,8 +2515,16 @@ since only regular expressions have distinguished subexpressions. */)
} }
if (really_changed) if (really_changed)
newtext = make_string (substed, substed_len); {
if (buf_multibyte)
{
int nchars = multibyte_chars_in_text (substed, substed_len);
newtext = make_multibyte_string (substed, nchars, substed_len);
}
else
newtext = make_unibyte_string (substed, substed_len);
}
xfree (substed); xfree (substed);
} }
...@@ -2900,3 +2916,6 @@ syms_of_search () ...@@ -2900,3 +2916,6 @@ syms_of_search ()
defsubr (&Sset_match_data); defsubr (&Sset_match_data);
defsubr (&Sregexp_quote); defsubr (&Sregexp_quote);
} }
/* arch-tag: a6059d79-0552-4f14-a2cb-d379a4e3c78f
(do not change this comment) */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment