From d15aba899e3779eb8d2c9843c1d1d5b3efbfc20e Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Wed, 17 Oct 2007 12:51:08 +0800 Subject: [SHELL] Replace shared illnum message by badnum function. This patch adds the badnum function and uses it to mostly replace the use of illnum except in miscbltin where the current code turns out to be smaller because of the twin sh_error calls. --- src/mystring.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/mystring.c') diff --git a/src/mystring.c b/src/mystring.c index 8e1200a..ce48c82 100644 --- a/src/mystring.c +++ b/src/mystring.c @@ -108,6 +108,10 @@ prefix(const char *string, const char *pfx) return (char *) string; } +void badnum(const char *s) +{ + sh_error(illnum, s); +} /* * Convert a string into an integer of type intmax_t. Alow trailing spaces. @@ -121,20 +125,20 @@ intmax_t atomax(const char *s, int base) r = strtoimax(s, &p, base); if (errno != 0) - sh_error(illnum, s); + badnum(s); /* * Disallow completely blank strings in non-arithmetic (base != 0) * contexts. */ - if (base && (p == s)) - sh_error(illnum, s); + if (p == s && base) + badnum(s); while (isspace((unsigned char)*p)) p++; if (*p) - sh_error(illnum, s); + badnum(s); return r; } @@ -155,7 +159,7 @@ number(const char *s) intmax_t n = atomax10(s); if (n < 0 || n > INT_MAX) - sh_error(illnum, s); + badnum(s); return n; } -- cgit 1.4.1