APPROVE COMMIT 21.5
This is a sync of the patch by Vin and Arnold, and of the test that I
submitted for shy groups which has been incorporated in the 21.4 test
suite already. I've tweaked Vin's ChangeLog to mention "stale match
data" and moved the code to be with the other "stale match data"
tests, rather than with the backreferencing tests, which test the
basic functionality.
Index: tests/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/ChangeLog,v
retrieving revision 1.62
diff -u -U0 -r1.62 ChangeLog
--- tests/ChangeLog 28 Oct 2004 11:31:18 -0000 1.62
+++ tests/ChangeLog 2 Feb 2005 11:31:18 -0000
@@ -0,0 +1,10 @@
+2005-02-01 Vin Shelton <acs(a)xemacs.org>
+
+ * automated/regexp-tests.el: Added test for stale match data with
+ shy groups authored by Arnaud Giersch <arnaud.giersch(a)free.fr>
+
+2005-01-13 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * automated/regexp-tests.el:
+ Test trivial subpatterns and backreferences with shy groups.
+
? tests/cygwin.sc
Index: tests/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/ChangeLog,v
retrieving revision 1.62
diff -u -r1.62 ChangeLog
--- tests/ChangeLog 28 Oct 2004 11:31:18 -0000 1.62
+++ tests/ChangeLog 2 Feb 2005 11:31:25 -0000
@@ -1,3 +1,13 @@
+2005-02-01 Vin Shelton <acs(a)xemacs.org>
+
+ * automated/regexp-tests.el: Added test for stale match data with
+ shy groups authored by Arnaud Giersch <arnaud.giersch(a)free.fr>
+
+2005-01-13 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * automated/regexp-tests.el:
+ Test trivial subpatterns and backreferences with shy groups.
+
2004-10-28 Stephen J. Turnbull <stephen(a)xemacs.org>
* automated/os-tests.el: New file. Add tests for bug reported by
Index: tests/automated/regexp-tests.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/automated/regexp-tests.el,v
retrieving revision 1.14
diff -u -r1.14 regexp-tests.el
--- tests/automated/regexp-tests.el 7 Oct 2004 08:01:44 -0000 1.14
+++ tests/automated/regexp-tests.el 2 Feb 2005 11:31:25 -0000
@@ -393,7 +393,13 @@
(Assert (string= (progn (string-match "\\(a\\)" a)
(string-match "b" a)
(match-string 1 a))
- a)))
+ a))
+ ;; in 21.4.16, registers from num_shy_groups to num_groups were not cleared,
+ ;; resulting in stale match data
+ (Assert (progn (string-match "\\(a\\)" a)
+ (string-match "\\(?:a\\)" a)
+ (not (match-beginning 1))))
+ )
;; bug identified by Katsumi Yamaoka 2004-09-03 <b9ywtzbbpue.fsf_-_(a)jpl.org>
;; fix submitted by sjt 2004-09-08
@@ -421,5 +427,35 @@
(Assert (null (match-string 2 text))) ; ab
(Assert (null (match-string 3 text))) ; c
(Assert (null (match-string 4 text))) ; nil
+)
+
+;; trivial subpatterns and backreferences with shy groups
+(let ((text1 "abb")
+ (text2 "aba")
+ (re0 "\\(a\\)\\(b\\)\\2")
+ (re1 "\\(?:a\\)\\(b\\)\\2")
+ (re2 "\\(?:a\\)\\(b\\)\\1")
+ (re3 "\\(a\\)\\(?:b\\)\\1"))
+
+ (Assert (eq 0 (string-match re0 text1)))
+ (Assert (string= text1 (match-string 0 text1)))
+ (Assert (string= "a" (match-string 1 text1)))
+ (Assert (string= "b" (match-string 2 text1)))
+ (Assert (null (string-match re0 text2)))
+
+ (Check-Error-Message 'invalid-regexp "Invalid back reference"
+ (string-match re1 text1))
+
+ (Assert (eq 0 (string-match re2 text1)))
+ (Assert (string= text1 (match-string 0 text1)))
+ (Assert (string= "b" (match-string 1 text1)))
+ (Assert (null (match-string 2 text1)))
+ (Assert (null (string-match re2 text2)))
+
+ (Assert (null (string-match re3 text1)))
+ (Assert (eq 0 (string-match re3 text2)))
+ (Assert (string= text2 (match-string 0 text2)))
+ (Assert (string= "a" (match-string 1 text2)))
+ (Assert (null (match-string 2 text2)))
)
--
Institute of Policy and Planning Sciences
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Ask not how you can "do" free software business;
ask what your business can "do for" free software.