From a21bda19f3e66a10cf4a9510060918de0d7db654 Mon Sep 17 00:00:00 2001 From: hobbs Date: Wed, 28 Mar 2001 02:30:06 +0000 Subject: * tests/regexp.test (regexp-19.1): * generic/tclCmdMZ.c (Tcl_RegsubObjCmd): fixed handling of nulls in subspec value. --- generic/tclCmdMZ.c | 7 ++++--- tests/regexp.test | 20 +++++--------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index a0e0489..473a408 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.32 2001/03/13 11:10:44 dkf Exp $ + * RCS: @(#) $Id: tclCmdMZ.c,v 1.33 2001/03/28 02:30:06 hobbs Exp $ */ #include "tclInt.h" @@ -481,7 +481,7 @@ Tcl_RegsubObjCmd(dummy, interp, objc, objv) Tcl_RegExp regExpr; Tcl_RegExpInfo info; Tcl_Obj *resultPtr, *varPtr, *objPtr; - Tcl_UniChar ch, *wsrc, *wfirstChar, *wstring, *wsubspec; + Tcl_UniChar ch, *wsrc, *wfirstChar, *wstring, *wsubspec, *wend; static char *options[] = { "-all", "-nocase", "-expanded", @@ -629,7 +629,8 @@ Tcl_RegsubObjCmd(dummy, interp, objc, objv) */ wsrc = wfirstChar = wsubspec; - for (ch = *wsrc; ch != '\0'; wsrc++, ch = *wsrc) { + wend = wsubspec + wsublen; + for (ch = *wsrc; wsrc != wend; wsrc++, ch = *wsrc) { if (ch == '&') { idx = 0; } else if (ch == '\\') { diff --git a/tests/regexp.test b/tests/regexp.test index 63dbd31..fc2863c 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.14 2000/09/20 01:50:39 ericm Exp $ +# RCS: @(#) $Id: regexp.test,v 1.15 2001/03/28 02:30:06 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -530,21 +530,11 @@ test regexp-18.11 {regexp -all} { regexp -all -inline {^a} aaaa } {a} +test regexp-19.1 {regsub null replacement} { + regsub -all {@} {@hel@lo@} "\0a\0" result + list $result [string length $result] +} "\0a\0hel\0a\0lo\0a\0 14" # cleanup ::tcltest::cleanupTests return - - - - - - - - - - - - - - -- cgit v0.12