summaryrefslogtreecommitdiff
path: root/function.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2003-01-30 06:21:36 +0000
committerPaul Smith <psmith@gnu.org>2003-01-30 06:21:36 +0000
commitb7c728046e3f32cd93b04fa4a19a69cf6135e6e4 (patch)
tree21f7a6b69cfdf22223052f65fa76fe05946110c5 /function.c
parentd33ff301454fa1db9919674dbc2a37309bbd529f (diff)
downloadgunmake-b7c728046e3f32cd93b04fa4a19a69cf6135e6e4.tar.gz
Enhancement (bug #2407) Make error messages more clear.
Diffstat (limited to 'function.c')
-rw-r--r--function.c36
1 files changed, 15 insertions, 21 deletions
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