diff options
author | dgp <dgp@users.sourceforge.net> | 2018-02-23 18:01:26 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2018-02-23 18:01:26 (GMT) |
commit | a9e916f1b99088ecc8185ace75245d6801aebaf6 (patch) | |
tree | 19be952cac68a19fce1cb3dd961d2dc5ca56977b /generic/tclObj.c | |
parent | c908681186e6c76d5479749ed6ca70b458d093fd (diff) | |
parent | 6faf2feff2aa8ca778eccc29cb8c43c14ea6199d (diff) | |
download | tcl-a9e916f1b99088ecc8185ace75245d6801aebaf6.zip tcl-a9e916f1b99088ecc8185ace75245d6801aebaf6.tar.gz tcl-a9e916f1b99088ecc8185ace75245d6801aebaf6.tar.bz2 |
merge 8.7
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r-- | generic/tclObj.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c index 86e5894..c99dedd 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -2101,7 +2101,7 @@ Tcl_GetBooleanFromObj( return TCL_OK; } if (objPtr->typePtr == &tclBooleanType) { - *boolPtr = (int) objPtr->internalRep.longValue; + *boolPtr = objPtr->internalRep.longValue != 0; return TCL_OK; } if (objPtr->typePtr == &tclDoubleType) { @@ -2145,7 +2145,12 @@ Tcl_GetBooleanFromObj( * * Side effects: * If no error occurs, an integer 1 or 0 is stored as "objPtr"s internal - * representation and the type of "objPtr" is set to boolean. + * representation and the type of "objPtr" is set to boolean or int/wideInt. + * + * Warning: If the returned type is "wideInt" (32-bit platforms) and your + * platform is bigendian, you cannot use internalRep.longValue to distinguish + * between false and true. On Windows and most other platforms this still will + * work fine, but basically it is non-portable. * *---------------------------------------------------------------------- */ @@ -2163,8 +2168,7 @@ TclSetBooleanFromAny( if (objPtr->bytes == NULL) { if (objPtr->typePtr == &tclIntType) { - switch (objPtr->internalRep.wideValue) { - case 0L: case 1L: + if ((Tcl_WideUInt)objPtr->internalRep.wideValue < 2) { return TCL_OK; } goto badBoolean; |