diff options
author | hobbs <hobbs> | 2001-08-07 00:51:12 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2001-08-07 00:51:12 (GMT) |
commit | 48ae72be11de3a91bee0e85531e7f9c25d921287 (patch) | |
tree | c8a1a9bdcb943b8abc2999b517a26255571b6de8 /generic/tclCmdMZ.c | |
parent | add60805e64260e099001e7d1da305ecedd74d68 (diff) | |
download | tcl-48ae72be11de3a91bee0e85531e7f9c25d921287.zip tcl-48ae72be11de3a91bee0e85531e7f9c25d921287.tar.gz tcl-48ae72be11de3a91bee0e85531e7f9c25d921287.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/tclCmdMZ.c')
-rw-r--r-- | generic/tclCmdMZ.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 5695702..f8798c5 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.26.2.1 2001/04/03 22:54:36 hobbs Exp $ + * RCS: @(#) $Id: tclCmdMZ.c,v 1.26.2.2 2001/08/07 00:51:12 hobbs Exp $ */ #include "tclInt.h" @@ -149,7 +149,7 @@ Tcl_RegexpObjCmd(dummy, interp, objc, objv) offset = 0; all = 0; doinline = 0; - + for (i = 1; i < objc; i++) { char *name; int index; @@ -235,11 +235,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) { @@ -275,12 +282,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. @@ -530,6 +531,17 @@ Tcl_RegsubObjCmd(dummy, interp, objc, objv) objv += i; + /* + * Get the length of the string that we are matching before + * getting the regexp to avoid shimmering problems. + */ + + objPtr = objv[1]; + wlen = Tcl_GetCharLength(objPtr); + wstring = Tcl_GetUnicode(objPtr); + subspec = Tcl_GetString(objv[2]); + varPtr = objv[3]; + regExpr = Tcl_GetRegExpFromObj(interp, objv[0], cflags); if (regExpr == NULL) { return TCL_ERROR; @@ -539,12 +551,6 @@ Tcl_RegsubObjCmd(dummy, interp, objc, objv) resultPtr = Tcl_NewObj(); Tcl_IncrRefCount(resultPtr); - objPtr = objv[1]; - wlen = Tcl_GetCharLength(objPtr); - wstring = Tcl_GetUnicode(objPtr); - subspec = Tcl_GetString(objv[2]); - varPtr = objv[3]; - /* * The following loop is to handle multiple matches within the * same source string; each iteration handles one match and its |