diff options
author | Jim Meyering <jim@meyering.net> | 1995-06-12 18:28:24 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1995-06-12 18:28:24 +0000 |
commit | bcee3d43cae34c5732e3beb0fb0f9c7923095b0e (patch) | |
tree | f9770d420d9dea709bc89712c80b0bb2bd12b630 | |
parent | afe762e4e6043d15b97dc56a40ea0df5e598eaf0 (diff) | |
download | coreutils-bcee3d43cae34c5732e3beb0fb0f9c7923095b0e.tar.xz |
(non_neg_strtol): Don't compare signed and unsigned.
-rw-r--r-- | src/tr.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -871,11 +871,16 @@ non_neg_strtol (s, len, val) for (i = 0; i < len; i++) { - int c = s[i] - '0'; + unsigned int c; - if (c >= base || c < 0) + if (s[i] < '0') return 1; - if (i > 8 && sum > (LONG_MAX - c) / base) + + c = s[i] - '0'; + if (c >= base) + return 1; + + if (sum > (LONG_MAX - c) / base) return 1; sum = sum * base + c; } |