From c8e99da5d0319a457285611fac52310c44d51a17 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 26 Apr 2002 08:34:35 +0000 Subject: Hex values on 64-bit machines can be booleans too! [Bug 548686] --- ChangeLog | 5 +++++ generic/tclObj.c | 28 +++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d176832..c769e48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-04-26 Donal K. Fellows + + * generic/tclObj.c (SetBooleanFromAny): Was not calling an integer + parsing function on native 64-bit platforms! [Bug 548686] + 2002-04-24 Jeff Hobbs * generic/tclInt.h: corrected TclRememberJoinableThread decl to diff --git a/generic/tclObj.c b/generic/tclObj.c index 15b84ca..9dc2b90 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.32 2002/02/27 07:08:28 hobbs Exp $ + * RCS: @(#) $Id: tclObj.c,v 1.33 2002/04/26 08:34:35 dkf Exp $ */ #include "tclInt.h" @@ -1166,7 +1166,29 @@ SetBooleanFromAny(interp, objPtr) } } else { double dbl; -#ifndef TCL_WIDE_INT_IS_LONG + /* + * Boolean values can be extracted from ints or doubles. Note + * that we don't use strtoul or strtoull here because we don't + * care about what the value is, just whether it is equal to + * zero or not. + */ +#ifdef TCL_WIDE_INT_IS_LONG + newBool = strtol(string, &end, 0); + if (end != string) { + /* + * Make sure the string has no garbage after the end of + * the int. + */ + while ((end < (string+length)) + && isspace(UCHAR(*end))) { /* INTL: ISO only */ + end++; + } + if (end == (string+length)) { + newBool = (newBool != 0); + goto goodBoolean; + } + } +#else /* !TCL_WIDE_INT_IS_LONG */ Tcl_WideInt wide = strtoll(string, &end, 0); if (end != string) { /* @@ -1182,7 +1204,7 @@ SetBooleanFromAny(interp, objPtr) goto goodBoolean; } } -#endif +#endif /* TCL_WIDE_INT_IS_LONG */ /* * Still might be a string containing the characters representing an * int or double that wasn't handled above. This would be a string -- cgit v0.12