summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r--generic/tclUtil.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index d065069..f858bb4 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -3316,10 +3316,10 @@ TclFormatInt(buffer, n)
* formatted characters are written. */
long n; /* The integer to format. */
{
- long intVal;
+ unsigned long intVal;
int i;
int numFormatted, j;
- char *digits = "0123456789";
+ static const char digits[] = "0123456789";
/*
* Check first whether "n" is zero.
@@ -3332,27 +3332,16 @@ TclFormatInt(buffer, n)
}
/*
- * 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++;