[SV 56655] Allow pattern expansion to contain spaces

* src/dep.h: Add a new flag PARSEFS_ONEWORD
* src/read.c (parse_file_seq): If PARSEFS_ONEWORD is given, treat the
entire incoming string as a single pattern.
* src/implicit.c (pattern_search): Pass PARSEFS_ONEWORD when parsing
patterns for wildcards.
* tests/scripts/features/patternrules: Add a new test.
This commit is contained in:
Paul Smith 2019-12-26 18:39:56 -05:00
parent 30cc10093b
commit 564fb212a7
4 changed files with 14 additions and 2 deletions

View File

@ -74,6 +74,7 @@ struct goaldep
#define PARSEFS_NOGLOB 0x0004
#define PARSEFS_EXISTS 0x0008
#define PARSEFS_NOCACHE 0x0010
#define PARSEFS_ONEWORD 0x0020
#define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \
(_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f))

View File

@ -559,7 +559,7 @@ pattern_search (struct file *file, int archive,
/* Parse the expanded string. It might have wildcards. */
p = depname;
dl = PARSE_SIMPLE_SEQ (&p, struct dep);
dl = PARSE_FILE_SEQ (&p, struct dep, MAP_NUL, NULL, PARSEFS_ONEWORD);
for (d = dl; d != NULL; d = d->next)
{
++deps_found;

View File

@ -3138,7 +3138,10 @@ parse_file_seq (char **stringp, size_t size, int stopmap,
char *p;
glob_t gl;
char *tp;
int findmap = stopmap|MAP_VMSCOMMA|MAP_BLANK|MAP_NUL;
int findmap = stopmap|MAP_VMSCOMMA|MAP_NUL;
if (NONE_SET (flags, PARSEFS_ONEWORD))
findmap |= MAP_BLANK;
/* Always stop on NUL. */
stopmap |= MAP_NUL;

View File

@ -236,6 +236,14 @@ all: a.elf a.dbg
unlink('a.c');
# SV 56655: Test patterns matching files containing whitespace
touch('some file.yy');
run_make_test(q!
%.xx : %.yy ; @echo matched
!, 'some\ file.xx', "matched\n");
unlink('some file.xx', 'some file.yy');
# This tells the test driver that the perl test script executed properly.
1;