aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);