Enhancement (bug #2407) Make error messages more clear.

This commit is contained in:
Paul Smith
2003-01-30 06:21:36 +00:00
parent d33ff30145
commit b7c728046e
6 changed files with 81 additions and 47 deletions

View File

@@ -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);
const char *end = s + strlen (s) - 1;
const char *beg = s;
strip_whitespace (&s, &end);
while (p <= end)
if (!ISDIGIT (*(p++))) /* ISDIGIT only evals its arg once: see make.h. */
return 0;
for (; s <= end; ++s)
if (!ISDIGIT (*s)) /* ISDIGIT only evals its arg once: see make.h. */
break;
return (end - beg >= 0);
}
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