1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-01 08:17:38 +00:00

* regex.c (at_begline_loc_p): Also recognize `(?N:' and correctly

account for preceding backslashes.  (Bug#11663)
This commit is contained in:
Andreas Schwab 2012-06-10 10:39:19 +02:00
parent 642b6d30c6
commit 95988fcfa8
2 changed files with 35 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2012-06-10 Andreas Schwab <schwab@linux-m68k.org>
* regex.c (at_begline_loc_p): Also recognize `(?N:' and correctly
account for preceding backslashes. (Bug#11663)
2012-06-09 Chong Yidong <cyd@gnu.org>
* term.c: Support italics in capable terminals (Bug#9652).

View File

@ -3824,18 +3824,37 @@ static boolean
at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax)
{
re_char *prev = p - 2;
boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
boolean odd_backslashes;
return
/* After a subexpression? */
(*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash))
/* After an alternative? */
|| (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash))
/* After a shy subexpression? */
|| ((syntax & RE_SHY_GROUPS) && prev - 2 >= pattern
&& prev[-1] == '?' && prev[-2] == '('
&& (syntax & RE_NO_BK_PARENS
|| (prev - 3 >= pattern && prev[-3] == '\\')));
/* After a subexpression? */
if (*prev == '(')
odd_backslashes = (syntax & RE_NO_BK_PARENS) == 0;
/* After an alternative? */
else if (*prev == '|')
odd_backslashes = (syntax & RE_NO_BK_VBAR) == 0;
/* After a shy subexpression? */
else if (*prev == ':' && (syntax & RE_SHY_GROUPS))
{
/* Skip over optional regnum. */
while (prev - 1 >= pattern && prev[-1] >= '0' && prev[-1] <= '9')
--prev;
if (!(prev - 2 >= pattern
&& prev[-1] == '?' && prev[-2] == '('))
return false;
prev -= 2;
odd_backslashes = (syntax & RE_NO_BK_PARENS) == 0;
}
else
return false;
/* Count the number of preceding backslashes. */
p = prev;
while (prev - 1 >= pattern && prev[-1] == '\\')
--prev;
return (p - prev) & odd_backslashes;
}