Ensure private variables are not used when appending target-specific

variables.  Fixes Savannah bug #32872.
This commit is contained in:
Paul Smith 2011-05-07 20:03:49 +00:00
parent b664d3a91d
commit f15efca811
4 changed files with 27 additions and 6 deletions

View File

@ -1,5 +1,10 @@
2011-05-07 Paul Smith <psmith@gnu.org> 2011-05-07 Paul Smith <psmith@gnu.org>
* expand.c (variable_append): Add a LOCAL argument to track
whether this is the first invocation or not. If it's not and
private_var is set, then skip this variable and try the next one.
Fixes Savannah bug #32872.
* read.c (parse_file_seq): Ensure existence checks use glob(). * read.c (parse_file_seq): Ensure existence checks use glob().
2011-05-07 Eli Zaretskii <eliz@gnu.org> 2011-05-07 Eli Zaretskii <eliz@gnu.org>

View File

@ -499,7 +499,7 @@ variable_expand_for_file (const char *line, struct file *file)
static char * static char *
variable_append (const char *name, unsigned int length, variable_append (const char *name, unsigned int length,
const struct variable_set_list *set) const struct variable_set_list *set, int local)
{ {
const struct variable *v; const struct variable *v;
char *buf = 0; char *buf = 0;
@ -511,14 +511,14 @@ variable_append (const char *name, unsigned int length,
/* Try to find the variable in this variable set. */ /* Try to find the variable in this variable set. */
v = lookup_variable_in_set (name, length, set->set); v = lookup_variable_in_set (name, length, set->set);
/* If there isn't one, look to see if there's one in a set above us. */ /* If there isn't one, or this one is private, try the set above us. */
if (!v) if (!v || (!local && v->private_var))
return variable_append (name, length, set->next); return variable_append (name, length, set->next, 0);
/* If this variable type is append, first get any upper values. /* If this variable type is append, first get any upper values.
If not, initialize the buffer. */ If not, initialize the buffer. */
if (v->append) if (v->append)
buf = variable_append (name, length, set->next); buf = variable_append (name, length, set->next, 0);
else else
buf = initialize_variable_output (); buf = initialize_variable_output ();
@ -548,7 +548,8 @@ allocated_variable_append (const struct variable *v)
variable_buffer = 0; variable_buffer = 0;
val = variable_append (v->name, strlen (v->name), current_variable_set_list); val = variable_append (v->name, strlen (v->name),
current_variable_set_list, 1);
variable_buffer_output (val, "", 1); variable_buffer_output (val, "", 1);
val = variable_buffer; val = variable_buffer;

View File

@ -1,5 +1,8 @@
2011-05-07 Paul Smith <psmith@gnu.org> 2011-05-07 Paul Smith <psmith@gnu.org>
* scripts/variables/private: Ensure we skip private variables when
appending. Test for Savannah bug #32872.
* scripts/functions/wildcard: Verify wildcard used to test for * scripts/functions/wildcard: Verify wildcard used to test for
file existence/non-existence. file existence/non-existence.

View File

@ -75,4 +75,16 @@ a b: ; @echo $@=$(private)
', ',
'', "b=a\na=a\n"); '', "b=a\na=a\n");
# 9: make sure private suppresses inheritence
run_make_test(q!
DEFS = FOO
all: bar1
bar1: private DEFS += 1
bar3: private DEFS += 3
bar1: bar2
bar2: bar3
bar1 bar2 bar3: ; @echo '$@: $(DEFS)'
!,
'', "bar3: FOO 3\nbar2: FOO\nbar1: FOO 1\n");
1; 1;