- undefine-variables.patch: Force recomputing .VARIABLES when a variable was made undefined (bsc#934131) OBS-URL: https://build.opensuse.org/request/show/331637 OBS-URL: https://build.opensuse.org/package/show/Base:System/make?expand=0&rev=47
81 lines
2.8 KiB
Diff
81 lines
2.8 KiB
Diff
Subject: [PATCH] [SV 45728] Force recomputing .VARIABLES when a variable was made undefined
|
||
|
||
* variable.c (last_var_count): Move to file level.
|
||
(undefine_variable_in_set): Clear last_var_count when the variable
|
||
was removed from global_variable_set.
|
||
* tests/scripts/variables/undefine: Add test case.
|
||
---
|
||
tests/scripts/variables/undefine | 14 ++++++++++++++
|
||
variable.c | 14 ++++++++------
|
||
2 files changed, 22 insertions(+), 6 deletions(-)
|
||
|
||
Index: make-4.1/tests/scripts/variables/undefine
|
||
===================================================================
|
||
--- make-4.1.orig/tests/scripts/variables/undefine
|
||
+++ make-4.1/tests/scripts/variables/undefine
|
||
@@ -70,4 +70,18 @@ all: ;@echo ouch
|
||
',
|
||
'', "#MAKEFILE#:3: *** empty variable name. Stop.\n", 512);
|
||
|
||
+
|
||
+# TEST 4: interaction between undefine and $(.VARIABLES)
|
||
+
|
||
+run_make_test('
|
||
+var_a := a
|
||
+var_b := b
|
||
+$(foreach v, $(filter var_%, $(.VARIABLES)), $(eval undefine $v))
|
||
+var_c := c
|
||
+var_d := d
|
||
+$(info $(filter var_%, $(.VARIABLES)))
|
||
+all: ;@:
|
||
+',
|
||
+'', "var_d var_c");
|
||
+
|
||
1;
|
||
Index: make-4.1/variable.c
|
||
===================================================================
|
||
--- make-4.1.orig/variable.c
|
||
+++ make-4.1/variable.c
|
||
@@ -172,6 +172,7 @@ static struct variable_set global_variab
|
||
static struct variable_set_list global_setlist
|
||
= { 0, &global_variable_set, 0 };
|
||
struct variable_set_list *current_variable_set_list = &global_setlist;
|
||
+static unsigned long last_var_count = 0;
|
||
|
||
/* Implement variables. */
|
||
|
||
@@ -328,6 +329,10 @@ undefine_variable_in_set (const char *na
|
||
{
|
||
hash_delete_at (&set->table, var_slot);
|
||
free_variable_name_and_value (v);
|
||
+ /* Force rebuilding of .VARIABLES when the global variable set
|
||
+ has changed. */
|
||
+ if (set == &global_variable_set)
|
||
+ last_var_count = 0;
|
||
}
|
||
}
|
||
}
|
||
@@ -345,9 +350,6 @@ undefine_variable_in_set (const char *na
|
||
static struct variable *
|
||
lookup_special_var (struct variable *var)
|
||
{
|
||
- static unsigned long last_var_count = 0;
|
||
-
|
||
-
|
||
/* This one actually turns out to be very hard, due to the way the parser
|
||
records targets. The way it works is that target information is collected
|
||
internally until make knows the target is completely specified. It unitl
|
||
@@ -410,9 +412,9 @@ lookup_special_var (struct variable *var
|
||
}
|
||
*(p-1) = '\0';
|
||
|
||
- /* Remember how many variables are in our current count. Since we never
|
||
- remove variables from the list, this is a reliable way to know whether
|
||
- the list is up to date or needs to be recomputed. */
|
||
+ /* Remember how many variables are in our current count. This is a
|
||
+ reliable way to know whether the list is up to date or needs to
|
||
+ be recomputed. */
|
||
|
||
last_var_count = global_variable_set.table.ht_fill;
|
||
}
|