diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-12-19 21:31:05 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-12-19 21:31:05 (GMT) |
| commit | a0f11eae42f9260f584f97332464ac95c9713062 (patch) | |
| tree | 3c0b67b5c7bb04e308be339b640ec870c569e9eb /generic/tclUtil.c | |
| parent | ea5ed2816227e42d880192807f19c4ed5fd49da0 (diff) | |
| parent | 3a7b07be0d7da9b0c0b0397913d4cce60c8160a5 (diff) | |
| download | tcl-a0f11eae42f9260f584f97332464ac95c9713062.zip tcl-a0f11eae42f9260f584f97332464ac95c9713062.tar.gz tcl-a0f11eae42f9260f584f97332464ac95c9713062.tar.bz2 | |
Merge 8.5
Diffstat (limited to 'generic/tclUtil.c')
| -rw-r--r-- | generic/tclUtil.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 41b3481..a0f1fa0 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3597,10 +3597,10 @@ TclFormatInt( * formatted characters are written. */ long n) /* The integer to format. */ { - long intVal; + unsigned long intVal; int i; int numFormatted, j; - const char *digits = "0123456789"; + static const char digits[] = "0123456789"; /* * Check first whether "n" is zero. @@ -3613,27 +3613,16 @@ TclFormatInt( } /* - * Check whether "n" is the maximum negative value. This is -2^(m-1) for - * an m-bit word, and has no positive equivalent; negating it produces the - * same value. - */ - - intVal = -n; /* [Bug 3390638] Workaround for*/ - if (n == -n || intVal == n) { /* broken compiler optimizers. */ - return sprintf(buffer, "%ld", n); - } - - /* * Generate the characters of the result backwards in the buffer. */ - intVal = (n < 0? -n : n); + intVal = (n < 0 ? -n : n); i = 0; buffer[0] = '\0'; do { i++; buffer[i] = digits[intVal % 10]; - intVal = intVal/10; + intVal = intVal / 10; } while (intVal > 0); if (n < 0) { i++; |
