summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2001-06-12 08:07:37 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2001-06-12 08:07:37 (GMT)
commit618765e259dedad64023f5f750afe080cb50e1c4 (patch)
treed0d7eaa0cc57a266b613765f972ca573df84eade
parent4f211efb0420a08b1bde5ecf7512c41ffbaac25a (diff)
downloadtcl-618765e259dedad64023f5f750afe080cb50e1c4.zip
tcl-618765e259dedad64023f5f750afe080cb50e1c4.tar.gz
tcl-618765e259dedad64023f5f750afe080cb50e1c4.tar.bz2
Fix for bug #219232 (submatch errors with regexp -all -inline -indices)
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclCmdMZ.c8
-rw-r--r--tests/regexp.test5
3 files changed, 16 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index d860fd4..4a9c721 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-06-12 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+
+ * tests/regexp.test (regexp-18.12):
+ * generic/tclCmdMZ.c (Tcl_RegexpObjCmd): Fixed so that submatches
+ that do not match always have index pair {-1 -1} [Bug #219232]
+
2001-05-03 Don Porter <dgp@users.sourceforge.net>
* generic/tcl.h:
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 602fca4..5984ed0 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.38 2001/05/17 02:11:32 hobbs Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.39 2001/06/12 08:07:37 dkf Exp $
*/
#include "tclInt.h"
@@ -368,7 +368,11 @@ Tcl_RegexpObjCmd(dummy, interp, objc, objv)
int start, end;
Tcl_Obj *objs[2];
- if (i <= info.nsubs) {
+ /*
+ * Only adjust the match area if there was a match for
+ * that area. (Scriptics Bug 4391/SF Bug #219232)
+ */
+ if (i <= info.nsubs && info.matches[i].start >= 0) {
start = offset + info.matches[i].start;
end = offset + info.matches[i].end;
diff --git a/tests/regexp.test b/tests/regexp.test
index fc2863c..11b72bd 100644
--- a/tests/regexp.test
+++ b/tests/regexp.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: regexp.test,v 1.15 2001/03/28 02:30:06 hobbs Exp $
+# RCS: @(#) $Id: regexp.test,v 1.16 2001/06/12 08:07:37 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -529,6 +529,9 @@ test regexp-18.10 {regexp -all} {
test regexp-18.11 {regexp -all} {
regexp -all -inline {^a} aaaa
} {a}
+test regexp-18.12 {regexp -all -inline -indices} {
+ regexp -all -inline -indices a(b(c)d|e(f)g)h abcdhaefgh
+} {{0 4} {1 3} {2 2} {-1 -1} {5 9} {6 8} {-1 -1} {7 7}}
test regexp-19.1 {regsub null replacement} {
regsub -all {@} {@hel@lo@} "\0a\0" result