- Fix Savannah bug 17825

- Fix Savannah bug 21231
This commit is contained in:
Paul Smith 2009-06-13 21:21:48 +00:00
parent c8840352ac
commit bf9822658f
13 changed files with 79 additions and 40 deletions

View File

@ -1,5 +1,23 @@
2009-06-13 Paul Smith <psmith@gnu.org>
* function.c (string_glob): Rely on multi_glob() to determine
whether files exist or not. Remove call to file_exists_p() which
is not always correct. Fixes Savannah bug #21231.
* read.c (multi_glob): Add a new argument EXISTS_ONLY; if true
then only files that really exist will be returned.
* dep.h: Add new argument to multi_glob().
* rule.c (install_pattern_rule): Ditto.
* read.c (eval): Ditto.
* main.c (main): Ditto.
* implicit.c (pattern_search): Ditto.
* file.c (parse_prereqs): Ditto.
* default.c (set_default_suffixes): Ditto.
2009-06-09 Paul Smith <psmith@gnu.org> 2009-06-09 Paul Smith <psmith@gnu.org>
* commands.c (set_file_variables): If always_make_flag is set,
always add the prereq to $?. Fixes Savannah bug #17825.
* remake.c (update_file_1): When rebuilding deps of FILE, also try * remake.c (update_file_1): When rebuilding deps of FILE, also try
to rebuild the deps of all the also_make targets for that file. to rebuild the deps of all the also_make targets for that file.
Fixes Savannah bug #19108. Fixes Savannah bug #19108.

View File

@ -240,7 +240,7 @@ set_file_variables (struct file *file)
memcpy (cp, c, len); memcpy (cp, c, len);
cp += len; cp += len;
*cp++ = FILE_LIST_SEPARATOR; *cp++ = FILE_LIST_SEPARATOR;
if (d->changed) if (d->changed || always_make_flag)
{ {
memcpy (qp, c, len); memcpy (qp, c, len);
qp += len; qp += len;

View File

@ -544,7 +544,7 @@ set_default_suffixes (void)
char *p = default_suffixes; char *p = default_suffixes;
suffix_file->deps = (struct dep *) suffix_file->deps = (struct dep *)
multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1), multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1),
sizeof (struct dep)); sizeof (struct dep), 0);
define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0); define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0);
} }
} }

2
dep.h
View File

@ -55,7 +55,7 @@ struct nameseq
}; };
struct nameseq *multi_glob (struct nameseq *chain, unsigned int size); struct nameseq *multi_glob (struct nameseq *chain, unsigned int size, int exists_only);
#ifdef VMS #ifdef VMS
struct nameseq *parse_file_seq (); struct nameseq *parse_file_seq ();
#else #else

4
file.c
View File

@ -416,7 +416,7 @@ parse_prereqs (char *p)
{ {
struct dep *new = (struct dep *) struct dep *new = (struct dep *)
multi_glob (parse_file_seq (&p, '|', sizeof (struct dep), 1), multi_glob (parse_file_seq (&p, '|', sizeof (struct dep), 1),
sizeof (struct dep)); sizeof (struct dep), 0);
if (*p) if (*p)
{ {
@ -427,7 +427,7 @@ parse_prereqs (char *p)
++p; ++p;
ood = (struct dep *) ood = (struct dep *)
multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1), multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1),
sizeof (struct dep)); sizeof (struct dep), 0);
if (! new) if (! new)
new = ood; new = ood;

View File

@ -361,7 +361,7 @@ string_glob (char *line)
That would break examples like: That would break examples like:
$(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)). */ $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)). */
0), 0),
sizeof (struct nameseq)); sizeof (struct nameseq), 1);
if (result == 0) if (result == 0)
{ {
@ -372,26 +372,20 @@ string_glob (char *line)
idx = 0; idx = 0;
while (chain != 0) while (chain != 0)
{ {
const char *name = chain->name;
unsigned int len = strlen (name);
struct nameseq *next = chain->next; struct nameseq *next = chain->next;
unsigned int len = strlen (chain->name);
if (idx + len + 1 > length)
{
length += (len + 1) * 2;
result = xrealloc (result, length);
}
memcpy (&result[idx], chain->name, len);
idx += len;
result[idx++] = ' ';
free (chain); free (chain);
chain = next; chain = next;
/* multi_glob will pass names without globbing metacharacters
through as is, but we want only files that actually exist. */
if (file_exists_p (name))
{
if (idx + len + 1 > length)
{
length += (len + 1) * 2;
result = xrealloc (result, length);
}
memcpy (&result[idx], name, len);
idx += len;
result[idx++] = ' ';
}
} }
/* Kill the last space and terminate the string. */ /* Kill the last space and terminate the string. */

View File

@ -584,7 +584,7 @@ pattern_search (struct file *file, int archive,
parse_file_seq (&p2, parse_file_seq (&p2,
order_only ? '\0' : '|', order_only ? '\0' : '|',
sizeof (struct idep), sizeof (struct idep),
1), sizeof (struct idep)); 1), sizeof (struct idep), 0);
/* @@ It would be nice to teach parse_file_seq or /* @@ It would be nice to teach parse_file_seq or
multi_glob to add prefix. This would save us some multi_glob to add prefix. This would save us some

2
main.c
View File

@ -2193,7 +2193,7 @@ main (int argc, char **argv, char **envp)
struct nameseq *ns; struct nameseq *ns;
ns = multi_glob (parse_file_seq (&p, '\0', sizeof (struct nameseq), 1), ns = multi_glob (parse_file_seq (&p, '\0', sizeof (struct nameseq), 1),
sizeof (struct nameseq)); sizeof (struct nameseq), 0);
if (ns) if (ns)
{ {
/* .DEFAULT_GOAL should contain one target. */ /* .DEFAULT_GOAL should contain one target. */

20
read.c
View File

@ -836,7 +836,7 @@ eval (struct ebuffer *ebuf, int set_default)
files = multi_glob (parse_file_seq (&p2, '\0', files = multi_glob (parse_file_seq (&p2, '\0',
sizeof (struct nameseq), sizeof (struct nameseq),
1), 1),
sizeof (struct nameseq)); sizeof (struct nameseq), 0);
free (p); free (p);
/* Save the state of conditionals and start /* Save the state of conditionals and start
@ -1021,7 +1021,7 @@ eval (struct ebuffer *ebuf, int set_default)
filenames = multi_glob (parse_file_seq (&p2, '\0', filenames = multi_glob (parse_file_seq (&p2, '\0',
sizeof (struct nameseq), sizeof (struct nameseq),
1), 1),
sizeof (struct nameseq)); sizeof (struct nameseq), 0);
*p2 = ':'; *p2 = ':';
if (!filenames) if (!filenames)
@ -3069,10 +3069,12 @@ tilde_expand (const char *name)
SIZE is how big to construct chain elements. SIZE is how big to construct chain elements.
This is useful if we want them actually to be other structures This is useful if we want them actually to be other structures
that have room for additional info. */ that have room for additional info.
If EXISTS_ONLY is true only return existing files. */
struct nameseq * struct nameseq *
multi_glob (struct nameseq *chain, unsigned int size) multi_glob (struct nameseq *chain, unsigned int size, int exists_only)
{ {
void dir_setup_glob (glob_t *); void dir_setup_glob (glob_t *);
struct nameseq *new = 0; struct nameseq *new = 0;
@ -3125,8 +3127,16 @@ multi_glob (struct nameseq *chain, unsigned int size)
nlist = (const char **)gl.gl_pathv; nlist = (const char **)gl.gl_pathv;
break; break;
case GLOB_NOMATCH:
if (exists_only)
{
i = 0;
break;
}
/* FALLTHROUGH */
default: default:
/* Not a match or another error; keep this name. */ /* By default keep this name. */
i = 1; i = 1;
nlist = &gname; nlist = &gname;
break; break;

2
rule.c
View File

@ -378,7 +378,7 @@ install_pattern_rule (struct pspec *p, int terminal)
ptr = p->dep; ptr = p->dep;
r->deps = (struct dep *) multi_glob (parse_file_seq (&ptr, '\0', r->deps = (struct dep *) multi_glob (parse_file_seq (&ptr, '\0',
sizeof (struct dep), 1), sizeof (struct dep), 1),
sizeof (struct dep)); sizeof (struct dep), 0);
if (new_pattern_rule (r, 0)) if (new_pattern_rule (r, 0))
{ {

View File

@ -1,5 +1,13 @@
2009-06-13 Paul Smith <psmith@gnu.org>
* scripts/functions/wildcard: Test that wildcards with
non-existent glob matchers return empty.
2009-06-09 Paul Smith <psmith@gnu.org> 2009-06-09 Paul Smith <psmith@gnu.org>
* scripts/options/dash-B: Test the $? works correctly with -B.
Savannah bug #17825.
* scripts/features/patternrules: Test that dependencies of * scripts/features/patternrules: Test that dependencies of
"also_make" targets are created properly. Savannah bug #19108. "also_make" targets are created properly. Savannah bug #19108.

View File

@ -81,14 +81,11 @@ if ((-f "example.1")||(-f "example.two")||(-f "example.3")||(-f "example.for"))
&compare_output($answer,&get_logfile(1)); &compare_output($answer,&get_logfile(1));
# TEST #4: Verify that failed wildcards don't return the pattern
run_make_test(q!
all: ; @echo $(wildcard xz--y*.7)
!,
'', "\n");
1; 1;

View File

@ -70,4 +70,16 @@ all');
rmfiles('foo.x', 'blah.x'); rmfiles('foo.x', 'blah.x');
# Test that $? is set properly with -B; all prerequisites will be newer!
utouch(-10, 'x.b');
touch('x.a');
run_make_test(q!
x.a: x.b ; @echo $?
!,
'-B', "x.b\n");
unlink(qw(x.a x.b));
1; 1;