aboutsummaryrefslogtreecommitdiff
path: root/libbb/xatonum_template.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-12-11 13:15:11 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-12-11 13:15:11 +0000
commit2cd4a747e5a0cc7db52c84d02208a2e292fd8275 (patch)
tree022ce9a90c57f8d73327884fdac50c50e0dea3fc /libbb/xatonum_template.c
parentd7e2e127a93afe2a88922ef94fa00fe8db39d834 (diff)
downloadbusybox-w32-2cd4a747e5a0cc7db52c84d02208a2e292fd8275.tar.gz
busybox-w32-2cd4a747e5a0cc7db52c84d02208a2e292fd8275.tar.bz2
busybox-w32-2cd4a747e5a0cc7db52c84d02208a2e292fd8275.zip
num conversions: allow for leading '+' (renice needs that)
Diffstat (limited to 'libbb/xatonum_template.c')
-rw-r--r--libbb/xatonum_template.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libbb/xatonum_template.c b/libbb/xatonum_template.c
index 205da53c8..9f9dc1102 100644
--- a/libbb/xatonum_template.c
+++ b/libbb/xatonum_template.c
@@ -21,9 +21,8 @@ unsigned type xstrtou(_range_sfx)(const char *numstr, int base,
21 int old_errno; 21 int old_errno;
22 char *e; 22 char *e;
23 23
24 /* Disallow '-' and any leading whitespace. Speed isn't critical here 24 /* Disallow '-' and any leading whitespace. Make sure we get the
25 * since we're parsing commandline args. So make sure we get the 25 * actual isspace function rather than a macro implementaion. */
26 * actual isspace function rather than a lnumstrer macro implementaion. */
27 if (*numstr == '-' || *numstr == '+' || (isspace)(*numstr)) 26 if (*numstr == '-' || *numstr == '+' || (isspace)(*numstr))
28 goto inval; 27 goto inval;
29 28
@@ -127,9 +126,12 @@ type xstrto(_range_sfx)(const char *numstr, int base,
127 type r; 126 type r;
128 const char *p = numstr; 127 const char *p = numstr;
129 128
130 if (p[0] == '-') { 129 /* NB: if you'll decide to disallow '+':
130 * at least renice applet needs to allow it */
131 if (p[0] == '+' || p[0] == '-') {
131 ++p; 132 ++p;
132 ++u; /* two's complement */ 133 if (p[0] == '-')
134 ++u; /* = <type>_MIN (01111... + 1 == 10000...) */
133 } 135 }
134 136
135 r = xstrtou(_range_sfx)(p, base, 0, u, suffixes); 137 r = xstrtou(_range_sfx)(p, base, 0, u, suffixes);