diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-11-08 07:58:54 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-11-08 07:58:54 (GMT) |
| commit | 65946d3f86dd49b65b128b71d4b2c4b4a020a277 (patch) | |
| tree | de96ec0e799aa9b8efbce68fd0209f52754f1276 /generic/tclScan.c | |
| parent | 208e4fd87b7123289717f2a292a056da196f3665 (diff) | |
| parent | 09776ae1965b3568cf927e2d4d1f6fc3727ea8c5 (diff) | |
| download | tcl-65946d3f86dd49b65b128b71d4b2c4b4a020a277.zip tcl-65946d3f86dd49b65b128b71d4b2c4b4a020a277.tar.gz tcl-65946d3f86dd49b65b128b71d4b2c4b4a020a277.tar.bz2 | |
For long/wide "scans"'s of negative numbers, but scanned as unsigned, generate binary representation in stead of string representation just as for all other numbers.
Diffstat (limited to 'generic/tclScan.c')
| -rw-r--r-- | generic/tclScan.c | 18 |
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); } |
