diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
commit | cad5364599eb5062d59e0c397ed638ddd61a8d5d (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /libbb/xgetlarg.c | |
parent | e01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff) | |
download | busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2 busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip |
Major coreutils update.
Diffstat (limited to 'libbb/xgetlarg.c')
-rw-r--r-- | libbb/xgetlarg.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libbb/xgetlarg.c b/libbb/xgetlarg.c index 598b0b3d6..06e776dc9 100644 --- a/libbb/xgetlarg.c +++ b/libbb/xgetlarg.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <getopt.h> | 9 | #include <getopt.h> |
10 | #include <errno.h> | 10 | #include <errno.h> |
11 | #include <assert.h> | 11 | #include <assert.h> |
12 | #include <ctype.h> | ||
12 | 13 | ||
13 | #include "busybox.h" | 14 | #include "busybox.h" |
14 | 15 | ||
@@ -19,10 +20,16 @@ extern long bb_xgetlarg(char *arg, int base, long lower, long upper) | |||
19 | int errno_save = errno; | 20 | int errno_save = errno; |
20 | 21 | ||
21 | assert(arg!=NULL); | 22 | assert(arg!=NULL); |
23 | |||
24 | /* Don't allow leading whitespace. */ | ||
25 | if ((isspace)(*arg)) { /* Use an actual funciton call for minimal size. */ | ||
26 | bb_show_usage(); | ||
27 | } | ||
28 | |||
22 | errno = 0; | 29 | errno = 0; |
23 | result = strtol(arg, &endptr, base); | 30 | result = strtol(arg, &endptr, base); |
24 | if (errno != 0 || *endptr!='\0' || result < lower || result > upper) | 31 | if (errno != 0 || *endptr!='\0' || endptr==arg || result < lower || result > upper) |
25 | show_usage(); | 32 | bb_show_usage(); |
26 | errno = errno_save; | 33 | errno = errno_save; |
27 | return result; | 34 | return result; |
28 | } | 35 | } |