]> git.ipfire.org Git - thirdparty/make.git/commit
[SV 62324] Simplify set_file_variables by passing in the stem
authorDmitry Goncharov <dgoncharov@users.sf.net>
Sun, 24 Apr 2022 00:34:18 +0000 (20:34 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 24 Apr 2022 14:39:32 +0000 (10:39 -0400)
commit8c2aa889bbe7fbd59d2655d6dc5a26cf86dfecf7
tree15a2fdc958ad8499f920ae79d79044066b57373c
parentbb21dd4d2dea63e65146567b60dad720f395e3e3
[SV 62324] Simplify set_file_variables by passing in the stem

Previously we always used the file->stem value as our stem in
set_file_variables(); when that wasn't correct we had to temporarily
set that value while the function was called, then reset it afterward.
This led to issues (for example when we assumed the stem was a cached
string but it wasn't).

Avoid this by passing in the stem as an argument so that different
values can be provided.

Add tests to verify this.

* src/commands.c (set_file_variables): Take second parameter stem to
relieve the callers of set_file_variables() from setting/restoring
file->stem.
* src/commands.h (set_file_variables): Ditto.
(execute_file_commands): Pass file->stem to set_file_variables().
* src/file.c (expand_deps): Pass d->stem to set_file_variables() and
remove set and restore of file->stem.
* src/implicit.c (pattern_search): Pass stem to set_file_variables()
and remove set and restore of file->stem.
* tests/scripts/features/se_explicit: Add new tests.
* tests/scripts/features/se_implicit: Ditto.
* tests/scripts/features/se_statpat: Ditto.
* tests/scripts/variables/automatic: Ditto.
src/commands.c
src/commands.h
src/file.c
src/implicit.c
tests/scripts/features/se_explicit
tests/scripts/features/se_implicit
tests/scripts/features/se_statpat
tests/scripts/variables/automatic