]> git.ipfire.org Git - thirdparty/make.git/log
thirdparty/make.git
3 years ago* tests/scripts/features/implicit_search: [SV 48643] Cleanups.
Paul Smith [Thu, 20 Jan 2022 00:45:12 +0000 (19:45 -0500)] 
* tests/scripts/features/implicit_search: [SV 48643] Cleanups.

3 years ago* src/implicit.c (pattern_search): Use const ptrs when possible.
Paul Smith [Wed, 19 Jan 2022 22:43:57 +0000 (17:43 -0500)] 
* src/implicit.c (pattern_search): Use const ptrs when possible.

Change suggested by Joe Filion <joefilion4@gmail.com>

3 years ago* src/job.c (load_too_high): Re-enable Linux /proc/loadavg checks.
Paul Smith [Wed, 19 Jan 2022 18:44:22 +0000 (13:44 -0500)] 
* src/job.c (load_too_high): Re-enable Linux /proc/loadavg checks.

Further experimentation shows that my previous thinking that there
was a problem using this was woefully mistaken.  The value generated
by the kernel shows runn*ABLE* processes not runn*ING* processes.
* NEWS: Announce the change.

3 years ago* doc/make.texi (Using One Shell): Correct example to use $<.
Paul Smith [Tue, 18 Jan 2022 21:06:24 +0000 (16:06 -0500)] 
* doc/make.texi (Using One Shell): Correct example to use $<.

3 years ago* src/function.c (parse_textint): Handle ints without 0 properly.
Jouke Witteveen [Tue, 18 Jan 2022 00:11:59 +0000 (19:11 -0500)] 
* src/function.c (parse_textint): Handle ints without 0 properly.

* tests/scripts/functions/intcmp: Add tests for values without 0.

3 years ago[SV 61226] Revert changes to detect missing included files
Paul Smith [Mon, 17 Jan 2022 23:23:42 +0000 (18:23 -0500)] 
[SV 61226] Revert changes to detect missing included files

The fix for SV 60595 introduced a backward-incompatibility: rules that
purported to rebuild included files, but didn't actually do so, were
treated as errors whereas before they were ignored.  This breaks a
common idiom in makefiles where an empty recipe is created for an
included makefile so make doesn't complain if it doesn't exist.

Unfortunately this means make cannot diagnose some types of errors.

Extra tests supplied by Dmitry Goncharov <dgoncharov@users.sf.net>.

* doc/make.texi (Including Other Makefiles): Clarify this behavior.
* src/main.c (main): Don't run the new check-for-errors behavior.
* tests/scripts/features/reinvoke: Reset tests of the "old" behavior
and add new tests for this situation.

3 years agoEnsure that loaded functions increment the command count
Paul Smith [Mon, 17 Jan 2022 22:15:00 +0000 (17:15 -0500)] 
Ensure that loaded functions increment the command count

Since we don't know what a loaded function (via Guile or load) may
do, increment the command count just in case.

* src/function.c (struct file_table_entry): New adds_command bool.
(FT_ENTRY): Initialize it to 0 for built-in functions.
(expand_builtin_function): If adds_command, increment the count.
(define_new_function): Set adds_command for loaded functions.

3 years ago* src/read.c (tilde_expand): Put back '/' before returning.
Paul Smith [Sat, 8 Jan 2022 22:31:56 +0000 (17:31 -0500)] 
* src/read.c (tilde_expand): Put back '/' before returning.

Joe Filion <joefilion4@gmail.com> noted that the string is modified,
and Henrik Carlqvist <hc94@poolhem.se> noticed that it wasn't put
back in all cases.

3 years ago* tests/scripts/targets/INTERMEDIATE: Rewrite for new test method
Paul Smith [Wed, 29 Dec 2021 20:27:04 +0000 (15:27 -0500)] 
* tests/scripts/targets/INTERMEDIATE: Rewrite for new test method

3 years agoDo not force targets to be SECONDARY
Paul Smith [Wed, 29 Dec 2021 19:44:46 +0000 (14:44 -0500)] 
Do not force targets to be SECONDARY

In SV 43677 we forced targets to be secondary if we found an
intermediate file that was listed as a prerequisite of another
target.  This overrides .INTERMEDIATE settings, so doesn't work.
Now that we have an is_explicit flag in targets, use that instead.

* src/implicit.c (pattern_search): Remove setting of secondary.
Preserve the value of the is_explicit flag when creating a new
file target, and consider it when setting the intermediate flag.
* tests/scripts/features/patternrules: Add a test w/out INTERMEDIATE
* tests/scripts/targets/INTERMEDIATE: Add a test with INTERMEDIATE

3 years ago[SV 48643] Preserve target-specific variables on intermediate files
Dmitry Goncharov [Wed, 29 Dec 2021 19:26:40 +0000 (14:26 -0500)] 
[SV 48643] Preserve target-specific variables on intermediate files

Target-specific variables used to define the target as "ought to
exist" so they could never be intermediate.  Now they can be, so
merge the target-specific variables from the intermediate target
so they're not lost.

* src/implicit.c (pattern_search): Use merge_variable_set_lists
to merge target-specific variables.
* tests/scripts/features/implicit_search: Add tests of target-
specific variable assignments and implicit rules.

3 years ago* README.template: Clean up patch submission information
Paul Smith [Mon, 20 Dec 2021 05:31:05 +0000 (00:31 -0500)] 
* README.template: Clean up patch submission information

3 years ago* src/read.c (find_percent_cached): [SV 60798] Silence GCC11 warnings
Jouke Witteveen [Sun, 19 Dec 2021 21:19:02 +0000 (16:19 -0500)] 
* src/read.c (find_percent_cached): [SV 60798] Silence GCC11 warnings

3 years ago[SV 60798] Silence bogus GCC10 and GCC11 warnings
Jouke Witteveen [Sun, 19 Dec 2021 21:09:07 +0000 (16:09 -0500)] 
[SV 60798] Silence bogus GCC10 and GCC11 warnings

* src/main.c (main): Use a separate variable to track final character.
* src/read.c (eval): Track the semicolon position not one beyond it.
* src/variable.c (do_variable_definition): Include a default switch
case to ease the work of the exhaustiveness prover.

3 years agoUpdate documentation with instructions for patch submission
Paul Smith [Sat, 18 Dec 2021 23:25:38 +0000 (18:25 -0500)] 
Update documentation with instructions for patch submission

* README.template: Add notes on how to submit patches.
* README.git: Point to the README.
* doc/make.texi: Ditto.

3 years agoChange HTTP URLs to use HTTPS instead
Paul Smith [Sat, 18 Dec 2021 23:23:16 +0000 (18:23 -0500)] 
Change HTTP URLs to use HTTPS instead

Also remove unnecessary tests/COPYING file.

* README.template: Change http: to https:
* README.git: Ditto
* doc/make.texi: Ditto
* doc/make.1: Ditto
* src/main.c: Ditto
* maintMakefile: Remove invalid URL

3 years ago* src/makeint.h: Compute INTSTR_LENGTH based on size of intmax_t
Paul Smith [Sun, 19 Dec 2021 19:48:26 +0000 (14:48 -0500)] 
* src/makeint.h: Compute INTSTR_LENGTH based on size of intmax_t

Math suggested by Edward Welbourne <edward.welbourne@qt.io>

3 years agoRemove arbitrary limits on intcmp integers
Paul Eggert [Sun, 19 Dec 2021 19:48:14 +0000 (14:48 -0500)] 
Remove arbitrary limits on intcmp integers

We don't need to parse strings into C integer values to compare them.

* src/function.c (parse_textint): Find boundaries of a numeric string.
(func_intcmp): Use parse_textint() to compare integers textually.
* tests/scripts/functions/intcmp: Test with extra-large numbers.

3 years agoUse a well-known error string for out-of-bound function arguments
Paul Smith [Sat, 18 Dec 2021 23:11:30 +0000 (18:11 -0500)] 
Use a well-known error string for out-of-bound function arguments

* src/function.c (parse_numeric): Check for empty value and error.
If we find ERANGE just print our own error, not strerror.
(func_word): Use a generic "not good" error message.
(func_wordlist): Ditto
(func_intcmp): Ditto
* tests/run_make_tests.pl: Remove code to find strerror(ERANGE)
* tests/scrips/functions/intcmp: Update the error message.
* tests/scrips/functions/word: Ditto.

3 years ago* doc/make.text (Wildcards): Document that glob results are sorted.
Paul Smith [Sun, 5 Dec 2021 20:16:26 +0000 (15:16 -0500)] 
* doc/make.text (Wildcards): Document that glob results are sorted.

3 years ago[SV 61621] Don't use POSIX_SPAWN_RESETIDS with posix_spawn()
Paul Smith [Sun, 5 Dec 2021 19:22:43 +0000 (14:22 -0500)] 
[SV 61621] Don't use POSIX_SPAWN_RESETIDS with posix_spawn()

When make is invoked in a environment where the user namespace is
restricted, such as under unshare(1) (on GNU/Linux), it won't be able
to find its real UID so the effective UID can't be set to it and
posix_spawn() will fail with EINVAL.

It's not less safe to run recipe jobs using the same UID values that
make was invoked with, so don't worry about this flag.

* src/job.c (child_execute_job): Don't set POSIX_SPAWN_RESETIDS flag.

3 years ago* .gitignore: Ignore patch files.
Paul Smith [Sun, 5 Dec 2021 19:21:47 +0000 (14:21 -0500)] 
* .gitignore: Ignore patch files.

3 years ago* src/commands.c (fatal_error_signal) [W32]: Use %lu for DWORD.
U2FsdGVkX1 [Sun, 28 Nov 2021 20:25:45 +0000 (15:25 -0500)] 
* src/commands.c (fatal_error_signal) [W32]: Use %lu for DWORD.

* src/function.c (windows32_openpipe) [W32]: Ditto.

Copyright-paperwork-exempt: yes

3 years ago* NEWS: Update with author details
Paul Smith [Sun, 28 Nov 2021 19:34:05 +0000 (14:34 -0500)] 
* NEWS: Update with author details

3 years agoSpecial-case Windows error results
Paul Smith [Sun, 28 Nov 2021 19:17:55 +0000 (14:17 -0500)] 
Special-case Windows error results

* tests/scripts/features/errors: Match Windows-specific errors.
* tests/scripts/features/targetvars: Match Windows-specific errors.
* tests/scripts/misc/general4: Match Windows-specific errors.

3 years agoConvert word, wordlist, and intcmp functions to use long long
Paul Smith [Sun, 28 Nov 2021 14:50:10 +0000 (09:50 -0500)] 
Convert word, wordlist, and intcmp functions to use long long

Modify make functions that parse integer values to use long long
values instead of long: on Windows long is the same as int (4 bytes)
and we don't want behavior to differ between different platforms.

* bootstrap.conf: Change strtol module to strtoll module.
* src/function.c (parse_numeric): Use strtoll() and return long long.
(func_word): Use long long.
(func_wordlist): Use long long.  Verify second argument is >= 0.
(func_intcmp): Use long long.
* src/config.ami.template: Don't define HAVE_STRTOLL.
* src/config-vms.template: Define HAVE_STRTOLL.
* src/config.W32.template: Define HAVE_STRTOLL.
* tests/run_make_tests.pl: Set $ERR_out_of_range to the proper string.
* tests/scripts/functions/word: Rework to use the new style and avoid
TAB characters.  Verify trailing whitespace is ignored.  Add a test
for a negative second argument to wordlist.  Add tests for max signed
integer values.  Use $ERR_out_of_range for the error string.
* tests/scripts/functions/intcmp: Add tests for min and max signed
integer values.  Use $ERR_out_of_range for the error string.

3 years agoIntroduce $(intcmp ...) for numerical comparison
Jouke Witteveen [Fri, 16 Jul 2021 12:04:41 +0000 (14:04 +0200)] 
Introduce $(intcmp ...) for numerical comparison

Numbers can come from $(words ...), automatic variables such as
$(MAKELEVEL), from environment variables, or from shell output such as
through $(shell expr ...).  The $(intcmp ...) function allows
conditional evaluation controlled by numerical variables.

* NEWS: Announce this feature.
* doc/make.texi (Functions for Conditionals): Document 'intcmp'.
* src/function.c (func_intcmp): Create the 'intcmp' built-in function.
* tests/scripts/functions/intcmp: Test the 'intcmp' built-in function.

3 years agoUse strtol() instead of atoi()
Jouke Witteveen [Fri, 16 Jul 2021 12:04:33 +0000 (14:04 +0200)] 
Use strtol() instead of atoi()

strtol() is part of C89 and a fallback is provided by gnulib.

* src/function.c (func_word, func_wordlist): Change atoi to strtol.
* test/scripts/functions/word: Add out-of-range verification testing.

3 years ago* src/makeint.h: Removed unused atol declaration
Jouke Witteveen [Fri, 16 Jul 2021 12:04:22 +0000 (14:04 +0200)] 
* src/makeint.h: Removed unused atol declaration

3 years ago* src/implicit.c (pattern_search): Fix text for easier translation.
Paul Smith [Sat, 27 Nov 2021 20:08:56 +0000 (15:08 -0500)] 
* src/implicit.c (pattern_search): Fix text for easier translation.

3 years ago[SV 48643] Update the implicit rule search docs
Paul Smith [Sun, 28 Nov 2021 02:57:37 +0000 (21:57 -0500)] 
[SV 48643] Update the implicit rule search docs

* NEWS: Announce the change.
* doc/make.texi (Implicit Rule Search): Update the definition of
"ought to exist" and add the extra step for compatibility mode.

3 years ago[SV 48643] Enhance "ought to exist" definition
Dmitry Goncharov [Sun, 28 Nov 2021 03:00:05 +0000 (22:00 -0500)] 
[SV 48643] Enhance "ought to exist" definition

The traditional definition of "ought to exist" in the user's manual can
lead to make choosing a poor series of chained implicit rules.  Modify
that rule so that we first attempt to resolve implicit rules by
considering targets which are only (a) targets or (b) explicit
prerequisites of the current target.

For backward-compatibility, if we don't find a solution using that
algorithm use the previous definition where "ought to exist" means
"mentioned as a prerequisite of any target".

* src/implicit.c (pattern_search): An extra argument controls whether
to perform the backward-compatible rule search or not.  If a prereq is
a target, or if it's a prerequisite of THIS target, then choose it.
If we get to the end and haven't found a match, but we have found a
potential compatibility rule, then retry with compat rules enabled.
If we're searching with compat rules enabled and we find a file
mentioned as a prerequisite of ANY target, then use it.
* tests/features/implicit_search: Provide a large suite of tests for
different steps of implicit rule search.

3 years agotests: Enhance output to contain filename/line number info
Paul Smith [Sat, 27 Nov 2021 19:03:44 +0000 (14:03 -0500)] 
tests: Enhance output to contain filename/line number info

* tests/scripts/options/dash-I: Use string comparison operator.
* tests/test_driver.pl (cmd2str): New method to convert a
command line to a string with proper quoting.
* tests/run_make_tests.pl (create_command): Call cmd2str() to format
the command.  Add the filename/line number to the output.

3 years ago[SV 61042] Enhance logging of implicit rule search
Dmitry Goncharov [Sun, 17 Oct 2021 22:03:04 +0000 (18:03 -0400)] 
[SV 61042] Enhance logging of implicit rule search

Logging of implicit rule search gives limited information as to why a
given implicit rule was rejected, and if no implicit rule is found we
get the confusing "No rule to make target" result when the real issue
is that some prerequisite of some implicit rule could not be built.

Enhance logging around implicit rule search as follows:
1. The messages which refer to a rule print a description (the targets
   and prerequisites) of the rule.
2. A new message tells when a rule is rejected, along with the reason.
3. The 'Looking for an implicit rule...' message is printed for every
   prerequisite, not just the top-level target.
4. "Trying harder" message is printed, when intermediate prerequisites
   are going to be searched.
5. The 'No rule found...' and 'Found implicit rule...' messages are
   printed for every prerequisite, not just the top-level target.
6. "Ought to exist...", "Found..." or "Not found..." message is
   printed for each prerequisite.

* src/rule.h (struct rule): Remember the definition of the rule.
* src/rule.c (get_rule_defn): Compute the definition of a rule.
(install_pattern_rule): Initialize the definition to empty.
(create_pattern_rule): Ditto.
(freerule): Free the definition.
(print_rule): Use the definition when printing rules.
* src/remake.c (update_file_1): Push debug output down into
try_implicit_rule().
* src/implicit.c (try_implicit_rule): Add debugging
(pattern_search): Show the rule definition in various debug output.
Add new debug messages for implicit rule search.

Additional changes by Paul Smith <psmith@gnu.org>:

Since we usually don't need the rule definition, defer computing it
until we do.

* bootstrap.conf: Include the mempcpy Gnulib module.
* src/makeint.h (mempcpy): Declare mempcpy if not available.
* src/misc.c (mempcpy): Define mempcpy if not available.
* src/config.h-vms.template: Don't set HAVE_MEMPCPY.
* src/config.h.W32.template: Ditto.
* src/rule.h (get_rule_defn): Return the definition of a rule.
* src/rule.c (get_rule_defn): If we don't have a definition compute
it; either way return it.
* src/implicit.c (pattern_search): Rework the handling of explicit
prerequisites to pattern rules to be more clear.  There is no change
in behavior.

3 years ago* doc/make.texi (Special Targets): [SV 61122] Add .SECONDARY example
Dmitry Goncharov [Sat, 2 Oct 2021 19:19:15 +0000 (15:19 -0400)] 
* doc/make.texi (Special Targets): [SV 61122] Add .SECONDARY example

3 years ago* README.git: Update C version prerequisite
Paul Smith [Sun, 17 Oct 2021 23:07:36 +0000 (19:07 -0400)] 
* README.git: Update C version prerequisite

3 years agoAdd support for the POSIX :::= assignment operator.
Paul Smith [Sat, 18 Sep 2021 22:53:38 +0000 (18:53 -0400)] 
Add support for the POSIX :::= assignment operator.

POSIX Issue 8 will require a new assignment operator, :::=.
This operator behaves similarly to the BSD make := operator: the
right-hand side is expanded immediately, but then the value is
re-escaped (all '$' are converted to '$$') and the resulting variable
is considered a recursive variable: the value is re-expanded on use.

* src/variable.h (enum variable_flavor): Add f_expand flavor.
* src/variable.c (do_variable_definition): When defining f_expand,
post-process the result to re-escape '$' characters.
Remove default: to the compiler warns about un-handled enum values.
Set recursive values for both f_recursive and f_expand.
(parse_variable_definition): Rewrite this method.
The previous version was annoying to extend to ':::='.
(print_variable): Remove default: so the compiler warns us about
un-handled enum values.
* src/function.c (func_origin): Remove default: so the compiler warns
us about un-handled enum values.
* doc/make.texi: Add documentation for :::=.
* tests/scripts/variables/define: Add a test for define :::=.
* tests/scripts/variables/flavors: Add tests for :::=.
* tests/scripts/variables/negative: Add tests for :::=.

3 years agoClean up more Windows warnings.
Paul Smith [Tue, 7 Sep 2021 05:02:25 +0000 (01:02 -0400)] 
Clean up more Windows warnings.

* src/config.h.W32.template: Re-enable warnings that we don't violate.
Add a new disabled warning: 4130 (logical operation on address of
string constant).
* src/w32/compat/posixfcn.c: Make makeint.h the first included header.
* src/w32/subproc/sub_proc.c: Ditto.  It includes config.h already.

3 years ago[SV 60435] Ensure intermediate grouped files are removed
Dmitry Goncharov [Tue, 7 Sep 2021 04:08:27 +0000 (00:08 -0400)] 
[SV 60435] Ensure intermediate grouped files are removed

If multiple intermediate files are built together be sure all of them
are removed after make is finished.  Continue to ensure that targets
that exist before make starts are not removed even if they appear to be
intermediate.

Add a number of tests to pattern rules to verify this behavior.

* src/filedef.h (struct file): Add a new is_explicit bitfield.
* src/file.c (rehash_file): Merge the is_explicit bit.
(enter_prereqs): Set is_explicit if the file is explicitly mentioned.
* src/implicit.c (pattern_search): Set intermediate on the file if it's
not explicit.
(record_files): Set is_explicit if a file is mentioned as a target.
* src/remake.c (update_file_1): Set secondary on files that already
exist so they won't be removed.
* tests/scripts/features/double_colon: Add a test for double-colon
pattern rules.
* tests/scripts/features/patternrules: Update KGO for tests where more
files are removed.
Add new tests to verify handling removal of intermediate files in the
context of grouped pattern targets.

3 years ago* src/default.c (default_variables): Use CPP in PREPROCESS.S.
Paul Smith [Tue, 7 Sep 2021 00:42:34 +0000 (20:42 -0400)] 
* src/default.c (default_variables): Use CPP in PREPROCESS.S.

3 years ago* src/main.c (decode_debug_flags): [SV 607777] Preserve -d options
Dmitry Goncharov [Tue, 7 Sep 2021 00:36:15 +0000 (20:36 -0400)] 
* src/main.c (decode_debug_flags): [SV 607777] Preserve -d options

* tests/scripts/options/dash-d: Test that -d --trace keeps -d.

3 years ago[SV 57778] Don't ignore included makefiles that can't be read
Dmitry Goncharov [Tue, 7 Sep 2021 00:20:28 +0000 (20:20 -0400)] 
[SV 57778] Don't ignore included makefiles that can't be read

If we find an included makefile but it's not readable, stop
immediately with an error rather than continuing to look in other
directories.

* src/read.c (eval_makefile): Only keep searching if the fopen error
is ENOENT, else stop and fail.
* tests/scripts/features/include: Add tests to verify this behavior.

3 years ago[SV 60795] Don't remake phony included makefiles and show errors
Paul Smith [Mon, 6 Sep 2021 21:47:04 +0000 (17:47 -0400)] 
[SV 60795] Don't remake phony included makefiles and show errors

Change the handling of included makefiles which are phony targets to
be similar to double-colon rules with no prerequisites: simply don't
build them at all during the remake a makefile phase.

Ensure that any included makefile which is needed but not built
results in an error.

Update the documentation to make this clear.
Add tests to verify this behavior.

* doc/make.texi (Remaking Makefiles): Clarify double-colon exception.
Document that phony targets are handled the same way.
(Phony Targets): Ditto.
* src/main.c (main): Check for phony targets when skipping goals.
Rather than throwing out skipped but failed goals keep them
separately then report them as errors.
* src/read.c (eval): Set the file location on included makefiles even
when there's no error.
* tests/scripts/features/include: Add tests for handling included
makefiles with both phony and double-colon rules to rebuild them.

3 years ago* doc/make.texi (Environment): [SV 60841] Clarify variable exporting.
Paul Smith [Mon, 6 Sep 2021 14:57:43 +0000 (10:57 -0400)] 
* doc/make.texi (Environment): [SV 60841] Clarify variable exporting.

3 years ago* doc/make.texi (Chained Rules): [SV 60904] Clarify intermediate files.
Paul Smith [Mon, 6 Sep 2021 14:46:52 +0000 (10:46 -0400)] 
* doc/make.texi (Chained Rules): [SV 60904] Clarify intermediate files.

3 years agoRemove UBSAN issues discovered via fuzzing tests.
Paul Smith [Mon, 6 Sep 2021 04:14:57 +0000 (00:14 -0400)] 
Remove UBSAN issues discovered via fuzzing tests.

The arithmetic conversions in C say that if a binary operator has an
unsigned and signed type as operands and the unsigned type has a greater
rank then the signed value is converted to unsigned.  This is bad if the
signed value is negative.

There are a few places in the code which have this situation; convert
the signed value to positive and add instead of subtracting.

Reported by He Jingxuan <jingxuan.he@inf.ethz.ch>

* src/read.c (find_map_unquote): Use a positive int in memmove().
(find_char_unquote): Ditto.
(find_percent_cached): Ditto.

3 years ago* doc/make.texi (Prerequisite Types): [SV 61069] Mention PHONY prereqs
Paul Smith [Mon, 6 Sep 2021 03:28:03 +0000 (23:28 -0400)] 
* doc/make.texi (Prerequisite Types): [SV 61069] Mention PHONY prereqs

3 years ago* doc/make.1: Clean up man page text.
Paul Smith [Mon, 6 Sep 2021 03:17:26 +0000 (23:17 -0400)] 
* doc/make.1: Clean up man page text.

3 years ago* README.git: Add a section on ways to test.
Paul Smith [Mon, 6 Sep 2021 02:28:36 +0000 (22:28 -0400)] 
* README.git: Add a section on ways to test.

3 years ago* src/main.c (decode_switches): Fix memory leak.
Paul Smith [Mon, 6 Sep 2021 02:28:10 +0000 (22:28 -0400)] 
* src/main.c (decode_switches): Fix memory leak.

3 years agoClean up a few Windows build warnings (not all!)
Paul Smith [Mon, 6 Sep 2021 01:07:14 +0000 (21:07 -0400)] 
Clean up a few Windows build warnings (not all!)

* build_w32.bat: Quote uses of %VSWHERE% so it can contain spaces
* src/hash.c (hash_init): Avoid use of an undefined struct.
(hash_rehash): Ditto.
* src/vpath.c (construct_vpath_list): Cast explicitly to void*.

3 years ago[SV 45211] Parse MAKEFLAGS immediately when it's reset
Paul Smith [Sun, 5 Sep 2021 21:11:44 +0000 (17:11 -0400)] 
[SV 45211] Parse MAKEFLAGS immediately when it's reset

When MAKEFLAGS is set in a makefile, reparse it immediately rather
than waiting until after all makefiles have been read and parsed.
This change doesn't actually fix the SV bug referenced because, even
though we do reparse MAKEFLAGS, we don't handle the -r or -R options
immediately.  Doing this will require more effort.

* NEWS: Announce the change.
* src/makeint.h: Publish reset_switches() and decode_env_switches()
from main.c
* src/main.c (main): Don't call construct_include_path(); it will be
invoked decode_switches().
Preserve the old values of builtin_rules, builtin_variables, and
job_slots before we read makefiles since they can be changed now.
(reset_switches): Publish (remove static).  Set the initial value of
the stringlist list to NULL.
(decode_switches): Call construct_include_path() after decoding.
(decode_env_switches): Publish (remove static).
(define_makeflags): Set the MAKEFLAGS variable for special handling.
* src/read.c (eval_makefile): Check for empty include_directories.
(construct_include_path): Clear any old value of .INCLUDE_DIRS before
appending new values.  Free the previous include_directories.
* src/variable.c (lookup_special_var): When MAKEFLAGS is set, first
reset the switches then re-parse the variable.
* tests/run_make_tests.pl: Memo-ize some default variable values.
* tests/scripts/options/dash-r: Create tests for setting -r and -R.
* tests/scripts/variables/MAKEFLAGS: Test that resetting -I from
within the makefile takes effect immediately.

3 years ago* make-gdb.py: Add pretty-printers and clean up.
Paul Smith [Sun, 25 Jul 2021 21:19:09 +0000 (17:19 -0400)] 
* make-gdb.py: Add pretty-printers and clean up.

Create a pretty-printer for next-pointer lists.
Create a pretty-printer for stringlists.
Change showargv from a function to a command (easier to use).

Clean up some Python PEP violations.  Add support for testing null
pointers and caching gdb.Types.

3 years ago[SV 60595] Restart whenever any makefile is rebuilt
Paul Smith [Mon, 31 May 2021 18:37:09 +0000 (14:37 -0400)] 
[SV 60595] Restart whenever any makefile is rebuilt

Previously if an included makefile was rebuilt as a prerequisite of
another included makefile which didn't need to be rebuilt, make would
not realize that it needed to re-exec itself.

Ensure that if any included makefile target is rebuilt we re-exec.
Also ensure that if an included makefile is not readable, and our rule
for rebuilding it doesn't actually change it, we will still fail.

* src/remake.c (update_goal_chain): If a goal's update was successful
then check its status, even if no actual commands were run because it
was already up to date.
(show_goal_error): Remove superfluous cast.
* src/main.c (main): If the makefile remake did nothing, check that we
were able to successfully include all the makefiles we care about; if
not fail.  When generating error messages about included makefiles be
sure to show the filename/linenumber information.
* test/scripts/features/reinvoke: Add tests for this behavior.
* test/scripts/options/dash-k: Update error messages.

3 years ago[SV 60412] Allow -I- to throw out the current directory path
Paul Smith [Sun, 30 May 2021 22:47:50 +0000 (18:47 -0400)] 
[SV 60412] Allow -I- to throw out the current directory path

Accept a "-" directory value to the -I option to clear the set of
directories to be searched up to that point, including the default
directories.

* NEWS: Announce the change.
* doc/make.texi (Summary of Options): Add documentation.
* src/read.c (construct_include_path): Check for '-' and if found,
clear the list of directories to be searched.
* tests/scripts/options/dash-I: Add tests for -I-.
* tests/scripts/variables/INCLUDE_DIRS: Add tests for -I-.

4 years ago[SV 60699] Avoid calling strlen() repeatedly in a loop
Dmitry Goncharov [Sun, 30 May 2021 20:21:22 +0000 (16:21 -0400)] 
[SV 60699] Avoid calling strlen() repeatedly in a loop

* src/variable.c (lookup_pattern_var): Accept target length parameter.
(initialize_file_variables): Pass computed target length to lookup.

4 years ago* NEWS: Add a few missing attributions
Paul Smith [Sun, 30 May 2021 19:52:32 +0000 (15:52 -0400)] 
* NEWS: Add a few missing attributions

* AUTHORS: Add some missing attributions

4 years ago[SV 60297] Add .NOTINTERMEDIATE special target
Dmitry Goncharov [Sun, 30 May 2021 17:48:29 +0000 (13:48 -0400)] 
[SV 60297] Add .NOTINTERMEDIATE special target

Support a new special target, .NOTINTERMEDIATE.  Any file or pattern
prerequisite of this target will never be considered intermediate.
This differs from .SECONDARY in that .SECONDARY files won't be deleted
but they will still not be built if they are missing.

.NOTINTERMEDIATE files are treated the same way as a target which is
explicitly mentioned in the makefile.  This is mostly useful with
patterns; obviously mentioning a target explicitly here is enough in
and of itself to make something not intermediate.

Some adjustments made by psmith@gnu.org

* NEWS: Announce the new feature.
* doc/make.texi (Special Targets): Document .NOTINTERMEDIATE.
(Chained Rules): Describe how to use .NOTINTERMEDIATE.
* src/main.c (main): Add "notintermediate" to the .FEATURES variable.
* src/filedef.h (struct file): Add "notintermediate" flag.
* src/file.c (no_intermediates): Mark global .NOTINTERMEDIATE.
(snap_file): Support .NOTINTERMEDIATE special target.  Throw an error
if the same target is marked both .NOTINTERMEDIATE and .SECONDARY or
.INTERMEDIATE.
(rehash_file): Merge intermediate, notintermediate, secondary flags.
(remove_intermediates): Check notintermediate flag before removing.
(print_file):
* src/implicit.c (pattern_search): Set notintermediate based on the
pattern.
* tests/scripts/targets/NOTINTERMEDIATE: Add a new test suite.

4 years ago* make.texi (Reading Makefiles): != creates recursive variables.
Paul Smith [Sun, 30 May 2021 15:01:49 +0000 (11:01 -0400)] 
* make.texi (Reading Makefiles): != creates recursive variables.

Reported by Ronald Hoogenboom <RHoogenboom@irdeto.com>.

4 years ago[SV 60659] Set $$< properly in second expansion
Dmitry Goncharov [Sat, 29 May 2021 23:03:07 +0000 (19:03 -0400)] 
[SV 60659] Set $$< properly in second expansion

Set the $$< automatic variable as best we can during secondary
expansion of prerequisites.

* src/commands.c (set_file_variables): Don't break without setting
'less' if secondary expansion is enabled.
* tests/scripts/features/se_explicit: Test secondary expansion results.
* tests/scripts/features/se_implicit: Test secondary expansion results.

4 years ago[SV 58341] Add non-trivial options to $(MAKEFLAGS)
Paul Smith [Mon, 19 Apr 2021 21:27:54 +0000 (17:27 -0400)] 
[SV 58341] Add non-trivial options to $(MAKEFLAGS)

Previously only trivial (single-letter) options were available in
$(MAKEFLAGS) when it is examined from inside a makefile (the full
value was set before expanding recipes).

Ensure that all options (but, not command line variable overrides!)
are visible in the $(MAKEFLAGS) variable.  In order to do this
reset the default values of options, particularly options which are
lists, before re-reading MAKEFLAGS after makefiles have been read.
Otherwise we'll get duplicate values for options such as -I.

Unfortunately there are complications here as well: sometimes (for
jobserver options in particular) we modify the values of these
options while running: we must not reset these modifications.

* NEWS: Announce this change
* src/main.c (main): Call new reset_switches() before re-parsing
MAKEFLAGS.
(reset_switches): Reset the value of non-special options to their
defaults.
(define_makeflags): Add non-special options into MAKEFLAGS even
if 'all' is not set.

4 years ago[SV 60378] Don't add duplicate default search directories
Dmitry Goncharov [Sat, 17 Apr 2021 21:50:07 +0000 (17:50 -0400)] 
[SV 60378] Don't add duplicate default search directories

Depending on how make was configured it may add duplicate
directories in the default include search path: avoid this.

(Tweaked by psmith@gnu.org)

* configure.ac: Set AM variable KNOWN_PREFIX if --prefix is known
* Makefile.am: Only set INCLUDEDIR if prefix is not known
* read.c [default_include_directories]: Only add INCLUDEDIR if set

4 years ago* tests/scripts/targets/INTERMEDIATE: [SV 60188] Add one more test
Dmitry Goncharov [Sun, 30 May 2021 17:58:50 +0000 (13:58 -0400)] 
* tests/scripts/targets/INTERMEDIATE: [SV 60188] Add one more test

4 years ago[SV 58656] Fix mtime for large files on MS-Windows
Eli Zaretskii [Sat, 29 May 2021 08:37:09 +0000 (11:37 +0300)] 
[SV 58656] Fix mtime for large files on MS-Windows

In MSVC builds, 'stat' fails when called on files larger than
2GB.  Call '_stat64' instead to work around this.

* src/remake.c (STAT): Define to '_stat64' for MSVC builds.
(name_mtime) [WINDOWS32]: Use STAT instead of 'stat'.
Suggested by Makoto Kato <m_kato@ga2.so-net.ne.jp>.

4 years agoFix build and test issues on Windows
Paul Smith [Sun, 28 Mar 2021 20:22:57 +0000 (16:22 -0400)] 
Fix build and test issues on Windows

* src/dep.h (DEP): Remove extraneous semicolon.
* src/dir.c (find_directory) [W32]: Replace removed variable.
* tests/scripts/features/include: Allow the extra default makefile
searched for on Windows.
* tests/scripts/functions/file: Use $(info ...) to avoid "command
too long" errors on Windows.

4 years ago* src/remake.c (name_mtime): Reserve space for nul in readlink result
Tobias Stoeckmann [Sun, 12 Jul 2015 09:52:32 +0000 (11:52 +0200)] 
* src/remake.c (name_mtime): Reserve space for nul in readlink result

Copyright-paperwork-exempt: yes

4 years ago* doc/make.texi (Call Function): Apply consistent formatting
Cao jin [Tue, 27 Jun 2017 07:49:41 +0000 (15:49 +0800)] 
* doc/make.texi (Call Function): Apply consistent formatting

Copyright-paperwork-exempt: yes

4 years ago* src/job.c (child_execute_job): Update gnulib find_in_given_path()
Pete Dietl [Thu, 31 Dec 2020 23:55:19 +0000 (15:55 -0800)] 
* src/job.c (child_execute_job): Update gnulib find_in_given_path()

Copyright-paperwork-exempt: yes

4 years ago* doc/make.texi (Automatic Variables): Relocate the $? example
Mike Frysinger [Thu, 25 Mar 2021 05:18:30 +0000 (01:18 -0400)] 
* doc/make.texi (Automatic Variables): Relocate the $? example

Copyright-paperwork-exempt: yes

4 years ago[SV 58497] Ensure $(file <) newline removal succeeds
Paul Smith [Mon, 15 Mar 2021 07:28:11 +0000 (03:28 -0400)] 
[SV 58497] Ensure $(file <) newline removal succeeds

Keep a count of bytes read rather than comparing pointers since the
variable_buffer might get reallocated.

Bug and patch by Ken Tossell <ken@tossell.net>
Regression tests by Dmitry Goncharov <dgoncharov@users.sf.net>
Tweaked by Paul Smith <psmith@gnu.org>

* src/function.c (func_file): Use bytes read rather than a pointer.
* tests/scripts/functions/file: Provide various tests for reading
empty files, files with/without newlines, and large files.

4 years ago[SV 60188] Explicit prereqs cannot be intermediate files
Dmitry Goncharov [Mon, 15 Mar 2021 06:10:49 +0000 (02:10 -0400)] 
[SV 60188] Explicit prereqs cannot be intermediate files

If a prereq of a pattern is an explicit target, it should not be
considered an intermediate file.

(Minor tweaks by Paul Smith <psmith@gnu.org>)

* src/dep.h (struct nameseq): Add is_explicit flag.
* src/implicit.c (struct patdeps): Ditto.
(pattern_search): Set the is_explicit flag appropriately for each
prerequisite, based on whether it contained a pattern or not.
Update the help output to note implicit vs. explicit prereqs.
* tests/scripts/features/double_colon: Add tests.
* tests/scripts/features/grouped_targets: Ditto.
* tests/scripts/features/patternrules: Ditto.
* tests/scripts/features/se_implicit: Ditto.
* tests/scripts/features/statipattrules: Ditto.

4 years ago* tests/scripts/features/exec: Small cleanup
Paul Smith [Mon, 15 Mar 2021 05:15:18 +0000 (01:15 -0400)] 
* tests/scripts/features/exec: Small cleanup

4 years agoEnsure variable_buffer is always set.
Paul Smith [Mon, 15 Mar 2021 05:09:32 +0000 (01:09 -0400)] 
Ensure variable_buffer is always set.

Initialize the global variable_buffer in main() so that it is never
a null pointer.  Then invoking variable_expand("") is never needed:
simply use the variable_buffer pointer when we want to restart the
variable buffer.  The main point of this simplification is not to
keep a separate pointer to the beginning of the buffer: this is
dangerous because the buffer may be re-allocated.  Instead always
use the variable_buffer pointer itself.

* src/variable.h (initialize_variable_output): Publish.
* src/expand.c (initialize_variable_output): Remove static.
* src/main.c (main): Initialize variable_buffer.
* src/file.c (enter_prereqs): Don't call variable_expand("") and
don't save a separate buffer pointer than might be outdated.
(expand_deps): Ditto.
* src/read.c (record_files): Ditto.
* src/remake.c (library_search): Ditto.

4 years ago[SV 59881] Handle vertical TAB consistently
Paul Smith [Sun, 14 Mar 2021 23:12:24 +0000 (19:12 -0400)] 
[SV 59881] Handle vertical TAB consistently

While parsing makefiles get_next_mword() was treating VTAB as a word
character rather than a word separator.  However, when using
find_next_token(), for example in patsubst_expand_pat(), we treated
VTAB as a word separator causing multiple words to appear where we
didn't expect them.

* src/makeint.h (END_OF_TOKEN): Change from a loop to a boolean check.
* src/misc.c (end_of_token): Move the loop here.
* src/read.c (get_next_mword): Skip whitespace, not just blank, to
find the start of the word and use END_OF_TOKEN() to decide when the
current word is finished.

4 years ago[SV 59870] define/undefine prerequisites are not target-specific vars
Paul Smith [Sun, 14 Mar 2021 20:32:47 +0000 (16:32 -0400)] 
[SV 59870] define/undefine prerequisites are not target-specific vars

* src/read.c (parse_var_assignment): If called in a target-specific
variable context don't allow define/undefine as variable assignments.
* test/scripts/variables/define: Add a test.
* test/scripts/variables/undefine: Add a test.

4 years ago* maintMakefile: Don't make .check-git-HEAD .PHONY
Paul Smith [Sun, 14 Mar 2021 19:53:45 +0000 (15:53 -0400)] 
* maintMakefile: Don't make .check-git-HEAD .PHONY

4 years agoMore correctly describe the scope of variables
Jouke Witteveen [Fri, 25 Dec 2020 18:00:10 +0000 (19:00 +0100)] 
More correctly describe the scope of variables

* NEWS: Use "local" instead of the incorrect "lexically-scoped".
* doc/make.texi: Refer to let/foreach variables as local variables.

4 years ago* doc/make.text: Clarify that patsubst doesn't touch unmatched words
Paul Smith [Mon, 8 Mar 2021 00:05:20 +0000 (19:05 -0500)] 
* doc/make.text: Clarify that patsubst doesn't touch unmatched words

4 years ago* .dir-locals.el: Update for newer LSP config
Paul Smith [Mon, 8 Mar 2021 00:04:48 +0000 (19:04 -0500)] 
* .dir-locals.el: Update for newer LSP config

4 years ago* file.c (remove_intermediates): Restart "rm ..." on error
Paul Smith [Mon, 8 Mar 2021 00:04:22 +0000 (19:04 -0500)] 
* file.c (remove_intermediates): Restart "rm ..." on error

4 years ago* doc/make.texi (How Patterns Match): [SV 58639] Fix chaining info.
Paul Smith [Mon, 7 Dec 2020 06:03:11 +0000 (01:03 -0500)] 
* doc/make.texi (How Patterns Match): [SV 58639] Fix chaining info.

4 years agoCreate $(let ...) providing lexically scoped variables
Jouke Witteveen [Sun, 1 Nov 2020 21:48:53 +0000 (22:48 +0100)] 
Create $(let ...) providing lexically scoped variables

Add a new function $(let ...) which allows lexically scoped variables.

* NEWS: Add information on this feature.
* doc/make.texi (Let Function): Document the 'let' function.
* src/function.c (func_let): Create the 'let' built-in function.
* tests/scripts/functions/let: Test the 'let' built-in function.

4 years ago* doc/make.texi (Phony Targets): [SV 58961] Clarify pattern handling
Paul Smith [Sun, 6 Dec 2020 20:21:23 +0000 (15:21 -0500)] 
* doc/make.texi (Phony Targets): [SV 58961] Clarify pattern handling

4 years ago* doc/make.texi (Synchronized Terminal Output): [SV 58960] Fix link
Paul Smith [Sun, 6 Dec 2020 15:14:15 +0000 (10:14 -0500)] 
* doc/make.texi (Synchronized Terminal Output): [SV 58960] Fix link

4 years ago[SV 59169] Add --debug=why and --debug=print options
Paul Smith [Sat, 5 Dec 2020 21:25:12 +0000 (16:25 -0500)] 
[SV 59169] Add --debug=why and --debug=print options

Add debug options to print recipes even if they would otherwise be
silent, and to print the reason that a target was considered out of
date.

Modify --trace to simply be a shorthand for --debug=print,why.

* NEWS: Announce changes.
* doc/make.texi (Summary of Options): Document the new options.
* doc/make.1: Ditto.
* src/debug.h: Add new flags DB_PRINT and DB_WHY.
* src/makeint.h: Remove the trace_flag variable.
* src/job.c (start_job_command): Check debug flags not trace_flag.
(new_job): Ditto.
* src/main.c (trace_flag): Make a static variable for switches.
(decode_debug_flags): Set DB_PRINT and DB_WHY if trace_flag is set.
* tests/scripts/variables/GNUMAKEFLAGS: Update known-good messages.
* tests/scripts/variables/MAKEFLAGS: Ditto.

4 years ago* configure.ac: [SV 58836] Copy build.sh to the build directory
Paul Smith [Sat, 5 Dec 2020 20:11:52 +0000 (15:11 -0500)] 
* configure.ac: [SV 58836] Copy build.sh to the build directory

4 years ago[SV 57676] Support included files being built after failing
Paul Smith [Sat, 5 Dec 2020 20:06:25 +0000 (15:06 -0500)] 
[SV 57676] Support included files being built after failing

If a -include file does not exist, then some subsequent operation
creates it, then allow it to be successfully included.

* src/read.c (eval_makefile): If our last mtime was NONEXISTENT then
reset it to 0 so we'll check it again.
* tests/scripts/features/include: Add a test for this behavior.

4 years ago* src/makeint.h (free_alloca): Check for builtin alloca
Paul Smith [Wed, 2 Dec 2020 22:29:16 +0000 (17:29 -0500)] 
* src/makeint.h (free_alloca): Check for builtin alloca

4 years ago* src/main.c (main): [SV 59601] Check for malformed env. variables
Paul Smith [Wed, 2 Dec 2020 22:27:55 +0000 (17:27 -0500)] 
* src/main.c (main): [SV 59601] Check for malformed env. variables

4 years ago* maintMakefile: [SV 58794] Check for file existence in the release
Paul Smith [Sun, 29 Nov 2020 22:40:34 +0000 (17:40 -0500)] 
* maintMakefile: [SV 58794] Check for file existence in the release

4 years ago* Makefile.am (HAVE_GUILE): Only use Guile options if HAVE_GUILE.
Paul Smith [Sun, 29 Nov 2020 21:02:41 +0000 (16:02 -0500)] 
* Makefile.am (HAVE_GUILE): Only use Guile options if HAVE_GUILE.

4 years ago* tests/scripts/features/vpathgpath: Avoid duplicate function name.
Paul Smith [Sun, 29 Nov 2020 21:02:12 +0000 (16:02 -0500)] 
* tests/scripts/features/vpathgpath: Avoid duplicate function name.

4 years agoResolve unused-result warnings for alloca(0)
Paul Smith [Sun, 29 Nov 2020 19:28:29 +0000 (14:28 -0500)] 
Resolve unused-result warnings for alloca(0)

* src/makeint.h (free_alloca): New macro to defeat warn_unused_result.
* src/read.c (eval_makefile): Call it.
(eval_buffer): Ditto.
* src/remake.c (update_file): Ditto.

4 years agoAvoid some valgrind warnings
Paul Smith [Sun, 29 Nov 2020 19:03:30 +0000 (14:03 -0500)] 
Avoid some valgrind warnings

Using sscanf() to parse archive header values (struct ar_hdr) can lead
to valgrind warnings which are probably bogus but are annoying.
To be safer, create a local method to convert the ASCII integer
strings into integers.

* src/arscan.c (parse_int): Turn integer strings into integers.
(ar_scan): Initialize struct ar_hdr memory.
Call parse_int() rather than sscanf/atol.

4 years ago[SV 41273] Allow the directory cache to be invalidated
Paul Smith [Fri, 27 Nov 2020 22:07:53 +0000 (17:07 -0500)] 
[SV 41273] Allow the directory cache to be invalidated

Each time we invoke a command it's possible that it will change the
filesystem in ways that were not described by the target.  If that
happens but we have cached previous directory contents then we may
make decisions or report results based on obsolete information.

Keep a count of how many commands we've invoked, and remember the
current command count every time we load the contents of a directory.
If we request the directory and the current command count has changed
we know the cache is outdated so reload from scratch.

* NEWS: Announce the change.
* src/makeint.h (command_count): Create a global counter.
* src/main.c (command_count): Ditto.
* src/job.c (reap_children): Increment the counter on job completion.
* src/function.c (func_file): Increment if we write a file.
* src/dir.c (clear_directory_contents): Clear the current contents of
a cached directory.
(struct directory_contents): Remember the counter value.
(struct directory): Remember the counter value for non-existing dirs.
(find_directory): If we have a cached directory and the count hasn't
changed then return it.  Else, clear the previous contents and re-read
from scratch.
* tests/scripts/features/dircache: Add tests of the directory cache.

4 years agoSupport "unexport" in target-specific variables.
Paul Smith [Sat, 28 Nov 2020 17:30:08 +0000 (12:30 -0500)] 
Support "unexport" in target-specific variables.

Rewrite the environment variable algorithm to correctly inherit
export settings from parent variable sets.  The new algorithm
for computing the table of environment variables is:

- Start with the most local variable set and proceed to global.
- If the variable already exists in the table and we don't know
  its export status, update it with the current variable's status.
- If the variable is not in the table and it's not global, add it
  regardless of its status so if it's unexported we remember that.
- If the variable is not in the table and is global, check its
  export status and don't add it if we won't export it.

Then when generating the environment variables, check the export
status of each variable in case it was a target-specific variable
and we have determined it should not be exported.

Rework SHELL handling to check at the end whether we added it or
not and if we didn't, add the value from the environment.

* NEWS: Announce support for target-specific "unexport"."
* doc/make.texi (Target-specific): Document the support.
* src/variable.h (enum variable_export): Make into a global type.
* src/read.c (struct vmodifiers): Use enum variable_export rather
than individual booleans.
(parse_var_assignment): Parse the "unexport" keyword.
(eval): Remember the vmodifier value in the variable.
(record_target_var): Ditto.
* src/variable.c (should_export): Check if the variable should be
exported.
(target_environment): Implement the above algorithm.
* tests/scripts/features/export: Test export/unexport with variable
assignments on the same line.
* tests/scripts/features/targetvars: Add a comprehensive suite of
tests for different types of target-specific export / unexport.
* tests/scripts/variables/SHELL: Update the comment.

4 years ago[SV 59230] Preserve export settings for target-specific vars
Dmitry Goncharov [Fri, 27 Nov 2020 22:18:05 +0000 (17:18 -0500)] 
[SV 59230] Preserve export settings for target-specific vars

* src/read.c (record_target_var): Don't overwrite pre-existing export
flag unless we're changing it.
* tests/scripts/features/targetvars: Add a test.

4 years ago[SV 59230] Ensure environment variables are exportable
Paul Smith [Fri, 27 Nov 2020 21:56:22 +0000 (16:56 -0500)] 
[SV 59230] Ensure environment variables are exportable

When checking for invalid environment variable names we searched the
entire name string instead of just the first LENGTH chars; this could
cause us to incorrectly decide the variable was not exportable.

Dmitry Goncharov <dgoncharov@users.sf.net> found this bug and
provided a test case and sample fix: I used the test but chose a
slightly different fix.

* src/variable.c (define_variable_in_set): check the variable name
not the input string.
* tests/scripts/features/targetvars: Ensure environment variable
values are exported.

4 years ago* src/default.c (default_variables) [AIX]: [SV 59096] Fix ARFLAGS
Paul Smith [Fri, 27 Nov 2020 21:16:38 +0000 (16:16 -0500)] 
* src/default.c (default_variables) [AIX]: [SV 59096] Fix ARFLAGS

Reported by Dmitry Goncharov <dgoncharov@users.sf.net>, with a patch
changing the pattern rule for building archives.  I decided to
change the default value of ARFLAGS on AIX instead.

4 years ago[SV 35711] Check for special targets earlier
Paul Smith [Fri, 27 Nov 2020 16:37:29 +0000 (11:37 -0500)] 
[SV 35711] Check for special targets earlier

GNU make must recognize some special targets as they are defined.
Because of the way targets are defined, we were not recognizing these
special targets until we were handling the NEXT statement.  However
that's too late for some special targets such as .POSIX etc. which can
change the behavior of make during parsing.

Check for special targets earlier, as soon as we've finished parsing
the target introduction line (before we've even parsed the recipe).

* NEWS: Mention the change.
* src/read.c (check_specials): New function to look for special
targets.  Move checks from eval() and record_files() to this new
function.
(eval): Call check_specials() after we've completed parsing the target
introduction line.  Move default goal detection to check_specials().
(record_files): Move handling of .POSIX, .SECONDEXPANSION, and
.ONESHELL to check_specials().
* tests/scripts/misc/bs-nl: Remove workaround for late .POSIX issue.
* tests/scripts/targets/POSIX: Add a comment.