diff options
Diffstat (limited to 'function.c')
-rw-r--r-- | function.c | 36 |
1 files changed, 15 insertions, 21 deletions
@@ -673,35 +673,29 @@ func_words (char *o, char **argv, const char *funcname) return o; } -char * -strip_whitespace (char **begpp, char **endpp) +static char * +strip_whitespace (const char **begpp, const char **endpp) { while (isspace ((unsigned char)**begpp) && *begpp <= *endpp) (*begpp) ++; while (isspace ((unsigned char)**endpp) && *endpp >= *begpp) (*endpp) --; - return *begpp; + return (char *)*begpp; } -int -is_numeric (char *p) +static void +check_numeric (const char *s, const char *message) { - char *end = p + strlen (p) - 1; - char *beg = p; - strip_whitespace (&p, &end); - - while (p <= end) - if (!ISDIGIT (*(p++))) /* ISDIGIT only evals its arg once: see make.h. */ - return 0; + const char *end = s + strlen (s) - 1; + const char *beg = s; + strip_whitespace (&s, &end); - return (end - beg >= 0); -} + for (; s <= end; ++s) + if (!ISDIGIT (*s)) /* ISDIGIT only evals its arg once: see make.h. */ + break; -void -check_numeric (char *s, char *message) -{ - if (!is_numeric (s)) - fatal (reading_file, message); + if (s <= end || end - beg < 0) + fatal (reading_file, "%s: '%s'", message, beg); } @@ -1134,8 +1128,8 @@ func_sort (char *o, char **argv, const char *funcname) static char * func_if (char *o, char **argv, const char *funcname) { - char *begp = argv[0]; - char *endp = begp + strlen (argv[0]); + const char *begp = argv[0]; + const char *endp = begp + strlen (argv[0]); int result = 0; /* Find the result of the condition: if we have a value, and it's not |