aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-02-28 11:16:21 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2012-02-28 11:16:21 +0100
commit62c006d508552a6ac547b807eb9ad0a32a76e1c9 (patch)
treeddf8e5d1196916c5131029ab3441038b1c10b677 /libbb
parentcd09e81520b7917adebcffd7c361671f913325eb (diff)
downloadbusybox-62c006d508552a6ac547b807eb9ad0a32a76e1c9.tar.gz
libbb/procps.c: make fast_strtoul_10() stop on '\n' too
This time for real :) Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/procps.c9
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)
char *str = *endptr;
unsigned long n = 0;
- /* need to stop on both ' ' and '\n' */
+ /* Need to stop on both ' ' and '\n' */
while ((c = *str++) > ' ') {
c = ((c|0x20) - '0');
if (c > 9)
- // c = c + '0' - 'a' + 10:
+ /* c = c + '0' - 'a' + 10: */
c = c - ('a' - '0' - 10);
n = n*16 + c;
}
@@ -144,11 +144,12 @@ static unsigned long fast_strtoul_16(char **endptr)
/* We cut a lot of corners here for speed */
static unsigned long fast_strtoul_10(char **endptr)
{
- char c;
+ unsigned char c;
char *str = *endptr;
unsigned long n = *str - '0';
- while ((c = *++str) != ' ')
+ /* Need to stop on both ' ' and '\n' */
+ while ((c = *++str) > ' ')
n = n*10 + (c - '0');
*endptr = str + 1; /* We skip trailing space! */