Fixed Savannah bug #12320.

This commit is contained in:
Boris Kolpackov 2005-03-15 15:31:47 +00:00
parent d584d0c1c6
commit 4923580e3a
4 changed files with 135 additions and 93 deletions

View File

@ -1,3 +1,12 @@
2005-03-15 Boris Kolpackov <boris@kolpackov.net>
* file.c (expand_deps): Factor out the second expansion and
prerequisite line parsing logic from snap_deps().
* file.c (snap_deps): Use expand_deps(). Expand and parse
prerequisites of the .SUFFIXES special target first. Fixes
Savannah bug #12320.
2005-03-10 Boris Kolpackov <boris@kolpackov.net>
* implicit.c (pattern_search): Mark an intermediate target as

86
file.c
View File

@ -414,43 +414,21 @@ set_intermediate (const void *item)
f->intermediate = 1;
}
/* For each dependency of each file, make the `struct dep' point
at the appropriate `struct file' (which may have to be created).
Also mark the files depended on by .PRECIOUS, .PHONY, .SILENT,
and various other special targets. */
void
snap_deps (void)
/* Expand and parse each dependency line. */
static void
expand_deps (struct file *f)
{
register struct file *f;
register struct file *f2;
register struct dep *d, *d1;
register struct file **file_slot_0;
register struct file **file_slot;
register struct file **file_end;
/* Perform second expansion and enter each dependency
name as a file. */
/* We must use hash_dump (), because within this loop
we might add new files to the table, possibly causing
an in-situ table expansion. */
file_slot_0 = (struct file **) hash_dump (&files, 0, 0);
file_end = file_slot_0 + files.ht_fill;
for (file_slot = file_slot_0; file_slot < file_end; file_slot++)
for (f2 = *file_slot; f2 != 0; f2 = f2->prev)
{
struct dep *new = 0;
struct dep *old = f2->deps;
unsigned int last_dep_has_cmds = f2->updating;
struct dep *old = f->deps;
unsigned int last_dep_has_cmds = f->updating;
f2->updating = 0;
f2->deps = 0;
f->updating = 0;
f->deps = 0;
/* We are going to do second expansion so initialize file
variables for the file. */
initialize_file_variables (f2, 0);
initialize_file_variables (f, 0);
for (d = old; d != 0; d = d->next)
{
@ -459,9 +437,9 @@ snap_deps (void)
char *p;
struct dep **d_ptr;
set_file_variables (f2);
set_file_variables (f);
p = variable_expand_for_file (d->name, f2);
p = variable_expand_for_file (d->name, f);
/* Parse the dependencies. */
new = (struct dep *)
@ -500,7 +478,7 @@ snap_deps (void)
d1->name = 0;
}
/* Add newly parsed deps to f2->deps. If this is the last
/* Add newly parsed deps to f->deps. If this is the last
dependency line and this target has commands then put
it in front so the last dependency line (the one with
commands) ends up being the first. This is important
@ -517,12 +495,12 @@ snap_deps (void)
for (d_ptr = &new; *d_ptr; d_ptr = &(*d_ptr)->next)
;
*d_ptr = f2->deps;
f2->deps = new;
*d_ptr = f->deps;
f->deps = new;
}
else
{
for (d_ptr = &(f2->deps); *d_ptr; d_ptr = &(*d_ptr)->next)
for (d_ptr = &(f->deps); *d_ptr; d_ptr = &(*d_ptr)->next)
;
*d_ptr = new;
@ -532,6 +510,42 @@ snap_deps (void)
}
free_ns_chain ((struct nameseq*)old);
}
/* For each dependency of each file, make the `struct dep' point
at the appropriate `struct file' (which may have to be created).
Also mark the files depended on by .PRECIOUS, .PHONY, .SILENT,
and various other special targets. */
void
snap_deps (void)
{
register struct file *f;
register struct file *f2;
register struct dep *d;
register struct file **file_slot_0;
register struct file **file_slot;
register struct file **file_end;
/* Perform second expansion and enter each dependency
name as a file. */
/* Expand .SUFFIXES first; it's dependencies are used for
$$* calculation. */
for (f = lookup_file (".SUFFIXES"); f != 0; f = f->prev)
expand_deps (f);
/* We must use hash_dump (), because within this loop
we might add new files to the table, possibly causing
an in-situ table expansion. */
file_slot_0 = (struct file **) hash_dump (&files, 0, 0);
file_end = file_slot_0 + files.ht_fill;
for (file_slot = file_slot_0; file_slot < file_end; file_slot++)
for (f = *file_slot; f != 0; f = f->prev)
{
if (strcmp (f->name, ".SUFFIXES") != 0)
expand_deps (f);
}
free (file_slot_0);

View File

@ -1,3 +1,7 @@
2005-03-15 Boris Kolpackov <boris@kolpackov.net>
* scripts/variables/automatic: Add a test for Savannah bug #12320.
2005-03-10 Boris Kolpackov <boris@kolpackov.net>
* scripts/features/patternrules: Add a test for Savannah bug #12267.

View File

@ -78,4 +78,19 @@ $answer = ".x\n$dir/x.z.x\nx\n\$@.x\n$dir.x\nx.z.x\n.y\n$dir/y.z.y\n\y\n\$@.y\n$
$answer = "$dir/biz.x\n$dir.x\nbiz.x\n";
&compare_output($answer, &get_logfile(1));
# TEST #3 -- test for Savannah bug #12320.
#
run_make_test('
.SUFFIXES: .b .src
mbr.b: mbr.src
@echo $*
mbr.src: ; @:
',
'',
'mbr
');
1;