]> git.ipfire.org Git - thirdparty/make.git/commit
[SV 64803] Set origin for unmodified variables after -e
authorDmitry Goncharov <dgoncharov@users.sf.net>
Sun, 4 Feb 2024 16:16:40 +0000 (11:16 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 4 Feb 2024 16:34:49 +0000 (11:34 -0500)
commita382ac6cd17eedf535407d29bcfc3cef04bbc3bc
tree9b4a582ae300bf902db65207ec6773c6918275b4
parent63b602e74f8e2235191d7dee4dd05f82b1869fdb
[SV 64803] Set origin for unmodified variables after -e

Ensure the origin of all variables inherited from the environment is
"environment override" if -e is given.  Previously only variables
that were set in the makefile had this origin.

PDS: Most of these changes are from Dmitry but I slightly modified
the algorithm: instead of rearranging the way in which MAKEFLAGS is
parsed we reset the env_override value to the default before we
re-parse MAKEFLAGS, then we set the origin of all env vars to the
correct value based on the new setting.

* NEWS: Mention the change for backward-compatibility.
* src/main.c (main): Ensure MAKEFLAGS is always marked special.
(reset_makeflags): Set env_overrides back to default before parsing
MAKEFLAGS.
(decode_switches): Call reset_env_override() to check for changes.
* src/variable.h (reset_env_override): Declare a new function.
* src/variable.c (reset_env_override): Go through all env variables
and ensure the origin is correct based on env_overrides.
(set_env_override): Helper function for the hash.
* tests/scripts/functions/foreach: Fix tests.
* tests/scripts/functions/let: Ditto.
* tests/scripts/functions/origin: Ditto.
* tests/scripts/options/dash-e: Add tests.
NEWS
src/main.c
src/variable.c
src/variable.h
tests/scripts/functions/foreach
tests/scripts/functions/let
tests/scripts/functions/origin
tests/scripts/options/dash-e