mirror of
https://github.com/mirror/make.git
synced 2025-01-04 01:10:26 +08:00
* src/read.c (parse_file_seq): [SV 52076] Don't reverse glob() results.
This commit is contained in:
parent
715c787dc6
commit
7e60ffe83e
12
src/read.c
12
src/read.c
@ -3182,7 +3182,7 @@ parse_file_seq (char **stringp, size_t size, int stopmap,
|
|||||||
#endif
|
#endif
|
||||||
char *s;
|
char *s;
|
||||||
size_t nlen;
|
size_t nlen;
|
||||||
int i;
|
int tot, i;
|
||||||
|
|
||||||
/* Skip whitespace; at the end of the string or STOPCHAR we're done. */
|
/* Skip whitespace; at the end of the string or STOPCHAR we're done. */
|
||||||
NEXT_TOKEN (p);
|
NEXT_TOKEN (p);
|
||||||
@ -3391,7 +3391,7 @@ parse_file_seq (char **stringp, size_t size, int stopmap,
|
|||||||
if (NONE_SET (flags, PARSEFS_EXISTS) && strpbrk (name, "?*[") == NULL)
|
if (NONE_SET (flags, PARSEFS_EXISTS) && strpbrk (name, "?*[") == NULL)
|
||||||
{
|
{
|
||||||
globme = 0;
|
globme = 0;
|
||||||
i = 1;
|
tot = 1;
|
||||||
nlist = &name;
|
nlist = &name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3402,7 +3402,7 @@ parse_file_seq (char **stringp, size_t size, int stopmap,
|
|||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
/* Success. */
|
/* Success. */
|
||||||
i = gl.gl_pathc;
|
tot = gl.gl_pathc;
|
||||||
nlist = (const char **)gl.gl_pathv;
|
nlist = (const char **)gl.gl_pathv;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3410,20 +3410,20 @@ parse_file_seq (char **stringp, size_t size, int stopmap,
|
|||||||
/* If we want only existing items, skip this one. */
|
/* If we want only existing items, skip this one. */
|
||||||
if (ANY_SET (flags, PARSEFS_EXISTS))
|
if (ANY_SET (flags, PARSEFS_EXISTS))
|
||||||
{
|
{
|
||||||
i = 0;
|
tot = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* By default keep this name. */
|
/* By default keep this name. */
|
||||||
i = 1;
|
tot = 1;
|
||||||
nlist = &name;
|
nlist = &name;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For each matched element, add it to the list. */
|
/* For each matched element, add it to the list. */
|
||||||
while (i-- > 0)
|
for (i = 0; i < tot; ++i)
|
||||||
#ifndef NO_ARCHIVES
|
#ifndef NO_ARCHIVES
|
||||||
if (memname != 0)
|
if (memname != 0)
|
||||||
{
|
{
|
||||||
|
@ -13,52 +13,33 @@ test echo's all files which match '?.example' and
|
|||||||
[a-z0-9].example. Lastly we clean up all of the files using
|
[a-z0-9].example. Lastly we clean up all of the files using
|
||||||
the '*' wildcard as in the first test";
|
the '*' wildcard as in the first test";
|
||||||
|
|
||||||
open(MAKEFILE,"> $makefile");
|
touch("example.1");
|
||||||
|
touch("example.two");
|
||||||
# The Contents of the MAKEFILE ...
|
touch("example.3");
|
||||||
|
touch("example.for");
|
||||||
print MAKEFILE <<EOM;
|
touch("example._");
|
||||||
.PHONY: print1 print2 clean
|
|
||||||
print1: ;\@echo \$(sort \$(wildcard example.*))
|
|
||||||
print2:
|
|
||||||
\t\@echo \$(sort \$(wildcard example.?))
|
|
||||||
\t\@echo \$(sort \$(wildcard example.[a-z0-9]))
|
|
||||||
\t\@echo \$(sort \$(wildcard example.[!A-Za-z_\\!]))
|
|
||||||
clean:
|
|
||||||
\t$CMD_rmfile \$(sort \$(wildcard example.*))
|
|
||||||
EOM
|
|
||||||
|
|
||||||
# END of Contents of MAKEFILE
|
|
||||||
|
|
||||||
close(MAKEFILE);
|
|
||||||
|
|
||||||
&touch("example.1");
|
|
||||||
&touch("example.two");
|
|
||||||
&touch("example.3");
|
|
||||||
&touch("example.for");
|
|
||||||
&touch("example._");
|
|
||||||
|
|
||||||
# TEST #1
|
# TEST #1
|
||||||
# -------
|
# -------
|
||||||
|
|
||||||
$answer = "example.1 example.3 example._ example.for example.two\n";
|
run_make_test(qq/
|
||||||
|
.PHONY: print1 print2 clean
|
||||||
&run_make_with_options($makefile,"print1",&get_logfile);
|
print1: ;\@echo \$(wildcard example.*)
|
||||||
|
print2:
|
||||||
&compare_output($answer,&get_logfile(1));
|
\t\@echo \$(wildcard example.?)
|
||||||
|
\t\@echo \$(wildcard example.[a-z0-9])
|
||||||
|
\t\@echo \$(wildcard example.[!A-Za-z_\\!])
|
||||||
|
clean:
|
||||||
|
\t$CMD_rmfile \$(wildcard example.*)
|
||||||
|
/,
|
||||||
|
'print1', "example.1 example.3 example._ example.for example.two\n");
|
||||||
|
|
||||||
# TEST #2
|
# TEST #2
|
||||||
# -------
|
# -------
|
||||||
|
|
||||||
$answer = "example.1 example.3 example._\n"
|
run_make_test(undef, 'print2', "example.1 example.3 example._\n"
|
||||||
."example.1 example.3\n"
|
."example.1 example.3\n"
|
||||||
."example.1 example.3\n";
|
."example.1 example.3\n");
|
||||||
|
|
||||||
&run_make_with_options($makefile,"print2",&get_logfile);
|
|
||||||
|
|
||||||
&compare_output($answer,&get_logfile(1));
|
|
||||||
|
|
||||||
|
|
||||||
# TEST #3
|
# TEST #3
|
||||||
# -------
|
# -------
|
||||||
@ -73,13 +54,7 @@ else
|
|||||||
$answer .= "\n";
|
$answer .= "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
&run_make_with_options($makefile,"clean",&get_logfile);
|
run_make_test(undef, 'clean', $answer);
|
||||||
|
|
||||||
if ((-f "example.1")||(-f "example.two")||(-f "example.3")||(-f "example.for")) {
|
|
||||||
$test_passed = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&compare_output($answer,&get_logfile(1));
|
|
||||||
|
|
||||||
# TEST #4: Verify that failed wildcards don't return the pattern
|
# TEST #4: Verify that failed wildcards don't return the pattern
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user