From ae33d6bbf676b0bdd074ee8a295a1c35a6107459 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 6 Nov 2019 13:25:09 +0000 Subject: Fix tclScan.c, not generating a string representation any more with unsigned wideints and unsigned longs. --- generic/tclScan.c | 18 ++++++++++-------- 1 file 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); } -- cgit v0.12