From ac36b4dd74f9359f07bfdb431c932d702064652f Mon Sep 17 00:00:00 2001 From: ericm Date: Wed, 20 Sep 2000 01:50:37 +0000 Subject: * generic/tclCmdMZ.c (Tcl_RegexpObjCmd): When using -all, all attempts after the first to match the regexp against the string should include the TCL_REG_NOTBOL flag, to avoid erroneously matching ^ in the middle of the string. Added code to set this flag after the first pass through the matching loop. [Bug: 6284]. --- ChangeLog | 8 ++++++++ generic/tclCmdMZ.c | 3 ++- tests/regexp.test | 6 +++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4800ea8..06b7bcf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2000-09-19 Eric Melski + + * generic/tclCmdMZ.c (Tcl_RegexpObjCmd): When using -all, all + attempts after the first to match the regexp against the string + should include the TCL_REG_NOTBOL flag, to avoid erroneously + matching ^ in the middle of the string. Added code to set this + flag after the first pass through the matching loop. [Bug: 6284]. + 2000-09-19 David Gravereaux * doc/Eval.3: Added a note about the script argument to Tcl_Eval() diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 9fa3166..1e99419 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.29 2000/09/06 18:31:36 hobbs Exp $ + * RCS: @(#) $Id: tclCmdMZ.c,v 1.30 2000/09/20 01:50:38 ericm Exp $ */ #include "tclInt.h" @@ -433,6 +433,7 @@ Tcl_RegexpObjCmd(dummy, interp, objc, objv) } offset += info.matches[0].end; all++; + eflags |= TCL_REG_NOTBOL; if (offset >= stringLength) { break; } diff --git a/tests/regexp.test b/tests/regexp.test index e891b54..63dbd31 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.13 2000/04/10 21:08:27 ericm Exp $ +# RCS: @(#) $Id: regexp.test,v 1.14 2000/09/20 01:50:39 ericm Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -526,6 +526,10 @@ test regexp-18.10 {regexp -all} { # Go to index 3; this is past the end of the string, so stop. regexp -all -inline {a*} aba } {a {} a} +test regexp-18.11 {regexp -all} { + regexp -all -inline {^a} aaaa +} {a} + # cleanup ::tcltest::cleanupTests -- cgit v0.12