summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-06 13:25:09 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-06 13:25:09 (GMT)
commitae33d6bbf676b0bdd074ee8a295a1c35a6107459 (patch)
tree1ece81994881f86ac385b13fa273e712e7cffdfb
parent92be9569b81be3e3c9c99455ad609fe5f8e2e76e (diff)
downloadtcl-ae33d6bbf676b0bdd074ee8a295a1c35a6107459.zip
tcl-ae33d6bbf676b0bdd074ee8a295a1c35a6107459.tar.gz
tcl-ae33d6bbf676b0bdd074ee8a295a1c35a6107459.tar.bz2
Fix tclScan.c, not generating a string representation any more with unsigned wideints and unsigned longs.
-rw-r--r--generic/tclScan.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/generic/tclScan.c b/generic/tclScan.c
index b0669ab..4b9298d 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -585,9 +585,6 @@ Tcl_ScanObjCmd(
Tcl_UniChar ch = 0, sch = 0;
Tcl_Obj **objs = NULL, *objPtr = NULL;
int flags;
- char buf[513]; /* Temporary buffer to hold scanned number
- * strings before they are passed to
- * strtoul. */
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv,
@@ -937,9 +934,9 @@ Tcl_ScanObjCmd(
}
}
if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) {
- sprintf(buf, "%" TCL_LL_MODIFIER "u",
- (Tcl_WideUInt)wideValue);
- Tcl_SetStringObj(objPtr, buf, -1);
+ mp_int big;
+ TclBNInitBignumFromWideUInt(&big, (Tcl_WideUInt)wideValue);
+ Tcl_SetBignumObj(objPtr, &big);
} else {
Tcl_SetWideIntObj(objPtr, wideValue);
}
@@ -952,8 +949,13 @@ Tcl_ScanObjCmd(
}
}
if ((flags & SCAN_UNSIGNED) && (value < 0)) {
- sprintf(buf, "%lu", value); /* INTL: ISO digit */
- Tcl_SetStringObj(objPtr, buf, -1);
+#ifdef TCL_WIDE_INT_IS_LONG
+ mp_int big;
+ TclBNInitBignumFromWideUInt(&big, (unsigned long)value);
+ Tcl_SetBignumObj(objPtr, &big);
+#else
+ Tcl_SetWideIntObj(objPtr, (unsigned long)value);
+#endif
} else {
Tcl_SetLongObj(objPtr, value);
}