(Freplace_match): Handle nonexistent back-references properly.

This commit is contained in:
Richard M. Stallman
2004-01-27 04:52:09 +00:00
parent bdb6a22747
commit 5fbbc83b2b

View File

@@ -2366,13 +2366,21 @@ since only regular expressions have distinguished subexpressions. */)
substart = search_regs.start[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'];
subend = search_regs.end[c - '0'];
}
else
{
/* If that subexp did not match,
replace \\N with nothing. */
substart = 0;
subend = 0;
}
}
else if (c == '\\')
delbackslash = 1;