diff options
author | hobbs <hobbs> | 2001-08-07 00:56:15 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2001-08-07 00:56:15 (GMT) |
commit | f546af5ac7018d30c4776d9c66006e2e8e425de7 (patch) | |
tree | 935196e702f2b3140e193d32a82e734571f9e582 /generic | |
parent | e7b06be22c5631e265bf357563de6c907aceb35d (diff) | |
download | tcl-f546af5ac7018d30c4776d9c66006e2e8e425de7.zip tcl-f546af5ac7018d30c4776d9c66006e2e8e425de7.tar.gz tcl-f546af5ac7018d30c4776d9c66006e2e8e425de7.tar.bz2 |
* generic/tclCmdMZ.c (Tcl_RegexpObjCmd, Tcl_RegsubObjCmd):
reordered the retrieval of arguments to avoid shimmering bug when
the pattern and string referenced the same object.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCmdMZ.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index b70c7d8..2d1446b 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.42 2001/07/31 19:12:06 vincentdarley Exp $ + * RCS: @(#) $Id: tclCmdMZ.c,v 1.43 2001/08/07 00:56:15 hobbs Exp $ */ #include "tclInt.h" @@ -252,11 +252,18 @@ Tcl_RegexpObjCmd(dummy, interp, objc, objv) return TCL_ERROR; } + /* + * Get the length of the string that we are matching against so + * we can do the termination test for -all matches. Do this before + * getting the regexp to avoid shimmering problems. + */ + objPtr = objv[1]; + stringLength = Tcl_GetCharLength(objPtr); + regExpr = Tcl_GetRegExpFromObj(interp, objv[0], cflags); if (regExpr == NULL) { return TCL_ERROR; } - objPtr = objv[1]; if (about) { if (TclRegAbout(interp, regExpr) < 0) { @@ -292,12 +299,6 @@ Tcl_RegexpObjCmd(dummy, interp, objc, objv) } /* - * Get the length of the string that we are matching against so - * we can do the termination test for -all matches. - */ - stringLength = Tcl_GetCharLength(objPtr); - - /* * The following loop is to handle multiple matches within the * same source string; each iteration handles one match. If "-all" * hasn't been specified then the loop body only gets executed once. @@ -552,16 +553,21 @@ Tcl_RegsubObjCmd(dummy, interp, objc, objv) objv += idx; - regExpr = Tcl_GetRegExpFromObj(interp, objv[0], cflags); - if (regExpr == NULL) { - return TCL_ERROR; - } + /* + * Get the length of the string that we are matching before + * getting the regexp to avoid shimmering problems. + */ objPtr = objv[1]; wstring = Tcl_GetUnicodeFromObj(objPtr, &wlen); wsubspec = Tcl_GetUnicodeFromObj(objv[2], &wsublen); varPtr = objv[3]; + regExpr = Tcl_GetRegExpFromObj(interp, objv[0], cflags); + if (regExpr == NULL) { + return TCL_ERROR; + } + result = TCL_OK; resultPtr = Tcl_NewUnicodeObj(wstring, 0); Tcl_IncrRefCount(resultPtr); |