diff options
author | dgp <dgp@users.sourceforge.net> | 2004-10-06 16:08:57 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2004-10-06 16:08:57 (GMT) |
commit | c9460f40ff148c46d7f52e7b5d7d7d16f32d64e1 (patch) | |
tree | 60a7cfd573fd09f30d678bc07810645e5f08df05 /unix | |
parent | b0e29724338467351f10a4b11e317a5866ac658f (diff) | |
download | tcl-c9460f40ff148c46d7f52e7b5d7d7d16f32d64e1.zip tcl-c9460f40ff148c46d7f52e7b5d7d7d16f32d64e1.tar.gz tcl-c9460f40ff148c46d7f52e7b5d7d7d16f32d64e1.tar.bz2 |
* generic/tclBasic.c:
* generic/tclBinary.c:
* generic/tclCmdAH.c:
* generic/tclCmdIL.c:
* generic/tclCmdMZ.c:
* generic/tclCompExpr.c:
* generic/tclDictObj.c:
* generic/tclEncoding.c:
* generic/tclExecute.c:
* generic/tclFCmd.c:
* generic/tclHistory.c:
* generic/tclIndexObj.c:
* generic/tclInterp.c:
* generic/tclIO.c:
* generic/tclIOCmd.c:
* generic/tclNamesp.c:
* generic/tclObj.c:
* generic/tclPkg.c:
* generic/tclResult.c:
* generic/tclScan.c:
* generic/tclTimer.c:
* generic/tclTrace.c:
* generic/tclUtil.c:
* generic/tclVar.c:
* unix/tclUnixFCmd.c:
* unix/tclUnixPipe.c:
It is a poor practice to directly set or append to the value
of the objResult of an interp, because that value might be
shared, and in that circumstance a Tcl_Panic() will be the
result. Searched for example of this practice and replaced
with safer alternatives, often using the Tcl_AppendResult()
routine that dkf just rehabilitated.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tclUnixFCmd.c | 11 | ||||
-rw-r--r-- | unix/tclUnixPipe.c | 7 |
2 files changed, 8 insertions, 10 deletions
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index d6282d1..f0a69b7 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.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: tclUnixFCmd.c,v 1.38 2004/09/03 10:59:43 dkf Exp $ + * RCS: @(#) $Id: tclUnixFCmd.c,v 1.39 2004/10/06 16:08:57 dgp Exp $ * * Portions of this code were derived from NetBSD source code which has * the following copyright notice: @@ -1483,8 +1483,7 @@ SetPermissionsAttribute(interp, objIndex, fileName, attributePtr) if (GetModeFromPermString(NULL, modeStringPtr, &newMode) != TCL_OK) { if (interp != NULL) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "unknown permission string format \"", + Tcl_AppendResult(interp, "unknown permission string format \"", modeStringPtr, "\"", (char *) NULL); } return TCL_ERROR; @@ -1495,8 +1494,7 @@ SetPermissionsAttribute(interp, objIndex, fileName, attributePtr) result = chmod(native, newMode); /* INTL: Native. */ if (result != 0) { if (interp != NULL) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "could not set permissions for file \"", + Tcl_AppendResult(interp, "could not set permissions for file \"", Tcl_GetString(fileName), "\": ", Tcl_PosixError(interp), (char *) NULL); } @@ -1974,8 +1972,7 @@ SetReadOnlyAttribute(interp, objIndex, fileName, attributePtr) result = chflags(native, statBuf.st_flags); /* INTL: Native. */ if (result != 0) { if (interp != NULL) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "could not set flags for file \"", + Tcl_AppendResult(interp, "could not set flags for file \"", Tcl_GetString(fileName), "\": ", Tcl_PosixError(interp), (char *) NULL); } diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index 77d1f8b..ee8bacc 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.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: tclUnixPipe.c,v 1.25 2004/06/08 19:18:39 dgp Exp $ + * RCS: @(#) $Id: tclUnixPipe.c,v 1.26 2004/10/06 16:08:57 dgp Exp $ */ #include "tclInt.h" @@ -1225,7 +1225,7 @@ Tcl_PidObjCmd(dummy, interp, objc, objv) return TCL_ERROR; } if (objc == 1) { - Tcl_SetLongObj(Tcl_GetObjResult(interp), (long) getpid()); + Tcl_SetObjResult(interp, Tcl_NewLongObj((long) getpid())); } else { chan = Tcl_GetChannel(interp, Tcl_GetString(objv[1]), NULL); if (chan == (Tcl_Channel) NULL) { @@ -1236,11 +1236,12 @@ Tcl_PidObjCmd(dummy, interp, objc, objv) return TCL_OK; } pipePtr = (PipeState *) Tcl_GetChannelInstanceData(chan); - resultPtr = Tcl_GetObjResult(interp); + resultPtr = Tcl_NewObj(); for (i = 0; i < pipePtr->numPids; i++) { longObjPtr = Tcl_NewLongObj((long) TclpGetPid(pipePtr->pidPtr[i])); Tcl_ListObjAppendElement(NULL, resultPtr, longObjPtr); } + Tcl_SetObjResult(interp, resultPtr); } return TCL_OK; } |