diff options
author | dgp <dgp@users.sourceforge.net> | 2004-01-13 17:13:01 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2004-01-13 17:13:01 (GMT) |
commit | 5699baa407d41e3ffbfd4848004c5eb0bc3f8c0d (patch) | |
tree | de337bd64706c5f0f9bbf424af23988d1ba6ba27 /generic/tclFileName.c | |
parent | f7489b194766b891ed93052af61d87ab57197122 (diff) | |
download | tcl-5699baa407d41e3ffbfd4848004c5eb0bc3f8c0d.zip tcl-5699baa407d41e3ffbfd4848004c5eb0bc3f8c0d.tar.gz tcl-5699baa407d41e3ffbfd4848004c5eb0bc3f8c0d.tar.bz2 |
* generic/tclFileName.c (Tcl_GlobObjCmd): Latest changes to
management of the interp result by Tcl_GetIndexFromObj() exposed
improper interp result management in the [glob] command procedure.
Corrected by adopting the Tcl_SetObjResult(Tcl_NewStringObj) pattern.
Diffstat (limited to 'generic/tclFileName.c')
-rw-r--r-- | generic/tclFileName.c | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/generic/tclFileName.c b/generic/tclFileName.c index c9995f6..52ebfd8 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclFileName.c,v 1.44 2003/10/13 16:48:06 vincentdarley Exp $ + * RCS: @(#) $Id: tclFileName.c,v 1.45 2004/01/13 17:13:01 dgp Exp $ */ #include "tclInt.h" @@ -1585,7 +1585,6 @@ Tcl_GlobObjCmd(dummy, interp, objc, objv) join = 0; dir = PATH_NONE; typePtr = NULL; - resultPtr = Tcl_GetObjResult(interp); for (i = 1; i < objc; i++) { if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", 0, &index) != TCL_OK) { @@ -1611,14 +1610,14 @@ Tcl_GlobObjCmd(dummy, interp, objc, objv) break; case GLOB_DIR: /* -dir */ if (i == (objc-1)) { - Tcl_AppendToObj(resultPtr, - "missing argument to \"-directory\"", -1); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "missing argument to \"-directory\"", -1)); return TCL_ERROR; } if (dir != PATH_NONE) { - Tcl_AppendToObj(resultPtr, + Tcl_SetObjResult(interp, Tcl_NewStringObj( "\"-directory\" cannot be used with \"-path\"", - -1); + -1)); return TCL_ERROR; } dir = PATH_DIR; @@ -1634,14 +1633,14 @@ Tcl_GlobObjCmd(dummy, interp, objc, objv) break; case GLOB_PATH: /* -path */ if (i == (objc-1)) { - Tcl_AppendToObj(resultPtr, - "missing argument to \"-path\"", -1); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "missing argument to \"-path\"", -1)); return TCL_ERROR; } if (dir != PATH_NONE) { - Tcl_AppendToObj(resultPtr, + Tcl_SetObjResult(interp, Tcl_NewStringObj( "\"-path\" cannot be used with \"-directory\"", - -1); + -1)); return TCL_ERROR; } dir = PATH_GENERAL; @@ -1650,8 +1649,8 @@ Tcl_GlobObjCmd(dummy, interp, objc, objv) break; case GLOB_TYPE: /* -types */ if (i == (objc-1)) { - Tcl_AppendToObj(resultPtr, - "missing argument to \"-types\"", -1); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "missing argument to \"-types\"", -1)); return TCL_ERROR; } typePtr = objv[i+1]; @@ -1671,9 +1670,9 @@ Tcl_GlobObjCmd(dummy, interp, objc, objv) return TCL_ERROR; } if ((globFlags & TCL_GLOBMODE_TAILS) && (pathOrDir == NULL)) { - Tcl_AppendToObj(resultPtr, + Tcl_SetObjResult(interp, Tcl_NewStringObj( "\"-tails\" must be used with either \"-directory\" or \"-path\"", - -1); + -1)); return TCL_ERROR; } @@ -1832,8 +1831,7 @@ Tcl_GlobObjCmd(dummy, interp, objc, objv) } } /* - * Error cases. We re-get the interpreter's result, - * just to be sure it hasn't changed, and we reset + * Error cases. We reset * the 'join' flag to zero, since we haven't yet * made use of it. */ @@ -1845,10 +1843,9 @@ Tcl_GlobObjCmd(dummy, interp, objc, objv) join = 0; goto endOfGlob; badMacTypesArg: - resultPtr = Tcl_GetObjResult(interp); - Tcl_AppendToObj(resultPtr, + Tcl_SetObjResult(interp, Tcl_NewStringObj( "only one MacOS type or creator argument" - " to \"-types\" allowed", -1); + " to \"-types\" allowed", -1)); result = TCL_ERROR; join = 0; goto endOfGlob; @@ -1864,11 +1861,6 @@ Tcl_GlobObjCmd(dummy, interp, objc, objv) */ objc -= i; objv += i; - /* - * We re-retrieve this, in case it was changed in - * the Tcl_ResetResult above - */ - resultPtr = Tcl_GetObjResult(interp); result = TCL_OK; if (join) { if (dir != PATH_GENERAL) { |