From 58dae243526bd322ae6bec0c4394a117a5fe0171 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Mon, 13 May 2013 04:29:35 -0400 Subject: [Savannah #20501] Handle adding -r/-R to MAKEFLAGS in the makefile. If -R is set in the makefile and not the command line, then go through all the default variables and undefine them. If -r is set in the makefile and not in the command line, then remove all .SUFFIX prefixes (unless the user set it) and SUFFIX variable setting. In -p mode don't print builtins. --- variable.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index 51f936b..5415f05 100644 --- a/variable.c +++ b/variable.c @@ -280,7 +280,21 @@ define_variable_in_set (const char *name, unsigned int length, variable (makefile, command line or environment). */ static void -free_variable_name_and_value (const void *item); +free_variable_name_and_value (const void *item) +{ + struct variable *v = (struct variable *) item; + free (v->name); + free (v->value); +} + +void +free_variable_set (struct variable_set_list *list) +{ + hash_map (&list->set->table, free_variable_name_and_value); + hash_free (&list->set->table, 1); + free (list->set); + free (list); +} void undefine_variable_in_set (const char *name, unsigned int length, @@ -305,17 +319,17 @@ undefine_variable_in_set (const char *name, unsigned int length, if (! HASH_VACANT (v)) { if (env_overrides && v->origin == o_env) - /* V came from in the environment. Since it was defined - before the switches were parsed, it wasn't affected by -e. */ - v->origin = o_env_override; + /* V came from in the environment. Since it was defined + before the switches were parsed, it wasn't affected by -e. */ + v->origin = o_env_override; /* If the definition is from a stronger source than this one, don't undefine it. */ if ((int) origin >= (int) v->origin) - { + { hash_delete_at (&set->table, var_slot); free_variable_name_and_value (v); - } + } } } @@ -643,23 +657,6 @@ create_new_variable_set (void) return setlist; } -static void -free_variable_name_and_value (const void *item) -{ - struct variable *v = (struct variable *) item; - free (v->name); - free (v->value); -} - -void -free_variable_set (struct variable_set_list *list) -{ - hash_map (&list->set->table, free_variable_name_and_value); - hash_free (&list->set->table, 1); - free (list->set); - free (list); -} - /* Create a new variable set and push it on the current setlist. If we're pushing a global scope (that is, the current scope is the global scope) then we need to "push" it the other way: file variable sets point -- cgit v1.2.3