diff options
-rw-r--r-- | libbb/procps.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libbb/procps.c b/libbb/procps.c index c06ff1d70..40587db82 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
@@ -127,11 +127,11 @@ static unsigned long fast_strtoul_16(char **endptr) | |||
127 | char *str = *endptr; | 127 | char *str = *endptr; |
128 | unsigned long n = 0; | 128 | unsigned long n = 0; |
129 | 129 | ||
130 | /* need to stop on both ' ' and '\n' */ | 130 | /* Need to stop on both ' ' and '\n' */ |
131 | while ((c = *str++) > ' ') { | 131 | while ((c = *str++) > ' ') { |
132 | c = ((c|0x20) - '0'); | 132 | c = ((c|0x20) - '0'); |
133 | if (c > 9) | 133 | if (c > 9) |
134 | // c = c + '0' - 'a' + 10: | 134 | /* c = c + '0' - 'a' + 10: */ |
135 | c = c - ('a' - '0' - 10); | 135 | c = c - ('a' - '0' - 10); |
136 | n = n*16 + c; | 136 | n = n*16 + c; |
137 | } | 137 | } |
@@ -144,11 +144,12 @@ static unsigned long fast_strtoul_16(char **endptr) | |||
144 | /* We cut a lot of corners here for speed */ | 144 | /* We cut a lot of corners here for speed */ |
145 | static unsigned long fast_strtoul_10(char **endptr) | 145 | static unsigned long fast_strtoul_10(char **endptr) |
146 | { | 146 | { |
147 | char c; | 147 | unsigned char c; |
148 | char *str = *endptr; | 148 | char *str = *endptr; |
149 | unsigned long n = *str - '0'; | 149 | unsigned long n = *str - '0'; |
150 | 150 | ||
151 | while ((c = *++str) != ' ') | 151 | /* Need to stop on both ' ' and '\n' */ |
152 | while ((c = *++str) > ' ') | ||
152 | n = n*10 + (c - '0'); | 153 | n = n*10 + (c - '0'); |
153 | 154 | ||
154 | *endptr = str + 1; /* We skip trailing space! */ | 155 | *endptr = str + 1; /* We skip trailing space! */ |