From 4f322d5b3ce0b5f7a1c8dd8dd0871b23eb879f1f Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 23 Sep 2004 15:20:51 +0000 Subject: * generic/tclCmdAH.c (Tcl_ExprObjCmd): Simplified the TclObjCmdProc of [expr] with a call to Tcl_ConcatObj. --- ChangeLog | 5 +++++ generic/tclCmdAH.c | 39 +++++---------------------------------- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index d5becb8..10e8149 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-09-23 Don Porter + + * generic/tclCmdAH.c (Tcl_ExprObjCmd): Simplified the TclObjCmdProc + of [expr] with a call to Tcl_ConcatObj. + 2004-09-22 Don Porter * 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; } -- cgit v0.12