* src/function.c (parse_numeric): Check for empty value and error.
If we find ERANGE just print our own error, not strerror.
(func_word): Use a generic "not good" error message.
(func_wordlist): Ditto
(func_intcmp): Ditto
* tests/run_make_tests.pl: Remove code to find strerror(ERANGE)
* tests/scrips/functions/intcmp: Update the error message.
* tests/scrips/functions/word: Ditto.
long long num;
strip_whitespace (&beg, &end);
+ if (beg > end)
+ OS (fatal, *expanding_var, _("%s: empty value"), msg);
+
errno = 0;
num = strtoll (beg, &endp, 10);
if (errno == ERANGE)
- OSS (fatal, *expanding_var, "%s: '%s'", strerror (errno), s);
+ OSS (fatal, *expanding_var, _("%s: '%s' out of range"), msg, s);
else if (endp == beg || endp <= end)
/* Empty or non-numeric input */
OSS (fatal, *expanding_var, "%s: '%s'", msg, s);
long long i;
i = parse_numeric (argv[0],
- _("non-numeric first argument to 'word' function"));
+ _("invalid first argument to 'word' function"));
if (i < 1)
O (fatal, *expanding_var,
_("first argument to 'word' function must be greater than 0"));
long long start, stop, count;
start = parse_numeric (argv[0],
- _("non-numeric first argument to 'wordlist' function"));
+ _("invalid first argument to 'wordlist' function"));
stop = parse_numeric (argv[1],
- _("non-numeric second argument to 'wordlist' function"));
+ _("invalid second argument to 'wordlist' function"));
if (start < 1)
ON (fatal, *expanding_var,
long long lhs, rhs;
lhs = parse_numeric (lhs_str,
- _("non-numeric first argument to 'intcmp' function"));
+ _("invalid first argument to 'intcmp' function"));
rhs = parse_numeric (rhs_str,
- _("non-numeric second argument to 'intcmp' function"));
+ _("invalid second argument to 'intcmp' function"));
free (lhs_str);
free (rhs_str);
$ERR_unreadable_file = undef;
$ERR_nonexe_file = undef;
$ERR_exe_dir = undef;
-$ERR_out_of_range = undef;
{
use locale;
# See set_defaults() as this doesn't work right on Windows :(
$! = &POSIX::ERANGE;
- $ERR_out_of_range = "$!";
- } else {
- $ERR_out_of_range = 'Numerical result out of range';
}
if (open(my $F, '<', 'file.none')) {
$scriptsuffix = '.com';
} else {
$scriptsuffix = '.bat';
-
- # Frustratingly, Perl reports the wrong strerror string for ERANGE.
- # It's weird because Python gets it right. Not sure what's going on.
- $ERR_out_of_range = 'Result too large';
}
}
intcmp-e4: ; @echo $(intcmp -1)
intcmp-e5: ; @echo $(intcmp ,55)',
'intcmp-e1',
- "#MAKEFILE#:2: *** non-numeric first argument to 'intcmp' function: '12a'. Stop.",
+ "#MAKEFILE#:2: *** invalid first argument to 'intcmp' function: '12a'. Stop.",
512);
run_make_test(undef,
'intcmp-e2',
- "#MAKEFILE#:3: *** non-numeric second argument to 'intcmp' function: ''. Stop.",
+ "#MAKEFILE#:3: *** invalid second argument to 'intcmp' function: empty value. Stop.",
512);
run_make_test(undef,
'intcmp-e3',
- "#MAKEFILE#:4: *** $ERR_out_of_range: '9999999999999999999'. Stop.",
+ "#MAKEFILE#:4: *** invalid second argument to 'intcmp' function: '9999999999999999999' out of range. Stop.",
512);
wordlist-e2: ; @echo $(wordlist abc ,,$(FOO))
wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO))',
'word-e1',
- "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''. Stop.",
+ "#MAKEFILE#:3: *** invalid first argument to 'word' function: empty value. Stop.",
512);
run_make_test(undef,
'word-e2',
- "#MAKEFILE#:4: *** non-numeric first argument to 'word' function: 'abc '. Stop.",
+ "#MAKEFILE#:4: *** invalid first argument to 'word' function: 'abc '. Stop.",
512);
run_make_test(undef,
'word-e3',
- "#MAKEFILE#:5: *** non-numeric first argument to 'word' function: '1a'. Stop.",
+ "#MAKEFILE#:5: *** invalid first argument to 'word' function: '1a'. Stop.",
512);
run_make_test(undef,
'word-e4',
- "#MAKEFILE#:6: *** $ERR_out_of_range: '9999999999999999999'. Stop.",
+ "#MAKEFILE#:6: *** invalid first argument to 'word' function: '9999999999999999999' out of range. Stop.",
512);
run_make_test(undef,
'wordlist-e1',
- "#MAKEFILE#:8: *** non-numeric first argument to 'wordlist' function: ''. Stop.",
+ "#MAKEFILE#:8: *** invalid first argument to 'wordlist' function: empty value. Stop.",
512);
run_make_test(undef,
'wordlist-e2',
- "#MAKEFILE#:9: *** non-numeric first argument to 'wordlist' function: 'abc '. Stop.",
+ "#MAKEFILE#:9: *** invalid first argument to 'wordlist' function: 'abc '. Stop.",
512);
run_make_test(undef,
'wordlist-e3',
- "#MAKEFILE#:10: *** non-numeric second argument to 'wordlist' function: ' 12a '. Stop.",
+ "#MAKEFILE#:10: *** invalid second argument to 'wordlist' function: ' 12a '. Stop.",
512);
# Test error conditions again, but this time in a variable reference
word-e: ; @echo $(W)
wordlist-e: ; @echo $(WL)',
'word-e x=',
- "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''. Stop.",
+ "#MAKEFILE#:3: *** invalid first argument to 'word' function: empty value. Stop.",
512);
run_make_test(undef,
'word-e x=abc',
- "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: 'abc'. Stop.",
+ "#MAKEFILE#:3: *** invalid first argument to 'word' function: 'abc'. Stop.",
512);
run_make_test(undef,
run_make_test(undef,
'wordlist-e s= e=',
- "#MAKEFILE#:4: *** non-numeric first argument to 'wordlist' function: ''. Stop.",
+ "#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: empty value. Stop.",
512);
run_make_test(undef,
'wordlist-e s=abc e=',
- "#MAKEFILE#:4: *** non-numeric first argument to 'wordlist' function: 'abc'. Stop.",
+ "#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: 'abc'. Stop.",
512);
run_make_test(undef,
'wordlist-e s=4 e=12a',
- "#MAKEFILE#:4: *** non-numeric second argument to 'wordlist' function: '12a'. Stop.",
+ "#MAKEFILE#:4: *** invalid second argument to 'wordlist' function: '12a'. Stop.",
512);
run_make_test(undef,