summaryrefslogtreecommitdiff
path: root/expand.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2011-05-07 20:03:49 +0000
committerPaul Smith <psmith@gnu.org>2011-05-07 20:03:49 +0000
commitf15efca8112bc2cd4f120a64fcc3aa4fa70a871e (patch)
tree2a66f3f6ff75521c152afa89ef8d35be0cd5f9d0 /expand.c
parentb664d3a91d57bbd7efdb042489d70a1473e46753 (diff)
downloadgunmake-f15efca8112bc2cd4f120a64fcc3aa4fa70a871e.tar.gz
Ensure private variables are not used when appending target-specific
variables. Fixes Savannah bug #32872.
Diffstat (limited to 'expand.c')
-rw-r--r--expand.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/expand.c b/expand.c
index 2315b06..d1404b9 100644
--- a/expand.c
+++ b/expand.c
@@ -499,7 +499,7 @@ variable_expand_for_file (const char *line, struct file *file)
static char *
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;
char *buf = 0;
@@ -511,14 +511,14 @@ variable_append (const char *name, unsigned int length,
/* Try to find the variable in this variable 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 (!v)
- return variable_append (name, length, set->next);
+ /* If there isn't one, or this one is private, try the set above us. */
+ if (!v || (!local && v->private_var))
+ return variable_append (name, length, set->next, 0);
/* If this variable type is append, first get any upper values.
If not, initialize the buffer. */
if (v->append)
- buf = variable_append (name, length, set->next);
+ buf = variable_append (name, length, set->next, 0);
else
buf = initialize_variable_output ();
@@ -548,7 +548,8 @@ allocated_variable_append (const struct variable *v)
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);
val = variable_buffer;