]> git.ipfire.org Git - thirdparty/make.git/commit
[SV 64822, SV 36486] Fix appending to a pattern specific variable
authorDmitry Goncharov <dgoncharov@users.sf.net>
Sun, 4 Feb 2024 18:04:05 +0000 (13:04 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 4 Feb 2024 23:26:21 +0000 (18:26 -0500)
commit07187db947ba25e6c59b55f10660a04f8e9c5229
tree1b7b4aac9190689756bbfbe325644fcdeed08cdd
parenta493d9ab6cd2fbfa2ec83b35f52f486b56621779
[SV 64822, SV 36486] Fix appending to a pattern specific variable

Appending to a pattern specific variable produces an incorrect value
in the presence of a command line definition or an env override of
the variable.  Also, fix pattern/target-specific appending to a
variable with origin override.

* At parse time record_target_var sets the value of a pattern
  specific variable to the value defined on command line or to the
  value of the env override.
* Later, at build time, recursively_expand_for_file appends this
  value of the variable (set in record_target_var) to the command
  line value again, regardless of the origin of the variable.

This patch modifies recursively_expand_for_file to avoid appending,
unless the origin of the variable beats or equals the origin of one
of the parent definitions of this variable.

Reported by Rob <robw9739@gmail.com>,
Brian Vandenberg <phantall@gmail.com>,
Markus Oberhumer <markus@oberhumer.com>.

* NEWS: Note the change.
* src/variable.c (do_variable_definition): Avoid merging a
pattern-specific variable with the parent definition when a command
line or env override is present.
* src/expand.c (recursively_expand_for_file): Avoid appending to a
pattern-specific variable, unless the origin of this pattern-specific
variable beats or equals the origin of one of the parent definitions
of this variable.
* doc/make.texi (Override Directive): Add missing cross-reference.
* tests/scripts/variables/append: Add tests.
NEWS
doc/make.texi
src/expand.c
src/variable.c
tests/scripts/variables/append [new file with mode: 0644]