summaryrefslogtreecommitdiffhomepage
path: root/libbb
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
parentd7e2e127a93afe2a88922ef94fa00fe8db39d834 (diff)
num conversions: allow for leading '+' (renice needs that)
Diffstat (limited to 'libbb')
-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,
int old_errno;
char *e;
- /* Disallow '-' and any leading whitespace. Speed isn't critical here
- * since we're parsing commandline args. So make sure we get the
- * actual isspace function rather than a lnumstrer macro implementaion. */
+ /* Disallow '-' and any leading whitespace. Make sure we get the
+ * actual isspace function rather than a macro implementaion. */
if (*numstr == '-' || *numstr == '+' || (isspace)(*numstr))
goto inval;
@@ -127,9 +126,12 @@ type xstrto(_range_sfx)(const char *numstr, int base,
type r;
const char *p = numstr;
- if (p[0] == '-') {
+ /* NB: if you'll decide to disallow '+':
+ * at least renice applet needs to allow it */
+ if (p[0] == '+' || p[0] == '-') {
++p;
- ++u; /* two's complement */
+ if (p[0] == '-')
+ ++u; /* = <type>_MIN (01111... + 1 == 10000...) */
}
r = xstrtou(_range_sfx)(p, base, 0, u, suffixes);