From a597aaddfa76d589d3e1a37b1f1c3401c2decffd Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sat, 16 Dec 2006 23:48:13 +0000 Subject: s/extern inline/static ATTRIBUTE_ALWAYS_INLINE/g xstrtou: disallow leading '+' --- libbb/getopt32.c | 2 -- libbb/xatonum.c | 3 ++- libbb/xatonum_template.c | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'libbb') diff --git a/libbb/getopt32.c b/libbb/getopt32.c index dddf812..50343fd 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c @@ -447,7 +447,6 @@ getopt32(int argc, char **argv, const char *applet_opts, ...) } va_end (p); -#if ENABLE_AR || ENABLE_TAR if (spec_flgs & FIRST_ARGV_IS_OPT) { if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0') { argv[1] = xasprintf("-%s", argv[1]); @@ -455,7 +454,6 @@ getopt32(int argc, char **argv, const char *applet_opts, ...) spec_flgs |= FREE_FIRST_ARGV_IS_OPT; } } -#endif /* Note: just "getopt() <= 0" will not work good for * "fake" short options, like this one: * wget $'-\203' "Test: test" http://kernel.org/ diff --git a/libbb/xatonum.c b/libbb/xatonum.c index 35607c3..dec3c2d 100644 --- a/libbb/xatonum.c +++ b/libbb/xatonum.c @@ -34,7 +34,8 @@ #endif #if UINT_MAX != ULONG_MAX -extern inline unsigned bb_strtoui(const char *str, char **end, int b) +static ATTRIBUTE_ALWAYS_INLINE +unsigned bb_strtoui(const char *str, char **end, int b) { unsigned long v = strtoul(str, end, b); if (v > UINT_MAX) { diff --git a/libbb/xatonum_template.c b/libbb/xatonum_template.c index 53ba544..ce01995 100644 --- a/libbb/xatonum_template.c +++ b/libbb/xatonum_template.c @@ -24,7 +24,7 @@ unsigned type xstrtou(_range_sfx)(const char *numstr, int base, /* 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. */ - if ((*numstr == '-') || (isspace)(*numstr)) + if (*numstr == '-' || *numstr == '+' || (isspace)(*numstr)) goto inval; /* Since this is a lib function, we're not allowed to reset errno to 0. @@ -36,7 +36,7 @@ unsigned type xstrtou(_range_sfx)(const char *numstr, int base, /* Do the initial validity check. Note: The standards do not * guarantee that errno is set if no digits were found. So we * must test for this explicitly. */ - if (errno || (numstr == e)) + if (errno || numstr == e) goto inval; /* error / no digits / illegal trailing chars */ errno = old_errno; /* Ok. So restore errno. */ @@ -127,7 +127,7 @@ type xstrto(_range_sfx)(const char *numstr, int base, type r; const char *p = numstr; - if ((p[0] == '-') && (p[1] != '+')) { + if (p[0] == '-') { ++p; ++u; /* two's complement */ } -- cgit v1.1