summaryrefslogtreecommitdiffstats
path: root/generic/tclBasic.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2005-05-18 20:54:54 (GMT)
committerdgp <dgp@users.sourceforge.net>2005-05-18 20:54:54 (GMT)
commit4459bed11ee445f9e2a6f0263e2b93a31add3dfe (patch)
treef6520152938217e3e1b7c6844e04e8cd77c8c63b /generic/tclBasic.c
parent50396dd2bcd7655741791d49bc4ba7a88fa5c2b9 (diff)
downloadtcl-4459bed11ee445f9e2a6f0263e2b93a31add3dfe.zip
tcl-4459bed11ee445f9e2a6f0263e2b93a31add3dfe.tar.gz
tcl-4459bed11ee445f9e2a6f0263e2b93a31add3dfe.tar.bz2
* generic/tclBasic.c (Tcl_ExprBoolean): Rewrite as wrapper around
Tcl_ExprBooleanObj. * generic/tclCmdMZ.c ([string is boolean/true/false]): Rewrite dropping string-based Tcl_GetBoolean call, so that internal reps are kept for subsequent quick boolean operations. * generic/tclExecute.c: Dropped most special handling of the "boolean" Tcl_ObjType, since that type should now be rarely encountered. * doc/BoolObj.3: Rewrite of documentation dropping many details about the internals of Tcl_Objs. Shorter documentation focuses on the function and use of the routines.
Diffstat (limited to 'generic/tclBasic.c')
-rw-r--r--generic/tclBasic.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 843a30a..d6e6695 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.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: tclBasic.c,v 1.153 2005/05/14 23:15:11 dkf Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.154 2005/05/18 20:55:03 dgp Exp $
*/
#include "tclInt.h"
@@ -4293,22 +4293,19 @@ Tcl_ExprBoolean(interp, exprstring, ptr)
CONST char *exprstring; /* Expression to evaluate. */
int *ptr; /* Where to store 0/1 result. */
{
- register Tcl_Obj *exprPtr;
- Tcl_Obj *resultPtr;
- int length = strlen(exprstring);
- int result = TCL_OK;
+ if (*exprstring == '\0') {
+ /*
+ * An empty string. Just set the result boolean to 0 (false).
+ */
- if (length > 0) {
- exprPtr = Tcl_NewStringObj(exprstring, length);
+ *ptr = 0;
+ return TCL_OK;
+ } else {
+ int result;
+ Tcl_Obj *exprPtr = Tcl_NewStringObj(exprstring, -1);
Tcl_IncrRefCount(exprPtr);
- result = Tcl_ExprObj(interp, exprPtr, &resultPtr);
- if (result == TCL_OK) {
- /*
- * Store a boolean based on the expression result.
- */
- result = Tcl_GetBooleanFromObj(interp, resultPtr, ptr);
- Tcl_DecrRefCount(resultPtr); /* discard the result object */
- }
+ result = Tcl_ExprBooleanObj(interp, exprPtr, ptr);
+ Tcl_DecrRefCount(exprPtr);
if (result != TCL_OK) {
/*
* Move the interpreter's object result to the string result,
@@ -4317,15 +4314,8 @@ Tcl_ExprBoolean(interp, exprstring, ptr)
(void) Tcl_GetStringResult(interp);
}
- Tcl_DecrRefCount(exprPtr); /* discard the expression object */
- } else {
- /*
- * An empty string. Just set the result boolean to 0 (false).
- */
-
- *ptr = 0;
+ return result;
}
- return result;
}
/*