host-cpu-c-abi
mempcpy
strerror
-strtol
+strtoll
make-glob"
/* Define if you have the strsignal function. */
/* #undef HAVE_STRSIGNAL */
+/* Define if you have the strtoll function. */
+/* #undef HAVE_STRTOLL */
+
/* Define if you have the wait3 function. */
/* #undef HAVE_WAIT3 */
/* Define to 1 if you have the strsignal function. */
/* #undef HAVE_STRSIGNAL */
+/* Define to 1 if you have the `strtoll' function. */
+#define HAVE_STRTOLL 1
+
/* Define to 1 if you have the wait3 function. */
/* #undef HAVE_WAIT3 */
/* Define to 1 if you have the 'strsignal' function. */
/* #undef HAVE_STRSIGNAL */
+/* Define to 1 if you have the `strtoll' function. */
+#define HAVE_STRTOLL 1
+
/* Define to 1 if `d_type' is a member of `struct dirent'. */
/* SV 57152: MinGW64 version of dirent doesn't support d_type. */
#ifndef __MINGW64__
return (char *)*begpp;
}
-static long
+static long long
parse_numeric (const char *s, const char *msg)
{
const char *beg = s;
const char *end = s + strlen (s) - 1;
char *endp;
- long num;
+ long long num;
strip_whitespace (&beg, &end);
errno = 0;
- num = strtol (beg, &endp, 10);
+ num = strtoll (beg, &endp, 10);
if (errno == ERANGE)
OSS (fatal, *expanding_var, "%s: '%s'", strerror (errno), s);
else if (endp == beg || endp <= end)
{
const char *end_p;
const char *p;
- long i;
+ long long i;
i = parse_numeric (argv[0],
_("non-numeric first argument to 'word' function"));
- if (i <= 0)
+ if (i < 1)
O (fatal, *expanding_var,
_("first argument to 'word' function must be greater than 0"));
static char *
func_wordlist (char *o, char **argv, const char *funcname UNUSED)
{
- long start, stop, count;
+ long long start, stop, count;
start = parse_numeric (argv[0],
_("non-numeric first argument to 'wordlist' function"));
if (start < 1)
ON (fatal, *expanding_var,
- "invalid first argument to 'wordlist' function: '%ld'", start);
+ "invalid first argument to 'wordlist' function: '%lld'", start);
+
+ if (stop < 0)
+ ON (fatal, *expanding_var,
+ "invalid second argument to 'wordlist' function: '%lld'", stop);
count = stop - start + 1;
{
char *lhs_str = expand_argument (argv[0], NULL);
char *rhs_str = expand_argument (argv[1], NULL);
- long lhs, rhs;
+ long long lhs, rhs;
lhs = parse_numeric (lhs_str,
_("non-numeric first argument to 'intcmp' function"));
if (lhs == rhs)
{
char buf[INTSTR_LENGTH+1];
- sprintf (buf, "%ld", lhs);
+ sprintf (buf, "%lld", lhs);
o = variable_buffer_output(o, buf, strlen (buf));
}
return o;
#define CSTRLEN(_s) (sizeof (_s)-1)
#define STRING_SIZE_TUPLE(_s) (_s), CSTRLEN(_s)
-/* The number of bytes needed to represent the largest integer as a string. */
-#define INTSTR_LENGTH CSTRLEN ("18446744073709551616")
+/* The number of bytes needed to represent the largest integer as a string.
+ Large enough for both the largest signed and unsigned long long. */
+#define INTSTR_LENGTH CSTRLEN ("18446744073709551615")
#define DEFAULT_TTYNAME "true"
#ifdef HAVE_TTYNAME
$ERR_unreadable_file = undef;
$ERR_nonexe_file = undef;
$ERR_exe_dir = undef;
+$ERR_out_of_range = undef;
{
use locale;
# Windows has POSIX locale, but only LC_ALL not LC_MESSAGES
$loc = POSIX::setlocale(&POSIX::LC_ALL);
POSIX::setlocale(&POSIX::LC_ALL, 'C');
+
+ # 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';
}
}
z = 0
# Positive
p = 1000000000
+min = -9223372036854775808
+max = 9223372036854775807
.RECIPEPREFIX = >
all:
> @echo 0_1 $(intcmp $n,$n)
> @echo 3_1 $(intcmp $z,$p,lt,eq,gt)
> @echo 3_2 $(intcmp $p,$z,lt,eq,gt)
> @echo 3_3 $(intcmp $p,$p,lt,eq,gt)
-', '', "0_1 -10\n0_2\n0_3\n1_1\n1_2 lt\n1_3\n2_1 lt\n2_2 ge\n2_3 ge\n3_0\n3_1 lt\n3_2 gt\n3_3 eq\n");
+> @echo 4_0 $(intcmp $(min),$(max),lt,eq,gt)
+> @echo 4_1 $(intcmp $(max),$(min),lt,eq,gt)
+> @echo 4_2 $(intcmp $(min),$(min),lt,eq,gt)
+> @echo 4_3 $(intcmp $(max),$(max),lt,eq,gt)
+', '', "0_1 -10\n0_2\n0_3\n1_1\n1_2 lt\n1_3\n2_1 lt\n2_2 ge\n2_3 ge\n3_0\n3_1 lt\n3_2 gt\n3_3 eq\n4_0 lt\n4_1 gt\n4_2 eq\n4_3 eq\n");
# Test error conditions
run_make_test(undef,
'intcmp-e3',
- "#MAKEFILE#:4: *** Numerical result out of range: '9999999999999999999'. Stop.",
+ "#MAKEFILE#:4: *** $ERR_out_of_range: '9999999999999999999'. Stop.",
512);
Produce a variable with a large number of words in it,
determine the number of words, and then read each one back.\n";
-open(MAKEFILE,"> $makefile");
-print MAKEFILE <<'EOF';
+run_make_test('
string := word.pl general_test2.pl FORCE.pl word.pl generic_test.perl MAKEFILES_variable.pl
string2 := $(string) $(string) $(string) $(string) $(string) $(string) $(string)
string3 := $(string2) $(string2) $(string2) $(string2) $(string2) $(string2) $(string2)
string4 := $(string3) $(string3) $(string3) $(string3) $(string3) $(string3) $(string3)
+.RECIPEPREFIX = >
all:
- @echo $(words $(string))
- @echo $(words $(string4))
- @echo $(word 1, $(string))
- @echo $(word 100, $(string))
- @echo $(word 1, $(string))
- @echo $(word 1000, $(string3))
- @echo $(wordlist 3, 4, $(string))
- @echo $(wordlist 4, 3, $(string))
- @echo $(wordlist 1, 6, $(string))
- @echo $(wordlist 5, 7, $(string))
- @echo $(wordlist 100, 110, $(string))
- @echo $(wordlist 7, 10, $(string2))
-EOF
-close(MAKEFILE);
-
-&run_make_with_options($makefile, "", &get_logfile);
-$answer = "6\n"
- ."2058\n"
- ."word.pl\n"
- ."\n"
- ."word.pl\n"
- ."\n"
- ."FORCE.pl word.pl\n"
- ."\n"
- ."word.pl general_test2.pl FORCE.pl word.pl generic_test.perl MAKEFILES_variable.pl\n"
- ."generic_test.perl MAKEFILES_variable.pl\n"
- ."\n"
- ."word.pl general_test2.pl FORCE.pl word.pl\n";
-&compare_output($answer, &get_logfile(1));
-
+> @echo $(words $(string))
+> @echo $(words $(string4))
+> @echo $(word 1, $(string))
+> @echo $(word 100, $(string))
+> @echo $(word 1 , $(string))
+> @echo $(word 1000, $(string3))
+> @echo $(word 9223372036854775807, $(string2))
+> @echo $(wordlist 3, 4, $(string))
+> @echo $(wordlist 4, 3, $(string))
+> @echo $(wordlist 1 , 6 , $(string))
+> @echo $(wordlist 5,7, $(string))
+> @echo $(wordlist 100, 110, $(string))
+> @echo $(wordlist 7, 10, $(string2))
+> @echo $(wordlist 9223372036854775807, 0, $(string2))
+', '', "6\n"
+ ."2058\n"
+ ."word.pl\n"
+ ."\n"
+ ."word.pl\n"
+ ."\n"
+ ."\n"
+ ."FORCE.pl word.pl\n"
+ ."\n"
+ ."word.pl general_test2.pl FORCE.pl word.pl generic_test.perl MAKEFILES_variable.pl\n"
+ ."generic_test.perl MAKEFILES_variable.pl\n"
+ ."\n"
+ ."word.pl general_test2.pl FORCE.pl word.pl\n"
+ ."\n"
+);
# Test error conditions
run_make_test(undef,
'word-e4',
- "#MAKEFILE#:6: *** Numerical result out of range: '9999999999999999999'. Stop.",
+ "#MAKEFILE#:6: *** $ERR_out_of_range: '9999999999999999999'. Stop.",
512);
run_make_test(undef,
"#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: '0'. Stop.",
512);
+run_make_test(undef,
+ 'wordlist-e s=1 e=-1',
+ "#MAKEFILE#:4: *** invalid second argument to 'wordlist' function: '-1'. Stop.",
+ 512);
+
# TEST #8 -- test $(firstword )
#
.PHONY: all
-all:
- @test "$a" = "$b" && echo $a
+all: ; @test "$a" = "$b" && echo $a
',
'',
'foo');
.PHONY: all
-all:
- @test "$a" = "$b" && echo $a
+all: ; @test "$a" = "$b" && echo $a
',
'',
'baz');