projects
/
platform
/
upstream
/
coreutils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
afe762e
)
(non_neg_strtol): Don't compare signed and unsigned.
author
Jim Meyering
<jim@meyering.net>
Mon, 12 Jun 1995 18:28:24 +0000
(18:28 +0000)
committer
Jim Meyering
<jim@meyering.net>
Mon, 12 Jun 1995 18:28:24 +0000
(18:28 +0000)
src/tr.c
patch
|
blob
|
history
diff --git
a/src/tr.c
b/src/tr.c
index
8775613
..
474da3e
100644
(file)
--- a/
src/tr.c
+++ b/
src/tr.c
@@
-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;
}