summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-05-25 10:26:59 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-05-25 10:26:59 (GMT)
commitf544dd76f2e5c1b1b878c3d683f16f8aab7b6f9e (patch)
tree5b34e0a916b5c68e2fe35f08a739faa2187586dc
parentf35ca5603a4148fbdfd60f956ba427be2ea53861 (diff)
downloadtcl-f544dd76f2e5c1b1b878c3d683f16f8aab7b6f9e.zip
tcl-f544dd76f2e5c1b1b878c3d683f16f8aab7b6f9e.tar.gz
tcl-f544dd76f2e5c1b1b878c3d683f16f8aab7b6f9e.tar.bz2
Add testcases and fix implementation
-rw-r--r--generic/tclCmdMZ.c25
-rw-r--r--tests/string.test6
2 files changed, 21 insertions, 10 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 8d3eda9..d57dc69 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -1451,6 +1451,7 @@ StringIsCmd(
int (*chcomp)(int) = NULL; /* The UniChar comparison function. */
int i, failat = 0, result = 1, strict = 0, index, length1, length2;
Tcl_Obj *objPtr, *failVarObj = NULL;
+ Tcl_WideInt w;
static const char *const isClasses[] = {
"alnum", "alpha", "ascii", "control",
@@ -1592,9 +1593,17 @@ StringIsCmd(
case STR_IS_INT: {
void *p;
int type;
- if (TCL_OK == TclGetNumberFromObj(NULL, objPtr, &p, &type)
- && (type == TCL_NUMBER_LONG) && (*(long *)p <= INT_MAX) && (*(long *)p >= INT_MIN)) {
- break;
+ if (TCL_OK == TclGetNumberFromObj(NULL, objPtr, &p, &type)) {
+ if (type == TCL_NUMBER_LONG
+#ifndef TCL_WIDE_INT_IS_LONG
+ || type == TCL_NUMBER_WIDE
+#endif
+ || type == TCL_NUMBER_BIG) {
+ /* [string is integer] is -UINT_MAX to UINT_MAX range */
+ if (TclGetIntFromObj(NULL, objPtr, &i) == TCL_OK) {
+ break;
+ }
+ }
}
}
goto failedIntParse;
@@ -1643,13 +1652,9 @@ StringIsCmd(
failat = 0;
}
break;
- case STR_IS_WIDE: {
- void *p;
- int type;
- if (TCL_OK == TclGetNumberFromObj(NULL, objPtr, &p, &type)
- && (type == TCL_NUMBER_WIDE)) {
- break;
- }
+ case STR_IS_WIDE:
+ if (TCL_OK == TclGetWideIntFromObj(NULL, objPtr, &w)) {
+ break;
}
failedIntParse:
diff --git a/tests/string.test b/tests/string.test
index 172b22d..ad6b126 100644
--- a/tests/string.test
+++ b/tests/string.test
@@ -795,6 +795,12 @@ test string-6.130.1.$noComp {string is entier, false on bad octal} {
test string-6.131.$noComp {string is entier, false on bad hex} {
list [run {string is entier -fail var 0X12345611234123456123456562345612345612345612345612345612345612345612345612345612345345XYZ}] $var
} {0 88}
+test string-6.132.$noComp {string is integer, bug [76ad7aeba3]} {
+ run {string is integer 18446744073709551615}
+} 0
+test string-6.133.$noComp {string is integer, bug [76ad7aeba3]} {
+ run {string is integer -18446744073709551615}
+} 0
catch {rename largest_int {}}