diff options
author | dgp <dgp@users.sourceforge.net> | 2005-04-22 15:46:39 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2005-04-22 15:46:39 (GMT) |
commit | eea5a1d7018e33f7fa50a613d6a5b912e7bb6707 (patch) | |
tree | 07c4be3b6538e21a3c5f5538a7ef1831f6d9ed9c /generic/tclObj.c | |
parent | 918dbfe6102b60da44efe1c8344461ad3bddb4b0 (diff) | |
download | tcl-eea5a1d7018e33f7fa50a613d6a5b912e7bb6707.zip tcl-eea5a1d7018e33f7fa50a613d6a5b912e7bb6707.tar.gz tcl-eea5a1d7018e33f7fa50a613d6a5b912e7bb6707.tar.bz2 |
The 2005-04-21 changes to Tcl_GetBooleanFromObj were done to bring
it into agreement with its docs. Further investigation reveals it
was the docs that were incorrect.
* doc/BoolObj.3: Corrections to the documentation of
Tcl_GetBooleanFromObj to bring it into agreement with what this
public interface has always done, including noting the difference
in function between Tcl_GetBooleanFromObj and Tcl_GetBoolean.
* generic/tclGet.c: Revised Tcl_GetBoolean to no longer be a
wrapper around Tcl_GetBooleanFromObj (different function!).
* generic/tclObj.c: Removed TclGetTruthValueFromObj routine
that was added yesterday. Revisions so that only
Tcl_GetBoolean-approved values get the "boolean" Tcl_ObjType.
This retains the fix for [Bug 1187123].
* generic/tclInt.h: Revert most recent change.
* generic/tclBasic.c:
* generic/tclCompCmds.c:
* generic/tclDictObj.c:
* generic/tclExecute.c:
* tests/obj.test:
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r-- | generic/tclObj.c | 62 |
1 files changed, 15 insertions, 47 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c index 42acb01..bc073c2 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.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: tclObj.c,v 1.80 2005/04/21 20:35:04 dgp Exp $ + * RCS: @(#) $Id: tclObj.c,v 1.81 2005/04/22 15:46:59 dgp Exp $ */ #include "tclInt.h" @@ -1233,50 +1233,6 @@ Tcl_SetBooleanObj(objPtr, boolValue) * * Tcl_GetBooleanFromObj -- * - * Attempt to return a boolean from the Tcl object "objPtr". If the - * object is not already of the "boolean" Tcl_ObjType, an attempt - * will be made to convert it to one. - * - * Note that only exact boolean values are recognized, not all - * numeric values (use TclGetTruthValueFromObj() for that). - * - * Results: - * The return value is a standard Tcl object result. If an error occurs - * during conversion, an error message is left in the interpreter's - * result unless "interp" is NULL. - * - * Side effects: - * If the object is not already a boolean, the conversion will free - * any old internal representation. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetBooleanFromObj(interp, objPtr, boolPtr) - Tcl_Interp *interp; /* Used for error reporting if not NULL. */ - register Tcl_Obj *objPtr; /* The object from which to get boolean. */ - register int *boolPtr; /* Place to store resulting boolean. */ -{ - register int result; - - if (objPtr->typePtr == &tclBooleanType) { - result = TCL_OK; - } else { - result = SetBooleanFromAny(interp, objPtr); - } - - if (result == TCL_OK) { - *boolPtr = (int) objPtr->internalRep.longValue; - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * TclGetTruthValueFromObj -- - * * Attempt to return a boolean from the Tcl object "objPtr". This * includes conversion from any of Tcl's numeric types. * @@ -1292,7 +1248,7 @@ Tcl_GetBooleanFromObj(interp, objPtr, boolPtr) */ int -TclGetTruthValueFromObj(interp, objPtr, boolPtr) +Tcl_GetBooleanFromObj(interp, objPtr, boolPtr) Tcl_Interp *interp; /* Used for error reporting if not NULL. */ register Tcl_Obj *objPtr; /* The object from which to get boolean. */ register int *boolPtr; /* Place to store resulting boolean. */ @@ -1300,12 +1256,19 @@ TclGetTruthValueFromObj(interp, objPtr, boolPtr) double d; long l; + if (objPtr->typePtr == &tclBooleanType) { + *boolPtr = (int) objPtr->internalRep.longValue; + return TCL_OK; + } /* * The following call retrieves a numeric value without shimmering * away any existing numeric intrep Tcl_ObjTypes. */ if (Tcl_GetDoubleFromObj(NULL, objPtr, &d) == TCL_OK) { *boolPtr = (d != 0.0); + + /* Attempt shimmer to "boolean" objType */ + SetBooleanFromAny(NULL, objPtr); return TCL_OK; } /* @@ -1331,8 +1294,13 @@ TclGetTruthValueFromObj(interp, objPtr, boolPtr) #endif /* * Finally, check for the string values like "yes" + * and generate error message for non-boolean values. */ - return Tcl_GetBooleanFromObj(interp, objPtr, boolPtr); + if (SetBooleanFromAny(interp, objPtr) == TCL_OK) { + *boolPtr = (int) objPtr->internalRep.longValue; + return TCL_OK; + } + return TCL_ERROR; } /* |