summaryrefslogtreecommitdiffstats
path: root/generic/tclScan.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-08 11:44:37 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-08 11:44:37 (GMT)
commita3bdd051a3b9b1a52915cf92876753d802d9cdb8 (patch)
tree6e12b7b05459d951fb034a38423730146b73c94b /generic/tclScan.c
parent79b3f448c0f16d15dc6b44e04ab6790140458f44 (diff)
parent5de9b738d3fc73ba62f781f55ba8891ccec9764a (diff)
downloadtcl-a3bdd051a3b9b1a52915cf92876753d802d9cdb8.zip
tcl-a3bdd051a3b9b1a52915cf92876753d802d9cdb8.tar.gz
tcl-a3bdd051a3b9b1a52915cf92876753d802d9cdb8.tar.bz2
Merge 8.7
Diffstat (limited to 'generic/tclScan.c')
-rw-r--r--generic/tclScan.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/generic/tclScan.c b/generic/tclScan.c
index aa4e9c8..6f9515b 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -579,9 +579,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,
@@ -931,8 +928,16 @@ Tcl_ScanObjCmd(
}
}
if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) {
- sprintf(buf, "%" TCL_LL_MODIFIER "u", wideValue);
- Tcl_SetStringObj(objPtr, buf, -1);
+ mp_int big;
+ if (mp_init(&big) != MP_OKAY) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "insufficient memory to create bignum", -1));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ return TCL_ERROR;
+ } else {
+ mp_set_ull(&big, (Tcl_WideUInt)wideValue);
+ Tcl_SetBignumObj(objPtr, &big);
+ }
} else {
TclSetIntObj(objPtr, wideValue);
}
@@ -969,8 +974,20 @@ 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;
+ if (mp_init(&big) != MP_OKAY) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "insufficient memory to create bignum", -1));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ return TCL_ERROR;
+ } else {
+ mp_set_ull(&big, (unsigned long)value);
+ Tcl_SetBignumObj(objPtr, &big);
+ }
+#else
+ Tcl_SetWideIntObj(objPtr, (unsigned long)value);
+#endif
} else {
TclSetIntObj(objPtr, value);
}