summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2002-04-26 08:34:35 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2002-04-26 08:34:35 (GMT)
commitc8e99da5d0319a457285611fac52310c44d51a17 (patch)
tree3589d9074adf160f620f5136910bc07f777937ab
parent02546348bdc5f6cc2e49cc4c8a5666f7e7830643 (diff)
downloadtcl-c8e99da5d0319a457285611fac52310c44d51a17.zip
tcl-c8e99da5d0319a457285611fac52310c44d51a17.tar.gz
tcl-c8e99da5d0319a457285611fac52310c44d51a17.tar.bz2
Hex values on 64-bit machines can be booleans too! [Bug 548686]
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclObj.c28
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 <fellowsd@cs.man.ac.uk>
+
+ * generic/tclObj.c (SetBooleanFromAny): Was not calling an integer
+ parsing function on native 64-bit platforms! [Bug 548686]
+
2002-04-24 Jeff Hobbs <jeffh@ActiveState.com>
* 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