diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclCmdAH.c | 39 |
2 files changed, 10 insertions, 34 deletions
@@ -1,3 +1,8 @@ +2004-09-23 Don Porter <dgp@users.sourceforge.net> + + * generic/tclCmdAH.c (Tcl_ExprObjCmd): Simplified the TclObjCmdProc + of [expr] with a call to Tcl_ConcatObj. + 2004-09-22 Don Porter <dgp@users.sourceforge.net> * generic/tclCmdMZ.c (TclProcessReturn): Support the -errorline diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index cf57fce..fdcdac5 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdAH.c,v 1.47 2004/09/19 13:08:31 msofer Exp $ + * RCS: @(#) $Id: tclCmdAH.c,v 1.48 2004/09/23 15:20:52 dgp Exp $ */ #include "tclInt.h" @@ -758,52 +758,23 @@ Tcl_ExprObjCmd(dummy, interp, objc, objv) { register Tcl_Obj *objPtr; Tcl_Obj *resultPtr; - register char *bytes; - int length, i, result; + int result; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "arg ?arg ...?"); return TCL_ERROR; } - if (objc == 2) { - result = Tcl_ExprObj(interp, objv[1], &resultPtr); - if (result == TCL_OK) { - Tcl_SetObjResult(interp, resultPtr); - Tcl_DecrRefCount(resultPtr); /* done with the result object */ - } - return result; - } - - /* - * Create a new object holding the concatenated argument strings. - */ - - /*** QUESTION: Do we need to copy the slow way? ***/ - bytes = Tcl_GetStringFromObj(objv[1], &length); - objPtr = Tcl_NewStringObj(bytes, length); + objPtr = Tcl_ConcatObj(objc-1, objv+1); Tcl_IncrRefCount(objPtr); - for (i = 2; i < objc; i++) { - Tcl_AppendToObj(objPtr, " ", 1); - bytes = Tcl_GetStringFromObj(objv[i], &length); - Tcl_AppendToObj(objPtr, bytes, length); - } - - /* - * Evaluate the concatenated string object. - */ - result = Tcl_ExprObj(interp, objPtr, &resultPtr); + Tcl_DecrRefCount(objPtr); + if (result == TCL_OK) { Tcl_SetObjResult(interp, resultPtr); Tcl_DecrRefCount(resultPtr); /* done with the result object */ } - /* - * Free allocated resources. - */ - - Tcl_DecrRefCount(objPtr); return result; } |