^ was wrongly interpreted as literal when occurring at the start
of a shy group. Cause: regex.c:at_begline_loc_p() was not told about
shy groups.
Two tests added to tests/automated/regexp-tests.el.
Patch applies against 21.4.22. (Patch for 21.5 follows.)
--- src/regex.c-dist 2006-03-31 02:29:00.000000000 +0100
+++ src/regex.c 2011-12-11 18:47:22.000000000 +0000
@@ -3295,12 +3295,18 @@
{
re_char *prev = p - 2;
re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\';
+ re_bool shy_open = prev-1 > pattern && prev[0] == ':'
+ && prev[-1] == '?' && prev[-2] == '(';
+ re_bool ppp_backslash = prev-2 > pattern && prev[-3] == '\\';
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));
+ || (*prev == '|' && (syntax & RE_NO_BK_VBAR ||
prev_prev_backslash))
+ /* After a shy open? */
+ || (!(syntax & RE_NO_SHY_GROUPS) && shy_open
+ && (syntax & RE_NO_BK_PARENS || ppp_backslash));
}
--- tests/automated/regexp-tests.el-dist 2008-12-26 03:45:29.000000000 +0000
+++ tests/automated/regexp-tests.el 2011-12-11 19:20:46.000000000 +0000
@@ -447,11 +447,16 @@
(Assert (progn (string-match "\\(a\\)" "a")
(string-match "\\(?:a\\)" "a")
(not (match-beginning 1))))
+
+ ;; ^ at beginning of shy group. Fix by
+ ;; Julian Bradfield on 2012-12-11.
+ (Assert (string-match "\\(?:^\\)" ""))
+ (Assert (string-match "a(?:^)" "a:^)"))
)
;; empty string at point
-;; Thanks Julian Bradford on XEmacs Beta
+;; Thanks Julian Bradfield on XEmacs Beta
;; <18652.54975.894512.880956(a)krk.inf.ed.ac.uk>
(with-string-as-buffer-contents "aáa"
(goto-char (point-min))
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches