From b7c728046e3f32cd93b04fa4a19a69cf6135e6e4 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 30 Jan 2003 06:21:36 +0000 Subject: Enhancement (bug #2407) Make error messages more clear. --- function.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'function.c') diff --git a/function.c b/function.c index a6a04d4..2edac74 100644 --- a/function.c +++ b/function.c @@ -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 -- cgit v1.2.3