aboutsummaryrefslogtreecommitdiff
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
parentcd09e81520b7917adebcffd7c361671f913325eb (diff)
downloadbusybox-w32-62c006d508552a6ac547b807eb9ad0a32a76e1c9.tar.gz
busybox-w32-62c006d508552a6ac547b807eb9ad0a32a76e1c9.tar.bz2
busybox-w32-62c006d508552a6ac547b807eb9ad0a32a76e1c9.zip
libbb/procps.c: make fast_strtoul_10() stop on '\n' too
This time for real :) Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-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)
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 */
145static unsigned long fast_strtoul_10(char **endptr) 145static 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! */