From 00452d9d7d4d961a4659fc21e69febb307d184f0 Mon Sep 17 00:00:00 2001 From: nijtmans Date: Tue, 25 Nov 2008 23:19:01 +0000 Subject: Eliminate 3 calls to Tcl_SetResult, as examples how it should have been done. purpose: contribute in the TIP #340 discussion. --- ChangeLog | 6 ++++++ generic/tclIO.c | 11 ++--------- generic/tclIndexObj.c | 4 ++-- generic/tclTestObj.c | 5 ++--- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index e645581..a1199bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-11-25 Jan Nijtmans + + * generic/tclIndexObj.c: Eliminate 3 calls to Tcl_SetResult, as + * generic/tclIO.c examples how it should have been done. + * generic/tclTestObj.c purpose: contribute in the TIP #340 discussion. + 2008-11-25 Andreas Kupries * generic/tclIO.c (TclFinalizeIOSubsystem): Applied Alexandre diff --git a/generic/tclIO.c b/generic/tclIO.c index b7c7b02..fdd6cba 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.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: tclIO.c,v 1.149 2008/11/25 22:13:34 andreas_kupries Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.150 2008/11/25 23:19:01 nijtmans Exp $ */ #include "tclInt.h" @@ -2383,14 +2383,7 @@ FlushChannel( Tcl_SetErrno(errorCode); if (interp != NULL && !TclChanCaughtErrorBypass(interp, (Tcl_Channel) chanPtr)) { - /* - * Casting away const here is safe because the - * TCL_VOLATILE flag guarantees const treatment of the - * Posix error string. - */ - - Tcl_SetResult(interp, (char *) Tcl_PosixError(interp), - TCL_VOLATILE); + Tcl_SetObjResult(interp, Tcl_NewStringObj(Tcl_PosixError(interp), -1)); } /* diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index f04db71..d0fb382 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIndexObj.c,v 1.46 2008/10/14 22:37:53 nijtmans Exp $ + * RCS: @(#) $Id: tclIndexObj.c,v 1.47 2008/11/25 23:19:02 nijtmans Exp $ */ #include "tclInt.h" @@ -1263,7 +1263,7 @@ Tcl_ParseArgsObjv( sprintf(buf, "bad argument type %d in Tcl_ArgvInfo", infoPtr->type); - Tcl_SetResult(interp, buf, TCL_VOLATILE); + Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); goto error; } } diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c index 842cbd0..c643822 100644 --- a/generic/tclTestObj.c +++ b/generic/tclTestObj.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: tclTestObj.c,v 1.25 2008/10/16 22:34:19 nijtmans Exp $ + * RCS: @(#) $Id: tclTestObj.c,v 1.26 2008/11/25 23:19:02 nijtmans Exp $ */ #include "tclInt.h" @@ -930,8 +930,7 @@ TestobjCmd( if (CheckIfVarUnset(interp, varIndex)) { return TCL_ERROR; } - TclFormatInt(buf, varPtr[varIndex]->refCount); - Tcl_SetResult(interp, buf, TCL_VOLATILE); + Tcl_SetObjResult(interp, Tcl_NewIntObj(varPtr[varIndex]->refCount)); } else if (strcmp(subCmd, "type") == 0) { if (objc != 3) { goto wrongNumArgs; -- cgit v0.12