From 618765e259dedad64023f5f750afe080cb50e1c4 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 12 Jun 2001 08:07:37 +0000 Subject: Fix for bug #219232 (submatch errors with regexp -all -inline -indices) --- ChangeLog | 6 ++++++ generic/tclCmdMZ.c | 8 ++++++-- tests/regexp.test | 5 ++++- 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 + + * 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 * 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 -- cgit v0.12