diff options
author | dgp <dgp@users.sourceforge.net> | 2004-09-23 15:20:51 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2004-09-23 15:20:51 (GMT) |
commit | 4f322d5b3ce0b5f7a1c8dd8dd0871b23eb879f1f (patch) | |
tree | 9d317a385851761b51daf1748bdeea182a077145 /generic/tclCmdAH.c | |
parent | 3d626bd65d08f71f02584942012773bd014c6acb (diff) | |
download | tcl-4f322d5b3ce0b5f7a1c8dd8dd0871b23eb879f1f.zip tcl-4f322d5b3ce0b5f7a1c8dd8dd0871b23eb879f1f.tar.gz tcl-4f322d5b3ce0b5f7a1c8dd8dd0871b23eb879f1f.tar.bz2 |
* generic/tclCmdAH.c (Tcl_ExprObjCmd): Simplified the TclObjCmdProc
of [expr] with a call to Tcl_ConcatObj.
Diffstat (limited to 'generic/tclCmdAH.c')
-rw-r--r-- | generic/tclCmdAH.c | 39 |
1 files changed, 5 insertions, 34 deletions
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; } |