Home | History | Annotate | only in /src/usr.bin/make/unit-tests
History log of /src/usr.bin/make/unit-tests
RevisionDateAuthorComments
 1.1 30-Nov-2019  rillig branches: 1.1.4;
Ignore temporary files from running the unit tests
 1.1.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.4.1 30-Nov-2019  martin file .cvsignore was added on branch phil-wifi on 2020-04-08 14:09:17 +0000
 1.372 04-Aug-2025  sjg Use printf rather than echo -n
 1.371 04-Aug-2025  sjg sync-mi should do .inc files too?
 1.370 03-Aug-2025  sjg make: ensure output captured in meta file is accurate

In CollectOutput() a newline before the end of job->outBuf
results in a short write to stdout, but meta_job_output()
was recording the entire string in the meta file, so on
next call the left overs would be duplicated in the meta file.

Pass a length to meta_job_output() if it should only report part of
the data in meta file.
 1.369 29-Jun-2025  rillig tests/make: test backslash at the end of a line and in the :M modifier

As described in PR bin/46139 by David A. Holland.
 1.368 27-Jun-2025  rillig tests/make: test missing support for $^

Test provided by Diogo Santos via PR bin/59018; extended by me for .WAIT
and implicit rules.
 1.367 13-Jun-2025  rillig tests/make: fix race condition in debug output in parallel mode

Discovered in ATF run on evbearmv7hf.
 1.366 13-Jun-2025  rillig make: add on-demand inter-process stack traces

When debugging a build that heavily uses nested calls to sub-makes, the
chain of calls is useful to quickly assess the situation. If explicitly
requested, include the actions from any parent processes in the stack
traces.

Reviewed by: sjg
 1.365 13-Jun-2025  sjg Fix replacing ${TEST_MAKE} with make
 1.364 12-Jun-2025  rillig make: use a common style for unexpected error messages

In enomem, report the actual error instead of a fixed ENOMEM.
 1.363 05-Jun-2025  rillig make: remove empty line from diagnostic, add tests for output handling

The warning for the invalid internal option "-J" does not need a
trailing newline, as that is provided by Parse_Error already.

Having this newline in the output demonstrated a previously unknown bug
in handling the output of child commands in parallel mode. There, empty
lines are randomly discarded, depending on the chunks in which the
output from the child process is copied to make's stdout. See
job-output.mk for a demonstration.

The test for the Korn shell did not run the Korn shell in error handling
mode, as the error handling mode only affects the parallel mode but the
test didn't switch to that mode.

After fixing the shell-ksh.mk test, the single '"' in the output looked
suspicious, and indeed, the shell-csh.mk test had the same problem of
filtering more characters from the output than intended.
 1.362 09-May-2025  rillig make: unify debug messages for parallel mode

Always print the process status in hex, with a leading "0x", to avoid
confusion for status 127f, which looks suspiciously decimal.

Prefix all process IDs with "pid", to be able to filter them easily.

Omit trailing whitespace when printing a command.
 1.361 07-May-2025  rillig make: add end marker for -dg1, -dg2 and -dg3 debug log

The marker helps distinguish the output from sub-makes from the output
of the primary make.
 1.360 03-May-2025  rillig make: use uniform debug log messages for the token pool
 1.359 22-Apr-2025  rillig make: group the code for handling the job token pool
 1.358 13-Apr-2025  rillig tests/make: add tests for POSIX mode
 1.357 12-Apr-2025  sjg make/unit-tests: Fix expected results for meta-ignore tests
 1.356 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.355 25-Jan-2025  sjg make/unit-tests: avoid failure on NFS

The 'rm -rf ${TMPDIR}' at the end of the 'test' target, fails
when building on NFS because the temp file used for the target script
keeps the directory from being empty.

Move it to a separate target attached to '.END'

Reviewed by: rillig
 1.354 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.353 22-Nov-2024  rillig tests/make: speed up running the tests

Only 4 of the 389 tests need to postprocess their output, so spare the
extra 'cat' call in the majority of cases.
 1.352 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.351 18-Aug-2024  rillig tests/make: clean up private temporary directory after running tests

Fixes PR bin/58569.
 1.350 07-Jul-2024  rillig make: don't track hash table chain lengths during lookup

The chain lengths are only used for debugging purposes, so avoid the
extra cost at each lookup. Instead, calculate the maximum chain length
only when it is actually requested in -dh mode.

The reported number changes slightly: Before, it was the length of the
chain that was actually traversed to find an entry, up to that entry,
now it is the length of the largest chain in the table, no matter if it
was actually accessed or not.
 1.349 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.348 01-Jul-2024  sjg make: add :tc to capitalize first letter of each word

This is very hard to do without :tc

Reviewed by: rillig
 1.347 01-Jun-2024  sjg branches: 1.347.2;
Run check-expect.lua in .CURDIR
 1.346 01-Jun-2024  rillig tests/make: require all expected messages to be listed in the .mk files
 1.345 24-May-2024  rillig make: in -DCLEANUP mode, free variables and their values

The variables in the 3 scopes must be freed before the scopes themselves
are freed by Targ_End.

The test opt-m-include-dir creates a directory of the form '*.tmp', thus
it must be removed before attempting to only remove regular files of
this name.

POSIX requires setenv to copy the passed name and value, so there is no
need to keep that memory allocated any longer.
 1.344 30-Apr-2024  sjg Subst DEFSYSPATH in deptgt-phony
 1.343 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.342 07-Jan-2024  sjg make: unit-tests handle TEST_MAKE:T != make

We need to allow for ${TEST_MAKE:T}[1-9]: etc when
TEST_MAKE is not 'make'
 1.341 09-Sep-2023  sjg Add .MAKE.JOBS.C to indicate wether -jC is supported
 1.340 17-Aug-2023  rillig tests/make: extend tests for the ':mtime' modifier
 1.339 20-Jun-2023  rillig make: allow targets to be used as multiple-inclusion guards

This style is used by FreeBSD, among others.
 1.338 16-Jun-2023  rillig tests/make: add test for multiple-inclusion guards
 1.337 16-Jun-2023  rillig tests/make: clean up tests for the ':M' and ':S' modifiers
 1.336 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.335 10-May-2023  rillig tests/make: clean up tests for .for loops

Most of the tests from forloop.mk were already in directive-for.mk.
 1.334 09-May-2023  sjg make: add :mtime to provide mtime of file

The value of the variable is passed to stat(2)
and st_mtime is new value.
An optional arg can be used if stat(2) fails, otherwise
the current time is used.

See varmod-mtime.mk for usage examples.
 1.333 25-Feb-2023  sjg make: meta-ignore tests will not work if TMPDIR is /tmp

Since /tmp and /var/tmp are always part of .MAKE.META.IGNORE_PATHS
the varname-dot-make-meta-ignore_* tests will not work
if TMPDIR is either (or subdir) of those.
 1.332 23-Feb-2023  sjg Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR
 1.331 24-Jan-2023  sjg make: .SYSPATH: to add dirs to sysIncPath

.SYSPATH: with no sources will clear sysIncPath
otherwise sources are added

Reviewed by: rillig
 1.330 23-Jan-2023  sjg make: .[NO]READONLY for control of read-only variables

Reviewed by: rillig
 1.329 19-Jan-2023  rillig tests/make: rename files that are not test cases
 1.328 19-Jan-2023  rillig tests/make: add tests for whitespace in leading '@+-'
 1.327 25-Sep-2022  rillig tests/make: fix test for option '-e' (broken since 2022-01-23)
 1.326 10-Sep-2022  rillig tests/make: be more specific about the egrep compatibility
 1.325 09-Sep-2022  sjg Handle deprecation of egrep
 1.324 03-Sep-2022  sjg Only update distrib/sets/lists/tests/mi with valid files

sync-mi: use CVS/Entries to ensure we only update
distrib/sets/lists/tests/mi with files known to CVS.

Reviewed by: rillig
 1.323 02-Sep-2022  sjg Enable make/unit-tests/directive-for-break

Also ensure MAKE_VERSION is ignored.
 1.322 02-Sep-2022  sjg make: add .break to terminate .for loop early

When .break is encountered within a .for loop
it causes immediate termination.

Outside of a .for loop .break causes a parse error.

Reviewed by: christos
 1.321 25-Aug-2022  rillig tests/make: fix canonicalization for single-digit day of month
 1.320 24-Aug-2022  rillig make: prevent future out-of-bounds errors when parsing expressions

A modifier in an expression ends not only at the next ':' or at the
closing '}' or ')', but also at the end of the string.

Previously, testing for the end of the string had been done separately,
which was error-prone since 2006-05-11, when indirect modifiers were
introduced. Since then, it was possible that the string terminator '\0'
was accidentally skipped in cases where the loop condition only tested
for the ending character. When parsing indirect modifiers, the ending
character is indeed '\0', but when parsing direct modifiers, it is '}'
or ')'.

A welcome side effect is that in the case of unclosed expressions such
as '${VAR:Modifier', the amount of error messages is reduced from 2 or 3
to only 1. The removed error messages were wrong and thus confusing
anyway.
 1.319 26-Jul-2022  sjg Pass MAKEOBJDIR to opt-m-include-dir

Prevent makeing opt-m-include-dir.tmp in src tree.

Reviewed by: rillig
 1.318 10-Jun-2022  rillig tests/make: reword comment in Makefile to be more specific
 1.317 02-Jun-2022  skrll Increase the resource limit so these tests pass on hppa.

LGTM from Roland
 1.316 23-May-2022  rillig tests/make: document and demonstrate .for i containing .if empty(i)

PR bin/43821 describes the inconsistency that in a '.for i' loop, the
condition '.if ${i:M*.c}' works since 2009 while the seemingly
equivalent condition '.if !empty(i:M*.c)' does not access the variable
'i' from the .for loop but instead the global 'i'.

Resolving this situation in a backwards-compatible and non-surprising
way is hard, as make has grown several features during the last 20 years
that interact in various edge cases. For now, document the most obvious
pitfalls.
 1.315 08-May-2022  rillig tests/make: remove test varquote

The test varmod-quote-dollar covers the same topic.
 1.314 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.313 07-May-2022  rillig make: allow to randomize build order of targets

In complex dependency structures, when a build fails, a probable cause
is a missing dependency declaration between some files. In compat mode,
the build order is deterministic, in jobs mode, it is somewhat
deterministic. To explore more edge cases, add the line ".MAKE.MODE +=
randomize-targets" somewhere in the makefile.

Fixes PR bin/45226 by riastradh. Reviewed by christos.
 1.312 18-Apr-2022  rillig make: only switch to POSIX mode if '.POSIX:' is the first line

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
says that in order to make a makefile POSIX-conforming, its first
non-comment line must be the special dependency line '.POSIX:' without
any source dependencies.

Previously, make switched to POSIX mode even if such a line occurred
anywhere else, which was allowed by POSIX but was deep in the
"unspecified behavior" area. For NetBSD make, there is no big
difference since it doesn't ship any <posix.mk> file, this change mainly
affects the bmake distribution.

Previously, makefiles that contain '.POSIX:' somewhere in the middle
could fail due to <posix.mk> resetting .SUFFIXES, among other things.

Suggested by Simon J. Gerraty, who also reviewed an earlier version of
this change.
 1.311 26-Mar-2022  rillig make: fix crash on .undef of an environment variable (since 2020-10-06)
 1.310 25-Mar-2022  rillig tests/make: suppress -DCLEANUP output in test deptgt-phony
 1.309 12-Feb-2022  rillig tests/make: document the history of bugs in '-k' mode

Reported in PR#49720 in 2015, fixed independently in compat.c 1.199 from
2020-12-07.
 1.308 12-Feb-2022  rillig tests/make: demonstrate bug for .SILENT in jobs mode (since 2003)

Reported 2011 in PR#45356.
 1.307 09-Feb-2022  rillig tests/make: remove redundant 'echo' from variable assignments

Before main.c 1.231 from 2014-09-09, a variable assignment using the
operator '!=' generated a warning "Couldn't read shell's output" if the
output of the command was empty. The simplest way to suppress this
wrong warning was to add an empty 'echo' to the command. This hack is
no longer needed.
 1.306 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.305 09-Feb-2022  rillig make: prefix the warning about read-only .OBJDIR with a colon

For consistency with the other warnings.
 1.304 09-Feb-2022  rillig tests/make: use more distinctive placeholder for TMPDIR
 1.303 07-Feb-2022  rillig tests/make: demonstrate combination of .USE with transformation rule

Reported in 2003 in PR toolchain/20993. Linking a transformation rule
with .USE or .USEBEFORE node makes the transformation rule fail.
 1.302 27-Jan-2022  sjg numEntries can vary
 1.301 27-Jan-2022  sjg Do not allow /usr/obj to cause failure.
 1.300 23-Jan-2022  rillig tests/make: migrate modts to varmod-to-separator and explain
 1.299 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.298 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.297 22-Jan-2022  rillig tests/make: explore edge cases involving .ifmake
 1.296 19-Jan-2022  rillig tests/make: demonstrate wrong location in diagnostic (since 2018-12-22)

When a target has multiple places where commands are defined, the
diagnostics mixed up the filename in some cases.
 1.295 11-Jan-2022  rillig tests/make: clean up after test for option '-dF'

When the file for the debug log cannot be opened, make exits
immediately. This doesn't give the test a chance to clean up the
temporary log file.

Instead of trying to treat a regular file as a directory and create a
file in it, assume that the directory /nonexistent-$uuid is actually
nonexistent. This leads to the same kind of error message, independent
of strerror(3).
 1.294 09-Jan-2022  rillig tests/make: add placeholders for .PARSEDIR and .INCLUDEDFROMDIR

When run via 'cd usr.bin/make/unit-tests && make test', the tests are in
the current directory. When run via ATF, the tests are in
/usr/tests/usr.bin/make/unit-tests, while the current directory is a
temporary directory. Allow both variants, plus others that may occur in
the bmake distribution.
 1.293 28-Dec-2021  rillig tests/make: clean up after test 'opt-debug-file'
 1.292 28-Dec-2021  rillig tests/make: document inconsistencies between '!=' and '::!='

Found while trying to make the error messages from Cmd_Exec more
detailed.
 1.291 23-Dec-2021  rillig tests/make: explain the current behavior of the option '--version'
 1.290 14-Dec-2021  rillig make: remove unreachable code for parsing the dependency operator

At the point where ParseDependencyOp is called, cp is guaranteed to
point to either ':' or '!'.

No functional change.
 1.289 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.288 12-Dec-2021  rillig tests/make: test and document the newly added "variable" .SUFFIXES
 1.287 09-Dec-2021  rillig make: add back support for jemalloc 100

The ports sun2 and vax default to jemalloc 100, as opposed to the rest
of the ports, which use jemalloc 510. Some developers choose to use
jemalloc 100, so let them run the tests with memory debugging as well.

Suggested by mrg on source-changes-d.
 1.286 05-Dec-2021  rillig make: fix use-after-free in modifier ':@'

Without memory allocator debugging, the newly added test doesn't show
any obvious failure.

With memory allocator debugging enabled, all make versions since
2016.02.27.16.20.06 crash with a segmentation fault.
 1.285 05-Dec-2021  rillig tests/make: migrate to jemalloc > 100

When I started working on usr.bin/make in 2020, I used NetBSD 8, which
used jemalloc 100.

After updating to NetBSD 8 to 9.99.x, the debugging options for jemalloc
stopped working since MALLOC_OPTIONS had been replaced with MALLOC_CONF
in 2019.

Enable malloc debugging again, to reliably reproduce the use-after-free
for the variable modifier ':@'.
 1.284 19-Oct-2021  sjg Replace ${.OBJDIR} with <curdir> for consistent results.

If we replace ${.OBJDIR} with <objdir> some tests produce
different results depending on the value of .OBJDIR

For similar reasons eliminate .OBJDIR and .PATH from output of
varname-empty

Reviewed by: rillig
 1.283 30-Aug-2021  rillig tests/make: explain where "${var}" in .for loops comes from
 1.282 31-Jul-2021  rillig tests/make: split tests for the variable modifier ':O'

The tests for parse errors are now in varmod-order, which lets the other
tests focus on the desired behavior of the modifiers.
 1.281 30-Jul-2021  sjg Add :On for numeric sort

Reviewed by: christos rillig
 1.280 29-Jun-2021  sjg Allow BROKEN_TESTS to cause TESTS to be skipped.

Some tests simply do not work in some environments.
Eg. shell-ksh on macos/arm64
Allow local site to set BROKEN_TESTS to skip those they know
will not work.

Reviewed by: rillig
 1.279 16-Jun-2021  rillig tests/make: demonstrate wrong error handling in jobs mode
 1.278 18-May-2021  sjg Do not trust that /nonexistent does not exist

Use /nonexistent.${.MAKE.PID} to avoid failure when
/nonexistent actually exists.
 1.277 27-Apr-2021  rillig branches: 1.277.2;
tests/make: test the combination of -de with -j1

The test cases are the same as in opt-debug-errors.mk. The output
differs in several details though.

Even though the option '-k' is given (which is the default for any tests
that don't override it in unit-tests/Makefile), there is no message
"(continuing)" anywhere.

The failed target is printed twice. Once before the failed commands,
once after. This redundancy is not necessary and may be removed in a
follow-up commit.

The printed commands are in their unexpanded form, which may or may not
be more helpful than the expanded and space-normalized form of compat
mode. Either way, this is an unnecessary inconsistency between compat
mode and jobs mode.

In jobs mode, the message "make: stopped in $dir" is printed for each
failure, which is helpful since each of the jobs may have started in a
separate directory.
 1.276 15-Apr-2021  rillig tests/make: demonstrate handling of null bytes
 1.275 04-Apr-2021  rillig tests/make: split test for modifier ':@' into separate files

The file varmod-loop.mk has grown too large to be single-purpose, plus
it combined parse-time and run-time tests. This has the downside that
as soon as a parse-time test results in an error, the run-time tests are
not run anymore.
 1.274 03-Apr-2021  rillig make: use C99 bool type instead of defining its own

No functional change.
 1.273 14-Mar-2021  rillig tests/make: add test for short-circuit evaluation of modifiers
 1.272 14-Mar-2021  rillig make: demonstrate wrong expression evaluation in -dL mode
 1.271 14-Feb-2021  rillig make: add test for the variable modifier ':sh'
 1.270 14-Feb-2021  rillig make: fix TMPDIR in unit-tests

Combining the assignment operator ':=' with the variable modifier ':U'
on the same variable does not work as intended. At the point where the
':U' is evaluated, the variable is guaranteed to be defined because the
code in VarAssign_EvalSubst says so.
 1.269 06-Feb-2021  sjg Avoid test failures when more than one user run them.

Use a private TMPDIR
a subdir of .OBJDIR if using it
otherwise /tmp/uid${.MAKE.UID}
 1.268 04-Feb-2021  rillig make: remove .PARSEDIR from test output of varname-empty

The .PARSEDIR has nothing to do with .CURDIR. This wrong assumption
made the NetBSD test suite fail since the actual .PARSEDIR was not
replaced with "<curdir>".
 1.267 03-Feb-2021  rillig make: in the test varname-empty, keep more debug output

Filtering out the interesting lines based on the very specific pattern
"Var_Set" was surprising.
 1.266 02-Feb-2021  rillig make: demonstrate that neither -dg2 nor -dg3 produces debug output
 1.265 01-Feb-2021  rillig make: add test for reading from make's stdin

Just out of curiosity whether that really works. It does.
 1.264 30-Jan-2021  rillig make(1): add test for combining the options -j, -n, -t

This is a preparation for refactoring the complicated condition in
JobStart.
 1.263 29-Jan-2021  rillig make(1): demonstrate unnecessary creation of empty files in jobs mode
 1.262 23-Jan-2021  rillig make(1): fix unit tests for dash and bash 5.1
 1.261 19-Jan-2021  rillig make(1): normalize shell error messages in tests

Newly supported is bash, which outputs "bash: line 123".
 1.260 31-Dec-2020  rillig make(1): add test for error handling and expansion in .for loops
 1.259 30-Dec-2020  rillig make(1): add test for .endfor without corresponding .for
 1.258 29-Dec-2020  rillig make(1): add test that explains how variables are exported

Exporting the variables at the right time and with the correct values is
a subtle issue. The current implementation carefully marks variables as
ready to be exported, then exports them and at the same time tries to
export as few variables as possible, to avoid memory leaks. This test
describes and explains how all this works in detail.

This test also justifies that the call to Var_ReexportVars happens in
the make process itself, not in the child processes, no matter whether
these are created with vfork or (only theoretically) with plain fork.
This has changed in compat.c 1.217, job.c 1.390 and main.c 1.504 from
2020-12-27.
 1.257 27-Dec-2020  rillig make(1): add test for expansion errors in jobs mode

Since compat mode and jobs mode are implemented separately and vary in
lots of small details, each of them needs to be tested on its own.
 1.256 21-Dec-2020  rillig make(1): align tests for :localtime with those for :gmtime

These tests had been almost the same before, now they are as similar as
possible again.
 1.255 21-Dec-2020  rillig make(1): move tests for :gmtime to parse time

It's easier to have both the expressions and the expected values in a
single file. This also allows for flexible handling of multiple
acceptable outputs, in this case for 32-bit time_t.
 1.254 21-Dec-2020  sjg Set default for .MAKE.OS once
 1.253 20-Dec-2020  rillig make(1): include line numbers in output of test varmod-edge.mk

Suppressing the line numbers does not provide much benefit, given that
the test file doesn't change often.
 1.252 19-Dec-2020  rillig make(1): add test for null byte in .for loop body
 1.251 19-Dec-2020  rillig make(1): demonstrate wrong line numbers in .for loops, since 2007-01-01
 1.250 14-Dec-2020  rillig make(1): add test for parsing the end of a condition
 1.249 13-Dec-2020  rillig make(1): demonstrate wrong error handling in compat mode
 1.248 13-Dec-2020  sjg Prune job debug output that may appear out of order.

A race between child and parent means that we cannot
guarantee whether all child output is seen before we call
JobClosePipes, thus intervening debug output can appear
before or after the last child output.
 1.247 13-Dec-2020  sjg Ensure we have a value for .MAKE.UID
 1.246 13-Dec-2020  rillig make(1): add test for misspelled directives

This test allows the other directive-* tests to focus on the purpose of
the individual directive, allowing these tests to continue after
parsing, without errors.
 1.245 12-Dec-2020  rillig make(1): add test for a shell with error control

None of the predefined shells has error control, and the corresponding
code had not been covered by the existing unit tests.
 1.244 10-Dec-2020  rillig make(1): test all combinations of switches for running commands

The code in JobPrintSpecials is rather complicated and contains
surprising interaction between some of the switches.

To see the exact effects of the switches, record the current state and
its output, to prevent accidental breakage during the upcoming
refactorings.
 1.243 09-Dec-2020  rillig make(1): remove noise from test output of opt-jobs-no-action
 1.242 09-Dec-2020  rillig make(1): add test for the -n option combined with RunFlags
 1.241 09-Dec-2020  rillig make(1): add test for combining -j1 with -n
 1.240 07-Dec-2020  rillig make(1): normalize output of test sh-dots for non-native mode
 1.239 07-Dec-2020  rillig make(1): add tests and tutorial for the ?= assignment operator
 1.238 07-Dec-2020  rillig make(1): add test for wrong exit status 0 after failed targets with -k
 1.237 06-Dec-2020  rillig make(1): add test for .END after failed main node
 1.236 05-Dec-2020  sjg Use .MAKE.OS if we can
 1.235 04-Dec-2020  rillig make(1): use fixed format for debug output of the directory cache

The previous output format had a %-20s conversion specifier. This
produced different output depending on the length of the pathname, which
was too difficult to normalize. By moving the directory name to the
end, it is no longer necessary to fill up any space, and the numbers are
always aligned properly.

As a result, 3 of the unit tests no longer need any special
postprocessing of their output.
 1.234 01-Dec-2020  rillig make(1): add test and tutorial for indirect modifiers
 1.233 01-Dec-2020  rillig make(1): add test for the special .MAKEFLAGS variable
 1.232 01-Dec-2020  rillig make(1): add tests for suppressing "stopped in"

These tests demonstrate the unwanted behavior described in PR bin/55578
and PR bin/55832.
 1.231 30-Nov-2020  rillig make(1): fix tests for :gmtime and :localtime for 32-bit time_t

https://bugs.freebsd.org/251465
 1.230 30-Nov-2020  sjg Add some tests for meta mode
 1.229 29-Nov-2020  rillig make(1): clean up memory management for CachedDirs

Previously, the reference count for a newly created CacheDir had been
set to 1 in CacheNewDir. This was wrong because at that point, the
object had not been referenced by any nonlocal variable. The reference
count is no longer incremented at this point.

All callers of CacheNewDir either append the newly created CachedDir to
a SearchPath via Lst_Append and CachedDir_Ref, or they assign it to a
global variable via CachedDir_Assign.

Since the reference count is no longer wrongly incremented, it does not
need to be decremented more than necessary in Dir_End. To keep the code
simple and maintainable, all assignments to global variables are now
handled by CachedDir_Assign. Adding a CachedDir to a list is still done
manually via Lst_Append, and the corresponding code for decrementing is
in SearchPath_Clean and SearchPath_Free. These details may be cleaned
up in a follow-up commit.

As a result, when OpenDirs_Done is called in the unit tests, the list of
open directories is empty. It had been non-empty in a single unit test
before (dep-wildcards.mk), as a result of calling Dir_Expand.

The additional debug logging for the reference counting is not enabled
by default since it contains memory addresses, which makes the output
dependent on the memory allocator.

The function CachedDir_Destroy has been merged into CachedDir_Undef,
which had only been used in Dir_End before. The new name emphasizes
that it corresponds to CachedDir_Ref.
 1.228 29-Nov-2020  rillig make(1): add debug logging for OpenDirs_Done
 1.227 29-Nov-2020  rillig make(1): add debug logging for reference counting of CachedDir
 1.226 25-Nov-2020  sjg Add .MAKE.UID and .MAKE.GID
 1.225 25-Nov-2020  sjg access(2) does not work for root, so skip objdir-writable
 1.224 24-Nov-2020  rillig make(1): add test for bug in error handling of .BEGIN in -k mode
 1.223 24-Nov-2020  rillig make(1): add test for error in dependency of .END node in -k mode
 1.222 24-Nov-2020  rillig make(1): add test for missing "Stop" after error in .END
 1.221 23-Nov-2020  rillig make(1): make output of test opt-debug-graph1 consistent

The output from the directory cache made the regular NetBSD build fail
because the pathname to the working directory differs, thus affecting
the spacing.

This time, document why the directory cache needs to be excluded from
the output.
 1.220 23-Nov-2020  rillig make(1): test that .PHONY targets are not resolved using suffix rules
 1.219 22-Nov-2020  rillig make(1): add test for debug output from transformation rules
 1.218 22-Nov-2020  rillig make(1): add another unit test for suffix handling
 1.217 22-Nov-2020  rillig make(1): document the selection of the main target
 1.216 22-Nov-2020  rillig make(1): make configuration of export tests simpler

The configuration section of unit-tests/Makefile is already complicated
enough to read, due to the excessive use of regular expressions.
Therefore, to keep the structuring elements at a minimum, inline the
.for loop.
 1.215 22-Nov-2020  rillig make(1): add more output to test for -dg1

Previously, the variables section had been omitted. This was because
the variables had been output in hashcode order until 2020-10-18, and
because some of the variable values are specific to the test environment
or the individual run (MACHINE_ARCH, MAKE.PPID).
 1.214 21-Nov-2020  rillig make(1): capture more output from test deptgt-suffixes

This will have an effect with the next commit.
 1.213 21-Nov-2020  rillig make(1): limit memory usage in tests

There is a suspicious condition in SuffUpdateTarget code that looks wrong
on the first sight. When removing it though, make allocates huge amounts
of memory. To stop freezing the whole machine in this situation, limit
the total memory.

The limit of 200000 has been determined experimentally on NetBSD 8.0
x86_64. With a limit of 100000, make wouldn't even start. 100 MB of
memory is really a lot for such a simple program that according to top(1)
only needs 8 MB. But 200 MB is still better than 5 GB.

Since the Makefile is used on other platforms as well, via the bmake
distribution, and since every operating system has its own list of ulimit
options, make this configurable.
 1.212 21-Nov-2020  rillig make(1): add test for incomplete transformation rule
 1.211 19-Nov-2020  rillig make(1): fix test opt-debug-jobs for native shell

Even after substituting the actual shell name with <shell>, the trailing
optional -q option needs to be normalized.
 1.210 19-Nov-2020  rillig make(1): fix test opt-debug-jobs when compiled with dash as shell

make USER_CPPFLAGS=-DDEFSHELL_CUSTOM='\"/usr/pkg/bin/dash\"'
 1.209 19-Nov-2020  rillig make(1): remove redundant postprocessing for test var-op-shell

The regular expression from the previous line already matches everything
that the removed line could ever match.
 1.208 19-Nov-2020  rillig make(1): remove postprocessing for test directive-export-gmake

Since revision 1.3, directive-export-gmake.mk takes care of handling this
case. Removing the "error" lines from the output of the tests only makes
the test harder to understand and may also hide future bugs.
 1.207 18-Nov-2020  sjg Cleanup - colliding fixes for same issue
 1.206 18-Nov-2020  sjg Some tests need help with dash
 1.205 17-Nov-2020  rillig make(1): make test vardebug independent from the shell
 1.204 17-Nov-2020  rillig make(1): fix test output of var-op-shell for dash

Dash is helpful and outputs the line number in case of an error. The
other shells don't do this. Accept both variants.
 1.203 16-Nov-2020  rillig make(1): add test for self-referencing suffix rule

Just to ensure that make doesn't run into an endless loop.
 1.202 15-Nov-2020  rillig make(1): fix typo in test for variable with empty name
 1.201 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.200 14-Nov-2020  rillig make(1): use progname instead of hard-coded 'make' in warning

This only affects the warning that chdir to objdir failed. In sub-makes
the progname includes the [n], allowing to narrow down the actual cause
of the problem.
 1.199 14-Nov-2020  rillig make(1): add test for the -t option in jobs mode
 1.198 12-Nov-2020  sjg Pass a writable flag to Main_SetObjdir to control writable check

For curdir and an explicit .OBJDIR target, we allow for
the directory to be read-only.
During InitObjdir we otherwise default to requiring objdir to be
writable - this can be controlled by env variable
MAKE_OBJDIR_CHECK_WRITABLE

Add unit-tests/objdir-writable

Reviewed by: christos rillig
 1.197 10-Nov-2020  rillig make(1): add more tests for parsing .if directives

The details of parsing are quite tricky and not documented in the manual
page. Record the current behavior to be a little safer in future
refactorings.
 1.196 10-Nov-2020  rillig make(1): add test for the obsolete variable VPATH
 1.195 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.194 09-Nov-2020  rillig make(1): move test for != assignments to var-op-shell
 1.193 09-Nov-2020  sjg Control TZ for depsrc-optional
 1.192 08-Nov-2020  rillig make(1): in lint mode, only allow '&&' and '||', not '&' and '|'

These variants of the condition operators are neither documented in the
manual page nor are they used in practice.
 1.191 08-Nov-2020  rillig make(1): add test for expanding variable expressions
 1.190 07-Nov-2020  rillig make(1): add test for OP_SUBMAKE
 1.189 07-Nov-2020  rillig make(1): add test for job command flags
 1.188 04-Nov-2020  rillig make(1): add test for undefined variables in command line arguments

The variable discardUndefined has an implicit negation in its name,
which makes it hard to understand. Plus, most of the time it is true.
It's better to have a flag that is false most of the time and has a
positive name.

On the first attempt of inverting that variable, I stumbled upon
MainParseArgs, which initially leaves discardUndefined == FALSE, and
after handling the dashed options, sets it to TRUE. This would make a
difference when more command line arguments would be added later via the
.MAKEFLAGS special target.

Upon further inspection, the only place where discardUndefined is used
is in VarAssign_EvalSubst in parse.c, and that place is not reachable
from any of the dashed options. Therefore, discardUndefined could
already be set at the very beginning of MainParseArgs or even when
initializing the global variable itself, without any observable
difference.

Not even the ::= variable modifier could do anything about this since it
is not reachable from the dashed command line options as well, and in
addition, it expands its right-hand side in any case, always discarding
undefined variables. Oh, these little inconsistencies everywhere.
 1.187 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.186 02-Nov-2020  rillig make(1): remove obsolete POSTPROC.varname from unit tests

It was not needed anymore since 2020-10-18.
 1.185 02-Nov-2020  rillig make(1): add test for parse errors in commands in lint mode (-dL)

The difference to non-lint mode is that the exit status is now 2 instead
of 0.
 1.184 02-Nov-2020  rillig make(1): remove debugging code from sync-mi
 1.183 02-Nov-2020  rillig make(1): add test for parse errors in shell commands, compat mode
 1.182 02-Nov-2020  rillig make(1): handle errors when sync-mi fails because of a syntax error
 1.181 01-Nov-2020  rillig make(1): move test flags to test varmod-match-escape.mk
 1.180 31-Oct-2020  rillig make(1): add more tests for the variable modifier :localtime
 1.179 31-Oct-2020  rillig make(1): add test for recursive variable expressions
 1.178 31-Oct-2020  rillig make(1): merge the SysV modifier tests into varmod-sysv
 1.177 30-Oct-2020  rillig make(1): move test flags for varname-dot-shell to the test itself
 1.176 29-Oct-2020  rillig make(1): move MAKEFLAGS handling in vardebug test to the test itself
 1.175 24-Oct-2020  rillig make(1): add test for looking up suffixes
 1.174 23-Oct-2020  rillig make(1): add test for dependencies of the form '%.o: %.c'
 1.173 23-Oct-2020  rillig make(1): add test case in which .BEGIN depends on .END

Just for fun.
 1.172 23-Oct-2020  rillig make(1): add test for the '::' dependency operator
 1.171 23-Oct-2020  rillig make(1): move tests from cond2.mk to varmod-ifelse.mk (fixup)
 1.170 23-Oct-2020  rillig make(1): add test for .ERROR_CMD in jobs mode
 1.169 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.168 18-Oct-2020  sjg In meta mode we do not have to re-run all tests when Makefile is touched
 1.167 18-Oct-2020  rillig make(1): add test for turning a target into a transformation
 1.166 17-Oct-2020  rillig make(1): document why the ampersand is not listed in export.exp
 1.165 10-Oct-2020  sjg Limit output of export tests to POSIX compatible env vars
 1.164 08-Oct-2020  rillig make(1): remove test misc.mk from Makefile
 1.163 08-Oct-2020  rillig make(1): fix test opt-debug-jobs on non-native platforms
 1.162 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.161 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.160 04-Oct-2020  rillig make(1): add tests for parsing assignments, especially :sh

Luckily nobody uses the :sh variable assignment modifier since its
syntactical variant != is simpler.
 1.159 03-Oct-2020  rillig make(1): add test demonstrating the Towers of Hanoi puzzle

It's not the primary task of make to handle procedure calls with
parameters, combined with lexical scoping, therefore the code does not
look as straight-forward or clean as in other programming languages. It
feels more like squeezing a programming problem from the imperative
world into the world of declarative dependencies.

A more idiomatic way of implementing this puzzle should be as a
dependency graph since that's both the natural structure of the puzzle
and the primary domain of make. Something like having a main target
"hanoi-5" that depends on intermediate targets of the form
"move-1.2.3.4.5-_._._._._-_._._._._", each representing a single
configuration of the stacks. These targets could be generated
dynamically. A benefit of this implementation would be that the puzzle
could be resumed from an arbitrary configuration, just just from the
initial configuration.
 1.158 03-Oct-2020  rillig make(1): add tests for the various supported shells
 1.157 03-Oct-2020  rillig make(1): add test for the -dj debug option
 1.156 02-Oct-2020  rillig make(1): add tests for parsing and exporting variables

Once again, there are a few surprises deeply hidden inside the edge
cases.
 1.155 29-Sep-2020  rillig make(1): fix test job-output-long-lines

The test failed on Linux since the test relied on the two child
processes interleaving each other. This is not guaranteed to happen
though.
 1.154 27-Sep-2020  rillig make(1): add test for merging long lines of job output
 1.153 27-Sep-2020  rillig make(1): run tests with jemalloc debugging enabled

This protects against very simple memory allocation bugs such as
migrating Lst_ForEachUntil to Lst_ForEach without remembering that
Lst_ForEachUntil can handle the situation where the current list node is
removed from the list, but Lst_ForEach cannot. This happens in
Make_ExpandUse, for example.
 1.152 25-Sep-2020  rillig make(1): add test for harmless bug in Parse_File

When there is a dependency group at the end of a top-level makefile,
this dependency group is not finished properly. This allows to add
further commands to the targets of this dependency group, which was not
intended.
 1.151 25-Sep-2020  rillig make(1): add test for make() function in conditions
 1.150 25-Sep-2020  rillig make(1): add test for deleting the suffixes during parsing
 1.149 25-Sep-2020  rillig make(1): add test for partial expansion of undefined variables
 1.148 23-Sep-2020  rillig make(1): remove debug output from counter tests

Now that the tests work as intended, the debug information is no longer
necessary. It was only intended to track down the cause of the
unexpected behavior.
 1.147 23-Sep-2020  rillig make(1): add variant of the counter test

I had expected that using the ::+= modifier instead of the ::= modifier
would work, since the assignment modifier for COUNTER no longer contains
a reference to itself. But instead of ending up at 4, the counter even
goes up to 6.
 1.146 23-Sep-2020  rillig make(1): fix assertion failure in -j mode with .END node

There had been two separate global variables for the .END node, and in
parallel mode, only the one in jobs.c was initialized.

The code in JobRun heads over to Compat_Make without calling Compat_Run
first, which left the variable ENDNode uninitialized.
 1.145 21-Sep-2020  rillig make(1): run tests with absolute filenames as well

The tests varname-dot-parsedir and varname-dot-parsefile had been broken
before if they were run with the "-f $PWD/$test.mk" option. This way of
running the tests is used by FreeBSD.
 1.144 21-Sep-2020  rillig make(1): fix tests for .PARSEDIR/.PARSEFILE

The output of these tests previously depended upon whether the test
makefile was specified as relative or as absolute path. In NetBSD, it
is specified as relative path, in FreeBSD as absolute path.

Adjust the expected output to hide this difference; in the .rawout files
it is still visible.
 1.143 15-Sep-2020  rillig make(1): move flags for lint test into the test itself
 1.142 14-Sep-2020  rillig make(1): add test for undefined expressions in conditions in lint mode
 1.141 14-Sep-2020  rillig make(1): add tests for numbers in conditions
 1.140 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.139 13-Sep-2020  rillig make(1): fix sync-mi helper target, at least for adding tests
 1.138 07-Sep-2020  rillig make(1): explain why each test is run in a sub-make
 1.137 07-Sep-2020  rillig make(1): use consistent spelling for postprocessing
 1.136 05-Sep-2020  rillig make(1): add test for intentional hash collision for variable names

Hash collisions may slow down make in certain special situations. There
is no point though in maliciously triggering such a situation since
anyone who can inject values into makefiles can easily run shell
commands using the :!cmd! modifier or similar mechanisms. Crafting
variable names just to slow down make is thus not an attack vector.
 1.135 05-Sep-2020  rillig make(1): move test for -dg1 from opt-debug-g1 to opt-debug-graph1
 1.134 05-Sep-2020  rillig make(1): add tests for each debug option
 1.133 04-Sep-2020  rillig make(1): re-enable the archive test

The test had failed in the releng build because it assumed it were run
with .CURDIR == .PARSEDIR. This assumption is true when the tests are
run directly from usr.bin/make, but not when they are run from
tests/usr.bin/make.
 1.132 04-Sep-2020  rillig make(1): add test for the special variable MAKEFILE
 1.131 04-Sep-2020  rillig make(1): extend tests for the :hash variable modifier

The previous test vectors didn't contain any hash with a leading zero.
This could have been a simple programming mistake by using %8x instead
of the intended %08x. Using snprintf wouldn't have been possible anyway
since the hex digits are printed in little-endian order, but without
reversing the bits of each digit. Kind of unusual, but doesn't affect
the distribution of the hashes.
 1.130 02-Sep-2020  rillig make(1): add test for the .for directive

For a long time, I had assumed that the iteration variables of a .for
loop are just normal global variables. This assumption was wrong but
didn't have any consequences.

The iteration variables of a .for loop can just be accessed like global
variables, therefore it is not obvious that they are implemented in a
completely different way.

There are some edge cases in conditions used inside .for loops, in which
the iteration variables cannot be used like normal variables. An
example is brought up in https://gnats.netbsd.org/47888, which observes
that the defined() and empty() functions in conditions only work with
variables but ignore the iteration "variables", simply because these are
not variables but only expressions.
 1.129 29-Aug-2020  rillig make(1): fix sh-dots test

The exact output depends on the shell. Some shells prefix the error
message with their name, some don't.
 1.128 29-Aug-2020  rillig make(1): add test for the .ifmake directive
 1.127 29-Aug-2020  rillig make(1): add tests for .else and .for + .endif
 1.126 29-Aug-2020  rillig make(1): fix assertion failure for .SUFFIXES in archives

This occurred in the posix1.mk test, even though it is disabled in
unit-tests. But in tests/usr.bin/make it still runs. There, it should
have produced an "expected failure" but crashed instead.

The archive-suffix test is the stripped-down version of the posix1 test.
 1.125 29-Aug-2020  rillig make(1): fix test opt-debug-g1

Including the directory cache made the test output fragile.
 1.124 28-Aug-2020  rillig make(1): add test for interrupting a command
 1.123 28-Aug-2020  rillig make(1): add test for the undocumented .NULL special dependency target
 1.122 28-Aug-2020  rillig make(1): add tests for the special .INCLUDES and .LIBS variables
 1.121 28-Aug-2020  rillig make(1): disable the sync-mi convenience target
 1.120 27-Aug-2020  rillig make(1): add test for the -dg1 option
 1.119 23-Aug-2020  rillig make(1): add test for + commands with the -n command line option
 1.118 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.117 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.116 23-Aug-2020  rillig make(1): fix assertion failure in debug output for read-only variables
 1.115 23-Aug-2020  rillig make(1): add test for the newly added .SHELL variable
 1.114 22-Aug-2020  rillig make(1): add test for expanding wildcards in directories

This test covers DirExpandInt.
 1.113 22-Aug-2020  sjg bash says 'command not found'
 1.112 22-Aug-2020  rillig make(1): try to set the variable named "" using the command line

Before 2020-08-22, the command line argument '=cmline-plain' triggered
undefined behavior, just like the assignment '=assigned' in the Makefile.
 1.111 22-Aug-2020  sjg Use TEST_MAKE to run unit-tests

This lets us take advantage of new features like ${.SHELL}
 1.110 22-Aug-2020  rillig make(1): add test for assigning to the variable named ""

This has been possible at least since 2013, probably much longer.
 1.109 22-Aug-2020  rillig make(1): add test for deferred variable expansion in dependencies
 1.108 22-Aug-2020  sjg Supress /bin/sh: in error for sh-dots
 1.107 22-Aug-2020  rillig make(1): add test for "no target to make"
 1.106 22-Aug-2020  rillig make(1): add test for the special "..." in shell commands
 1.105 22-Aug-2020  rillig make(1): add test for combining :: and .USEBEFORE
 1.104 20-Aug-2020  rillig make(1): enable debug logging for archive test

This test succeeds locally on NetBSD 8.0 but not in the official test
runs on https://releng.netbsd.org/test-results.html. To see the
difference, run the test with full debug information.

This test is commented out in usr.bin/make/unit-tests/Makefile, but that
doesn't stop tests/usr.bin/make/t_make.sh from running it nevertheless,
since over there, all *.mk files are considered tests, be they commented
out or not.
 1.103 20-Aug-2020  rillig make(1): add test for parsing functions in .if conditions
 1.102 19-Aug-2020  rillig make(1): add test for the -n option
 1.101 19-Aug-2020  rillig make(1): add test for the -q option
 1.100 16-Aug-2020  rillig make(1): move tests for the :Ox modifier into separate file

The test has been extended by ensuring that the shuffled words are still
the same. Comparing two shuffled lists is probabilistic, but comparing
their sorted results is not, therefore that's completely sensible to do.

When writing this test, by coincidence I discovered how to generate the
"Undefined variable" error message. Unfortunately, the error message is
wrong since the variable NUMBERS is defined at that point. In summary,
that error message is shown when it shouldn't, and when it should it is
not shown. Still, I'm glad that I finally found it.
 1.99 16-Aug-2020  rillig make(1): move tests for the :M modifier into separate files

The test for the different escaping has been adjusted to actually show
the different parsing results in the test output. To do this, it had to
get its own file since it needs the -dv debug flag and specialized
post-processing.
 1.98 16-Aug-2020  rillig make(1): run tests in an almost empty, controlled environment

Several of the tests use simple variable names that might be influenced
by environment variables of the same name. Especially the tests for the
?= variable assignment operator need an empty environment to start with,
to produce reliable results.

The PATH must be in the base environment since several tests depend on
the usual tools like echo(1), sleep(1), grep(1). Setting the PATH to a
fixed value would have made it impossible to run the tests in a custom
environment that don't have a /bin directory. It's the user's
responsibility to provide a sane PATH.
 1.97 16-Aug-2020  rillig make(1): force all tests to be run with the -r flag

Without that flag, <sys.mk> is loaded before the tests. The tests are
not intended to either use or even test these rules and definitions,
therefore it is safe to omit this command line option.

If there should ever be tests for POSIX-conformance that need the
builtin rules and definitions, these tests can still ".include <sys.mk>"
at the beginning and be done with it, since the -m command line option
is not touched. The system-default rules and definitions are still
available, they are just not active by default.

Suggested by sjg.
 1.96 16-Aug-2020  rillig make(1): use consistent formatting for running the tests

With the many newly added tests, having two messages ("testing xzy" and
"postprocessing xyz") made the output too noisy since the words were not
aligned nicely. Use the same formatting as for MAKEVERBOSE=0, and
remove the message for postprocessing. If there should ever be problems
during postprocessing, it's trivial to run "../make TESTS=bad-test -dl"
to find out where the problem is.
 1.95 16-Aug-2020  rillig make(1): clean up cleaning of test files

The variables CLEANFILES and CLEANDIRS are not supposed to be
user-settable, thus use a simple "=" instead of "+=".

Since CLEANDIRS is always set, there is no point in making the rm
conditional.
 1.94 16-Aug-2020  rillig make(1): move tests for :S, :C, :@ from modmisc to their separate tests
 1.93 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.92 15-Aug-2020  rillig make(1): fix archive test

Even though it is commented out in this Makefile, it is still run by
atf, on purpose. This test is broken on FreeBSD, but on NetBSD it
should still be run.

Without removing the archive first, it could be left over from a
previous test failure and thus be newer than all its members, leading to
${.OODATE} being empty.
 1.91 09-Aug-2020  rillig make(1): add test for .USE combined with inference rule without commands

Discovered by christos.
 1.90 09-Aug-2020  rillig make(1): add test for non-obvious .MAKE.EXPORTED edge case
 1.89 07-Aug-2020  rillig make(1): add test for exporting variables
 1.88 07-Aug-2020  rillig make(1): document why the suffixes test must stay disabled
 1.87 07-Aug-2020  rillig make(1): enable test phony-end

This at least documents the actual behavior. Not sure what the expected
behavior is and why.
 1.86 07-Aug-2020  rillig make(1): enable test for .IMPSRC

Having this test disabled was very confusing since its content didn't
match the actual behavior, and this also differs from the GNU make
behavior.
 1.85 06-Aug-2020  sjg Use -r for recursive
 1.84 06-Aug-2020  rillig make(1): add test for unintended "recursive variable" in -dL mode
 1.83 03-Aug-2020  rillig make(1): in lint mode, disallow dynamic variable names in :@ modifier

This is an extremely obscure feature that hopefully nobody ever
considered using.
 1.82 02-Aug-2020  rillig make(1): set more predictable environment for counter test

Having an environment variable or a global variable called "C" would
change the debug output since an existing variable is not set to the
empty value first. See parse.c, keyword "!Var_Exists".
 1.81 02-Aug-2020  rillig make(1): add test for nested VAR_SUBST assignments
 1.80 01-Aug-2020  rillig make(1): fix error message when regcomp fails

If regcomp fails, it's not the regex substitution that is erroneous, but
the regex compilation.
 1.79 01-Aug-2020  rillig make(1): improve output grouping in varmod-edge test

The generated error messages are now closer to the test cases that
produce them. To keep the expected output stable, the line numbers are
omitted from the .info directives.
 1.78 31-Jul-2020  rillig make(1): automate adding or removing test files
 1.77 31-Jul-2020  rillig make(1): add test for braces in dependency lines

The comment at DirExpandCurly says something about "recursively", but the
nested braces don't work.

The manual page only mentions that "{} may be used", but it keeps quiet
about the exact meaning and also doesn't mention any nesting.
 1.76 29-Jul-2020  rillig make(1): add enough tests to cover the ApplyModifier functions

Only a few return statements are still missing from the code coverage.

In ApplyModifier_Assign, the test for an empty variable name is skipped
for now since it segfaults.

In ApplyModifier_SysV after the second ParseModifierPart, the branch for
the missing delimiter is not reached since this case is already checked
for in the first part of the function. To trigger this branch, a
specially crafted, unrealistic string needs to be created, and that's too
complicated for the moment.
 1.75 28-Jul-2020  rillig make(1): add test for setting .OBJDIR via the command line
 1.74 28-Jul-2020  sjg Use cat if no POSTPROC.${.TARGET:R}

On Linux sed with no flags throws an error.
 1.73 28-Jul-2020  sjg Ensure .CURDIR is correct for tests that run sub-makes
 1.72 28-Jul-2020  rillig make(1): disable archive test

On FreeBSD, running the archive.mk test results in "create-archive is up
to date" and similar messages. The situation is unclear, and the
archive code seems to be practically unused. Furthermore the archive
test doesn't ensure that it is run in ${.PARSEDIR}, so it needs a bit
more work.
 1.71 28-Jul-2020  sjg Use -r for export.mk to minimize interference
 1.70 27-Jul-2020  rillig make(1): add tests for parsing directives like .if and .info
 1.69 27-Jul-2020  rillig make(1): prepare test for .export to show all exported variables

Currently the unit tests don't cover exporting of local variables like
.TARGET or @. To see the effects, all exported variables must be listed
by the tests.
 1.68 27-Jul-2020  rillig make(1): sort flags for test cases alphabetically
 1.67 27-Jul-2020  rillig make(1): add very basic test for archive handling

The whole code in arch.c had been uncovered by tests before.

The code coverage shows that neither the archive name nor the member
contain any $, even though archive.mk looks like it. It could be
necessary to place the variable assignments below the dependency line,
to force late evaluation.
 1.66 26-Jul-2020  rillig make(1): add test for off-by-one error in Var_Parse
 1.65 26-Jul-2020  rillig make(1): add test for appending and exporting a variable
 1.64 25-Jul-2020  rillig make(1): add tests for previously uncovered code
 1.63 09-Jul-2020  sjg Fix typo
 1.62 04-Jul-2020  rillig make(1): ignore system-specific error message from regcomp in test

NetBSD 8 has: repetition-operator operand invalid
Ubuntu has: Invalid preceding regular expression
 1.61 04-Jul-2020  rillig make(1): add post-processing for tests

By defining SED_CMDS.${test}, a test can do additional post-processing
on its output, for example to normalize paths or error messages.

The Makefile for the tests now follows the common style to have all
relevant definitions at the top of the file, and all the implementation
details at the bottom.

By using the += instead of backslashed lists, it becomes easier to
comment out a single test, either temporarily or permanently (such as
the POSIX tests).

The :C modifier has been replaced with the simpler :S, some :S modifiers
have been replaced with simpler := modifiers.

The postprocessing commands have been extracted from the actual command.
This makes editing and commenting them easier.
 1.60 04-Jul-2020  rillig make(1): improve documentation about adding new tests
 1.59 28-Jun-2020  rillig make(1): demonstrate bug when evaluating conditions
 1.58 17-May-2020  rillig usr.bin/make: demonstrate actual behavior of .INCLUDEDFROMFILE
 1.57 10-May-2020  rillig usr.bin/make: sort test cases alphabetically
 1.56 10-May-2020  rillig usr.bin/make: add tests for surprising dollar removal
 1.55 29-Apr-2020  rillig usr.bin/make: add test case for lazy conditions
 1.54 30-Nov-2019  rillig Add unit tests for variable modifiers like :M and :N
 1.53 24-May-2018  christos branches: 1.53.2;
unit test for $ underquoting in :Q modifier
 1.52 05-May-2015  sjg branches: 1.52.8; 1.52.14;
When evaluating condtionals from .if we want to require
that the lhs is a variable reference, a number or a quoted string.
This helps avoid subtle bugs caused by typos.

When conditionals are being evaluated during variable expansion
we cannot be as strict becuase lhs will already have been expanded.

We therefor pass a boolean to Cond_EvalExpression to tell it how
lhs should be treated.

Add unit-tests/cond2.mk to test the above

Reviewed by: christos, joerg
 1.51 20-Oct-2014  sjg Extract broken tests
 1.50 29-Aug-2014  sjg *.rawout are out-of-date if ${TEST_MAKE} is newer.
 1.49 29-Aug-2014  sjg posix1.mk and suffixes.mk need to cleanup in order to achieve
repeatable results.
posix1.mk's lib.a target still looks dubious.
 1.48 24-Aug-2014  apb Let "make clean" delete the files and dirs created by some of the tests.
 1.47 24-Aug-2014  apb Add tests for backslash escaping in make(1).

Many of these tests fail, and I have populated the escape.exp file with
the results that I expect, not with the results that make(1) actually
produces.

Also update the set lists for these tests.
 1.46 23-Aug-2014  christos Instead of adding the test in 48095 I added the tests in 48096. Add the
missing test now.
 1.45 23-Aug-2014  christos Convert test in PR/49085
 1.44 21-Aug-2014  apb Add a .PATH, so you can be in any other directory and run
"make -f /path/to/this/Makefile sometest.out"
and have it create sometest.out in your current directory.
 1.43 21-Aug-2014  apb Add varmisc.mk, for miscellaneous variable tests.

For now, the only test is copied from
src/tests/usr.bin/make/d_unmatchedvarparen.mk. This was
the only test in src/tests/usr.bin/make that was not also in
src/usr.bin/make/unit-tests.

XXX: src/tests/usr.bin/mk should be changed to reach over to
src/usr.bin/make/unit-tests, instead of keeping out of date copies
of the tests.
 1.42 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.41 21-Aug-2014  apb Stricter sed expression for matching an optional PID in square brackets.
 1.40 21-Aug-2014  apb When sanitising test output, replace "${TEST_MAKE}" with "make".
This string may appear in error messages that end up in the output.
 1.39 20-Aug-2014  apb Add tests for VAR != command.
 1.38 28-Aug-2013  sjg Fix parsing of SUNSHCMD style :sh = assigments.

Submitted by: Will Andrews at freebsd.org
 1.37 16-Jul-2013  sjg Fix unit-tests to cope with recent change to progname
 1.36 22-Mar-2013  sjg Add unit-test for export-env and gmake export
 1.35 09-Nov-2012  sjg Add a unit-test for .ORDER
 1.34 19-Jun-2012  sjg branches: 1.34.2;
Add unit-tests for .for
 1.33 29-Sep-2011  sjg branches: 1.33.2;
Make sure .PHONY targets get .TARGET set.
This wasn't happening when a dependency of .END.
Set .PREFIX too and add a unit-test.

PR: 43534
 1.32 07-Apr-2011  joerg Add the :hash modifier to compute a 32bit hash of an variable.
This uses MurmurHash3 to get a reasonable collission-free hash with
small code. The result is endian neutral.
 1.31 06-Mar-2011  sjg Add unit tests to check that exists(some/dir/) works

Also fix handling of sysV substitutions when lhs and variable are empty.

Also that modifiers do not cause errors during conditional tests
when undefined variables should otherwise be ok.
Ie. .if defined(nosuch) && ${nosuch:Mx} != ""
 1.30 10-Dec-2010  sjg fix style
 1.29 10-Dec-2010  sjg Need to export LC_ALL=C too
 1.28 22-Apr-2010  sjg Force LANG=C to ensure sort(1) behaves as expected
 1.27 22-Apr-2010  sjg PR: 42850
Reviewed by:

modmisc: since we apply an exists() test to $paths, be conservative
in what we expect.

Run the unit tests with -r -m / so that we do not fail if there
is no sys.mk present.
 1.26 08-Apr-2010  sjg Process .ERROR the same as .BEGIN, .END etc
so that it cannot be the default target.
Add unit-tests for .info - .error, and .ERROR.
 1.25 19-Nov-2009  sjg Add .unexport - the exact opposite of .export
and .unexport-env which unexport's all previously .export'd globals
as well as clearing environ[].
Allow's sys.mk near total controll.

Reviewed by: apb
 1.24 07-Oct-2009  sjg The parser used to break dependency lines at ';' without regard
for substitution patterns. This (perhaps coupled with the
new handling of .for variables in ${:U<value>...) caused interesting
results for lines like:

.for file in ${LIST}
for-subst: ${file:S;^;${here}/;g}

add a unit-test to keep an eye on this.
 1.23 25-Oct-2008  apb Use ${TOOL_SED} instead if plain sed in Makefiles.
 1.22 31-Mar-2008  sjg If the name passed to Var_Exists contains '$' run it through Var_Subst.
 1.21 05-Oct-2007  sjg Add the ability to .export variables to the environment.
 1.20 11-May-2006  sjg branches: 1.20.12;
Extract the variable modifier logic to a separate function.
This cuts Var_Parse in half! and allows the modifier logic to
be used recursively - when getting modifiers via variables.

Add new unit-test, to check that certain error cases are handled
correctly.
 1.19 26-Feb-2006  apb Make ".WAIT" apply recursively to all children of nodes on the right
hand side of the .WAIT, except when the recursive interpretation would
cause a cycle in the dependency graph.

Discussed in tech-toolchain. Reviewed by christos, sjg.
 1.18 26-Feb-2006  sjg Update man page and add test case for specifying modifiers via variable.
Also allow said variable to appear anywhere in the modifier list.
 1.17 13-Feb-2006  apb Escape dots in sed regexps. Without this patch, and without
an OBJDIR, "make test" in usr.bin/make fails.
 1.16 15-Jun-2005  rpaulo Add a unit-test for comments.
Addition to PR bin/17732.
Approved by sjg and christos.
 1.15 01-Jun-2005  sjg Add :Ox for random ordering, based on patch from
Mike M. Volokhov <mishka@apk.od.ua>
 1.14 30-Jun-2004  jmc branches: 1.14.2;
Add missing NetBSD ID tags
 1.13 07-May-2004  sjg Remove use of sh -e when running in compat mode.
Its not posix compliant and serves very little purpose.
With this change compat and jobs modes are consistent wrt how
they treat each line of a script.

Add support for the '+' command line prefix as required by posix.
Lines prefixed with '+' are executed even when -n is given.
[Actually posix says they should also be done for -q and -t]

PR:
Reviewed by: jmc
 1.12 08-Apr-2004  sjg Add check for extraneous .else's - based on patch from Arne H. Juul
in PR/24420.
Add a unit-test for conditionals.
Also in the unit-test makefile strip any .CURDIR in output.

PR: 24420
 1.11 20-Feb-2004  sjg branches: 1.11.2;
Fix :M so that modifiers in nested variables don't terminate parsing
early. Add a unit-test to verify it works and keeps working.
Re-jig the unit-tests so that all are sub makefiles.
 1.10 19-Jan-2004  sjg ternary is .PHONY
 1.9 09-Jan-2004  sjg Add unit test for ternary modifier
 1.8 27-Sep-2003  sjg Implement :[] modifier to allow picking a range of words out of a variable.
Also :tW and a W flag to :C and :S to allow treating value as a single word.
Add unit tests for the above, and fix some corner cases.
Based on patches supplied by Alan Barrett <apb@cequrux.com>
 1.7 08-Aug-2003  sjg Hook make unit-tests into regress
 1.6 01-Aug-2003  sjg Avoid \a as a test of invalid separator, since if we make ksh the default
shell, we get different results. \x seems safe.
 1.5 31-Jul-2003  sjg Test behavior of commandline variable assignments.
 1.4 29-Jul-2003  sjg First bug picked up by the unit tests - delim wasn't always initialized.
Avoid putting '\' in test case script lines since shell's like that on
SunOS insist on interpreting them.
 1.3 29-Jul-2003  sjg Use single quotes to protect everything from shell's that might
alter the results.
 1.2 29-Jul-2003  sjg Regardless of the name of TEST_MAKE, force it to make in test.exp
to avoid needless failures.
 1.1 28-Jul-2003  sjg Fix parsing bug for :ts - patch from Alan Barrett <apb@cequrux.com>
Also add simple unit-test jig (regress/usr.bin/make will use it too)
but having it local here makes inclusion in bmake simpler.
 1.11.2.2 10-May-2004  tron Pull up revision 1.13 (requested by sjg in ticket #282):
Remove use of sh -e when running in compat mode.
Its not posix compliant and serves very little purpose.
With this change compat and jobs modes are consistent wrt how
they treat each line of a script.
Add support for the '+' command line prefix as required by posix.
Lines prefixed with '+' are executed even when -n is given.
[Actually posix says they should also be done for -q and -t]
PR:
Reviewed by: jmc
 1.11.2.1 10-May-2004  tron Pull up revision 1.12 (requested by sjg in ticket #282):
Add check for extraneous .else's - based on patch from Arne H. Juul
in PR/24420.
Add a unit-test for conditionals.
Also in the unit-test makefile strip any .CURDIR in output.
PR: 24420
 1.14.2.3 02-Jul-2005  tron Pull up revision 1.16 (requested by rpaulo in ticket #491):
Add a unit-test for comments.
Addition to PR bin/17732.
Approved by sjg and christos.
 1.14.2.2 16-Jun-2005  tron Backout ticket 458, it causes PR toolchain/30536.
 1.14.2.1 16-Jun-2005  tron Pull up revision 1.16 (requested by rpaulo in ticket #458):
Add a unit-test for comments.
Addition to PR bin/17732.
Approved by sjg and christos.
 1.20.12.1 06-Nov-2007  matt sync with HEAD
 1.33.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.33.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.33.2.1 30-Oct-2012  yamt sync with head
 1.34.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.2.2 23-Jun-2013  tls resync from head
 1.34.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.52.14.1 25-Jun-2018  pgoyette Sync with HEAD
 1.52.8.1 09-Jun-2018  martin Pull up following revision(s) (requested by christos in ticket #870):

sys/lib/libgnuefi/Makefile.inc: revision 1.5
external/mit/xorg/xorg-pkg-ver.mk: revision 1.9
sys/arch/i386/stand/lib/Makefile.inc: revision 1.17
sys/compat/common/Makefile.inc: revision 1.25
usr.bin/make/unit-tests/varquote.exp: revision 1.1, 1.2
sys/lib/libsa/Makefile.inc: revision 1.24
usr.bin/make/var.c: revision 1.220
sys/arch/ia64/stand/efi/libefi/Makefile.inc: revision 1.5
sys/arch/hppa/spmath/Makefile.inc: revision 1.10
usr.bin/make/unit-tests/varquote.mk: revision 1.1, 1.2
usr.bin/make/unit-tests/Makefile: revision 1.53
sys/lib/libkern/Makefile.inc: revision 1.45
sys/arch/acorn32/stand/lib/Makefile.inc: revision 1.4
sys/arch/m68k/fpsp/Makefile.inc: revision 1.21
usr.bin/make/make.1: revision 1.273
sys/lib/libz/Makefile.inc: revision 1.17

- Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@

XXX: pullup 8
 1.53.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.277.2.1 31-May-2021  cjep sync with head
 1.347.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 29-Aug-2020  rillig make(1): fix assertion failure for .SUFFIXES in archives

This occurred in the posix1.mk test, even though it is disabled in
unit-tests. But in tests/usr.bin/make it still runs. There, it should
have produced an "expected failure" but crashed instead.

The archive-suffix test is the stripped-down version of the posix1 test.
 1.3 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.2 07-Nov-2020  rillig make(1): fix references to Var_SetWithFlags in tests
 1.1 29-Aug-2020  rillig make(1): fix assertion failure for .SUFFIXES in archives

This occurred in the posix1.mk test, even though it is disabled in
unit-tests. But in tests/usr.bin/make it still runs. There, it should
have produced an "expected failure" but crashed instead.

The archive-suffix test is the stripped-down version of the posix1 test.
 1.12 12-Jun-2025  rillig make: add program name to stack traces from sub-makes
 1.11 12-Jun-2025  rillig make: add quotes to "in directory" line in stack traces

The other lines in stack traces use quotes as well.
 1.10 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.9 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.8 27-Apr-2024  rillig branches: 1.8.2;
tests/make: test detection of static library files
 1.7 09-Oct-2020  rillig make(1): use consistent order in .OODATE in test archive.mk
 1.6 08-Oct-2020  rillig make(1): make individual targets in test archive.mk visible

This test still fails on FreeBSD, printing the "ar cru, ranlib" lines
twice, and I don't know why.

To get more insights into the inner details, without activating the full
-dA logging, split the output into paragraphs, one per target.

This change reveals another interesting detail: Dependencies without any
commands (in this case create-archive) don't inherit the commands from
.USEBEFORE and .USE sources.
 1.5 04-Sep-2020  rillig make(1): fix expected file for archive test

This test is currently disabled, therefore it didn't fail immediately.
 1.4 23-Aug-2020  rillig make(1): in archive test, use wildcard that matches more than 1 file

This is to make sure that the buffer used for "archive(member)" is
properly reset after each member.
 1.3 23-Aug-2020  rillig make(1): add test for wildcards in archive dependency
 1.2 16-Aug-2020  rillig make(1): fix archive test

At the beginning of that test, the library archive obviously does not
exist yet.

This test failure is a bit hard to detect since the test is disabled in
usr.bin/make, but not in tests/usr.bin/make. This is because the latter
just runs all .mk files as tests, no matter whether they are commented
out or not.
 1.1 27-Jul-2020  rillig make(1): add very basic test for archive handling

The whole code in arch.c had been uncovered by tests before.

The code coverage shows that neither the archive name nor the member
contain any $, even though archive.mk looks like it. It could be
necessary to place the variable assignments below the dependency line,
to force late evaluation.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.14 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.13 27-Apr-2024  rillig branches: 1.13.2;
tests/make: test detection of static library files
 1.12 09-Apr-2021  christos Don't use a shell pattern to copy files, copy them explicitly. When running
as non-root, [at]*.mk matches archive.mk which we already copied. This was
copied as 444 and trying to overwrite it gives EACCES.
 1.11 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.10 09-Oct-2020  rillig make(1): use consistent order in .OODATE in test archive.mk
 1.9 08-Oct-2020  rillig make(1): make individual targets in test archive.mk visible

This test still fails on FreeBSD, printing the "ar cru, ranlib" lines
twice, and I don't know why.

To get more insights into the inner details, without activating the full
-dA logging, split the output into paragraphs, one per target.

This change reveals another interesting detail: Dependencies without any
commands (in this case create-archive) don't inherit the commands from
.USEBEFORE and .USE sources.
 1.8 07-Sep-2020  rillig make(1): fix archive test when .CURDIR != .PARSEDIR
 1.7 05-Sep-2020  rillig make(1): add tests for each debug option
 1.6 04-Sep-2020  rillig make(1): re-enable the archive test

The test had failed in the releng build because it assumed it were run
with .CURDIR == .PARSEDIR. This assumption is true when the tests are
run directly from usr.bin/make, but not when they are run from
tests/usr.bin/make.
 1.5 23-Aug-2020  rillig make(1): in archive test, use wildcard that matches more than 1 file

This is to make sure that the buffer used for "archive(member)" is
properly reset after each member.
 1.4 23-Aug-2020  rillig make(1): add test for wildcards in archive dependency
 1.3 16-Aug-2020  rillig make(1): fix archive test

At the beginning of that test, the library archive obviously does not
exist yet.

This test failure is a bit hard to detect since the test is disabled in
usr.bin/make, but not in tests/usr.bin/make. This is because the latter
just runs all .mk files as tests, no matter whether they are commented
out or not.
 1.2 15-Aug-2020  rillig make(1): fix archive test

Even though it is commented out in this Makefile, it is still run by
atf, on purpose. This test is broken on FreeBSD, but on NetBSD it
should still be run.

Without removing the archive first, it could be left over from a
previous test failure and thus be newer than all its members, leading to
${.OODATE} being empty.
 1.1 27-Jul-2020  rillig make(1): add very basic test for archive handling

The whole code in arch.c had been uncovered by tests before.

The code coverage shows that neither the archive name nor the member
contain any $, even though archive.mk looks like it. It could be
necessary to place the variable assignments below the dependency line,
to force late evaluation.
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 29-Jun-2025  rillig branches: 1.3.4;
make: if a condition is erroneous, skip the whole .if/.endif
 1.2 29-Jun-2025  rillig tests/make: fix expected test output for backslashes

Right before the previous commit, I had removed the "all" target from
the test, as the test had parsing errors, making the "all" target
redundant.
 1.1 29-Jun-2025  rillig tests/make: test backslash at the end of a line and in the :M modifier

As described in PR bin/46139 by David A. Holland.
 1.3.4.2 02-Aug-2025  perseant Sync with HEAD
 1.3.4.1 29-Jun-2025  perseant file char-005c-reverse-solidus.exp was added on branch perseant-exfatfs on 2025-08-02 05:58:30 +0000
 1.2 29-Jun-2025  rillig branches: 1.2.4;
make: if a condition is erroneous, skip the whole .if/.endif
 1.1 29-Jun-2025  rillig tests/make: test backslash at the end of a line and in the :M modifier

As described in PR bin/46139 by David A. Holland.
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 29-Jun-2025  perseant file char-005c-reverse-solidus.mk was added on branch perseant-exfatfs on 2025-08-02 05:58:30 +0000
 1.17 01-Jul-2025  rillig tests/make: detect unintended "expect" lines in the .mk files
 1.16 01-Jul-2025  rillig tests/make: require "expect" comments to start a line

Lua's string.gmatch function doesn't allow the anchor "^"; but its
string.gsub function does.
 1.15 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.14 29-Jun-2025  rillig tests/make: sort missing messages using a stable algorithm

Lua's table.sort does not provide a stable sort. No idea how this could
go unnoticed for two years and a few days.

Noticed in directive-for-escape.mk, which has several diagnostics in the
same location, in the body of .for loops.
 1.13 13-Apr-2025  rillig tests/make: add tests for POSIX mode
 1.12 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.11 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.10 11-Jan-2025  rillig tests/make: force correct order of expected messages
 1.9 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.8 17-Dec-2023  rillig branches: 1.8.2;
tests/make: in 'expect' lines, require the complete text of the line
 1.7 23-Jun-2023  rillig tests/make: sort missing 'expect' comments by their location
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.4 09-May-2023  rillig make: skip syntactically wrong .for loops

When a .for loop cannot be interpreted correctly, for example when there
are no iteration variables or the number of words doesn't match the
iteration variables, skip the body of the .for loop instead of
interpreting it once.
 1.3 15-Apr-2022  rillig tests/make: adjust expectations to actual behavior

The bug in deptgt-silent-jobs.mk has been fixed, the debug logging for
comparing conditions and for deleting global variables has changed
intentionally.
 1.2 29-Jan-2022  rillig tests/make: extend and isolate tests for target-local variables

Reusing the target var-scope-local.o for several tests made the test
more difficult to understand than necessary. The test names '2' and '3'
didn't convey any meaning.

Instead, add more test targets that are named after what they test. Add
tests for each of the 5 variable assignment operators, to demonstrate an
inconsistency between '+=' and '?='.

Add tests for the built-in target-local variables as well and explain
the general concepts, in particular the exact point where target-local
expressions are expanded.

The lines in the expected output file are not generated in the same
order as they appear in the makefile, so allow the 'expect' lines in
non-linear order, in check-expect.lua.
 1.1 15-Jan-2022  rillig tests/make: ensure that the 'expect' comments in tests are correct

Based on tests/usr.bin/xlint/check-expect.lua.

For now, this extra check needs to be run manually.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.18 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.17 13-Jun-2025  rillig make: add on-demand inter-process stack traces

When debugging a build that heavily uses nested calls to sub-makes, the
chain of calls is useful to quickly assess the situation. If explicitly
requested, include the actions from any parent processes in the stack
traces.

Reviewed by: sjg
 1.16 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.15 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.14 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.13 22-Jul-2024  rillig make: fix exit status for error in .BEGIN/.END prerequisite
 1.12 22-Jul-2024  rillig tests/make: demonstrate wrong exit status for .END dependency
 1.11 20-Jul-2024  rillig make: don't run erroneous commands in parallel mode
 1.10 20-Jul-2024  rillig tests/make: demonstrate failing dependency in parallel mode

In parallel mode, when generating the commands for a target, parse or
evaluation errors still continue generating and executing the commands.
And if the commands succeed, the targets that depend on this target are
still made.
 1.9 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.8 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.7 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.6 23-Apr-2024  rillig branches: 1.6.2;
make: clean up comments, code and tests
 1.5 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.4 19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.3 25-Sep-2022  rillig tests/make: reduce trailing whitespace
 1.2 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.1 27-Dec-2020  rillig make(1): add test for expansion errors in jobs mode

Since compat mode and jobs mode are implemented separately and vary in
lots of small details, each of them needs to be tested on its own.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.16 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.15 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.14 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.13 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.12 22-Jul-2024  rillig make: fix exit status for error in .BEGIN/.END prerequisite
 1.11 22-Jul-2024  rillig tests/make: demonstrate wrong exit status for .END dependency
 1.10 20-Jul-2024  rillig make: don't run erroneous commands in parallel mode
 1.9 20-Jul-2024  rillig tests/make: demonstrate failing dependency in parallel mode

In parallel mode, when generating the commands for a target, parse or
evaluation errors still continue generating and executing the commands.
And if the commands succeed, the targets that depend on this target are
still made.
 1.8 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.7 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.6 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.5 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.4 23-Apr-2024  rillig branches: 1.4.2;
make: clean up comments, code and tests
 1.3 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.2 25-Sep-2022  rillig tests/make: reduce trailing whitespace
 1.1 27-Dec-2020  rillig make(1): add test for expansion errors in jobs mode

Since compat mode and jobs mode are implemented separately and vary in
lots of small details, each of them needs to be tested on its own.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.13 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.12 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.11 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.10 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.9 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.8 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.7 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.6 23-Apr-2024  rillig branches: 1.6.2;
make: clean up comments, code and tests
 1.5 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.4 19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.3 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.2 02-Nov-2020  rillig make(1): error out on unclosed expressions after the colon
 1.1 02-Nov-2020  rillig make(1): add test for parse errors in commands in lint mode (-dL)

The difference to non-lint mode is that the exit status is now 2 instead
of 0.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.7 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.6 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.5 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.4 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.3 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.2 23-Apr-2024  rillig branches: 1.2.2;
make: clean up comments, code and tests
 1.1 02-Nov-2020  rillig make(1): add test for parse errors in commands in lint mode (-dL)

The difference to non-lint mode is that the exit status is now 2 instead
of 0.
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.17 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.16 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.15 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.14 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.13 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.12 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.11 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.10 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.9 23-Apr-2024  rillig branches: 1.9.2;
make: clean up comments, code and tests
 1.8 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.7 19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.6 25-Sep-2022  rillig tests/make: reduce trailing whitespace
 1.5 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.4 09-Nov-2020  rillig make(1): add test that parsing continues after a parse error
 1.3 02-Nov-2020  rillig make(1): error out on unclosed expressions after the colon
 1.2 02-Nov-2020  rillig make(1): add test for unclosed variable after a colon
 1.1 02-Nov-2020  rillig make(1): add test for parse errors in shell commands, compat mode
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.13 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.12 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.11 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.10 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.9 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.8 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.7 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.6 23-Apr-2024  rillig branches: 1.6.2;
make: clean up comments, code and tests
 1.5 25-Sep-2022  rillig tests/make: reduce trailing whitespace
 1.4 27-Dec-2020  rillig make(1): add test for expansion errors in jobs mode

Since compat mode and jobs mode are implemented separately and vary in
lots of small details, each of them needs to be tested on its own.
 1.3 09-Nov-2020  rillig make(1): add test that parsing continues after a parse error
 1.2 02-Nov-2020  rillig make(1): add test for unclosed variable after a colon
 1.1 02-Nov-2020  rillig make(1): add test for parse errors in shell commands, compat mode
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 13-Jul-2024  rillig tests/make: demonstrate interrupting make in compat mode
 1.3 18-Mar-2023  sjg branches: 1.3.2;
make: handle .PHONY consitently on interrupt

JobDeleteTarget skips .PHONY targets
CompatDeleteTarget should do the same

This addresses https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269663
 1.2 28-Aug-2020  rillig make(1): fix test for interrupted command execution

In the first version of this test, I had completely misunderstood the
whole topic.

To test the interrupt, the make process has to be interrupted, not the
shell. This generates the correct message that the target is removed.

The filename for .PHONY targets is removed even though .PHONY targets
usually don't correspond to a file. The message is only printed if
there actually is a corresponding file. That's why this message does
not appear when interrupting "make clean".

Finally, since files get created and removed during a single run of
make, the file cache needs to be disabled. This is done by prefixing
the filenames with "././", see Dir_FindFile.
 1.1 28-Aug-2020  rillig make(1): add test for interrupting a command
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 13-Jul-2024  rillig tests/make: demonstrate interrupting make in compat mode
 1.4 18-Mar-2023  sjg branches: 1.4.2;
make: handle .PHONY consitently on interrupt

JobDeleteTarget skips .PHONY targets
CompatDeleteTarget should do the same

This addresses https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269663
 1.3 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.2 28-Aug-2020  rillig make(1): fix test for interrupted command execution

In the first version of this test, I had completely misunderstood the
whole topic.

To test the interrupt, the make process has to be interrupted, not the
shell. This generates the correct message that the target is removed.

The filename for .PHONY targets is removed even though .PHONY targets
usually don't correspond to a file. The message is only printed if
there actually is a corresponding file. That's why this message does
not appear when interrupting "make clean".

Finally, since files get created and removed during a single run of
make, the file cache needs to be disabled. This is done by prefixing
the filenames with "././", see Dir_FindFile.
 1.1 28-Aug-2020  rillig make(1): add test for interrupting a command
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 01-Feb-2021  rillig make: add test for reading from make's stdin

Just out of curiosity whether that really works. It does.
 1.1 01-Feb-2021  rillig make: add test for reading from make's stdin

Just out of curiosity whether that really works. It does.
 1.5 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 01-Jun-2023  rillig branches: 1.3.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 04-Nov-2020  rillig make(1): fix line numbers in test output of cmdline-undefined.mk
 1.1 04-Nov-2020  rillig make(1): add test for undefined variables in command line arguments

The variable discardUndefined has an implicit negation in its name,
which makes it hard to understand. Plus, most of the time it is true.
It's better to have a flag that is false most of the time and has a
positive name.

On the first attempt of inverting that variable, I stumbled upon
MainParseArgs, which initially leaves discardUndefined == FALSE, and
after handling the dashed options, sets it to TRUE. This would make a
difference when more command line arguments would be added later via the
.MAKEFLAGS special target.

Upon further inspection, the only place where discardUndefined is used
is in VarAssign_EvalSubst in parse.c, and that place is not reachable
from any of the dashed options. Therefore, discardUndefined could
already be set at the very beginning of MainParseArgs or even when
initializing the global variable itself, without any observable
difference.

Not even the ::= variable modifier could do anything about this since it
is not reachable from the dashed command line options as well, and in
addition, it expands its right-hand side in any case, always discarding
undefined variables. Oh, these little inconsistencies everywhere.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.5 23-Apr-2024  rillig branches: 1.5.2;
make: clean up comments, code and tests
 1.4 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.3 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 04-Nov-2020  rillig make(1): negate discardUndefined to preserveUndefined
 1.1 04-Nov-2020  rillig make(1): add test for undefined variables in command line arguments

The variable discardUndefined has an implicit negation in its name,
which makes it hard to understand. Plus, most of the time it is true.
It's better to have a flag that is false most of the time and has a
positive name.

On the first attempt of inverting that variable, I stumbled upon
MainParseArgs, which initially leaves discardUndefined == FALSE, and
after handling the dashed options, sets it to TRUE. This would make a
difference when more command line arguments would be added later via the
.MAKEFLAGS special target.

Upon further inspection, the only place where discardUndefined is used
is in VarAssign_EvalSubst in parse.c, and that place is not reachable
from any of the dashed options. Therefore, discardUndefined could
already be set at the very beginning of MainParseArgs or even when
initializing the global variable itself, without any observable
difference.

Not even the ::= variable modifier could do anything about this since it
is not reachable from the dashed command line options as well, and in
addition, it expands its right-hand side in any case, always discarding
undefined variables. Oh, these little inconsistencies everywhere.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 29-Aug-2024  sjg make: unit-tests/cmdline do not remove TMPDIR

When running unit-tests in meta mode, removing TMPDIR while
still in use is fatal. Ensure that TMPBASE used by cmdline.mk
is a subdir of TMPDIR.
 1.4 10-Jun-2022  rillig branches: 1.4.4;
tests/make: demonstrate spaces and '#' in command line arguments
 1.3 09-Feb-2022  rillig tests/make: use more distinctive placeholder for TMPDIR
 1.2 06-Feb-2021  sjg Avoid test failures when more than one user run them.

Use a private TMPDIR
a subdir of .OBJDIR if using it
otherwise /tmp/uid${.MAKE.UID}
 1.1 28-Jul-2020  rillig make(1): add test for setting .OBJDIR via the command line
 1.4.4.1 02-Aug-2025  perseant Sync with HEAD
 1.7 29-Aug-2024  sjg make: unit-tests/cmdline do not remove TMPDIR

When running unit-tests in meta mode, removing TMPDIR while
still in use is fatal. Ensure that TMPBASE used by cmdline.mk
is a subdir of TMPDIR.
 1.6 18-Aug-2024  rillig tests/make: clean up private temporary directory after running tests

Fixes PR bin/58569.
 1.5 23-Apr-2024  rillig branches: 1.5.2;
make: clean up comments, code and tests
 1.4 10-Jun-2022  rillig tests/make: demonstrate spaces and '#' in command line arguments
 1.3 06-Feb-2021  sjg Avoid test failures when more than one user run them.

Use a private TMPDIR
a subdir of .OBJDIR if using it
otherwise /tmp/uid${.MAKE.UID}
 1.2 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.1 28-Jul-2020  rillig make(1): add test for setting .OBJDIR via the command line
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3 11-Jul-2005  sjg Expected results were not updated for comment testing.
 1.2 18-Jun-2005  rpaulo Add a new test case to reflect the problem found on PR toolchain/30536.
Reviewed by sjg and hubertf.
 1.1 15-Jun-2005  rpaulo branches: 1.1.2;
Add a unit-test for comments.
Addition to PR bin/17732.
Approved by sjg and christos.
 1.1.2.6 24-Jul-2005  tron Pull up revision 1.3 (requested by rpaulo in ticket #608):
Expected results were not updated for comment testing.
 1.1.2.5 02-Jul-2005  tron Pull up revision 1.2 (requested by rpaulo in ticket #491):
Add a new test case to reflect the problem found on PR toolchain/30536.
Reviewed by sjg and hubertf.
 1.1.2.4 02-Jul-2005  tron Pull up revision 1.1 (requested by rpaulo in ticket #491):
Add a unit-test for comments.
Addition to PR bin/17732.
Approved by sjg and christos.
 1.1.2.3 16-Jun-2005  tron Backout ticket 458, it causes PR toolchain/30536.
 1.1.2.2 16-Jun-2005  tron Pull up revision 1.1 (requested by rpaulo in ticket #458):
Add a unit-test for comments.
Addition to PR bin/17732.
Approved by sjg and christos.
 1.1.2.1 15-Jun-2005  tron file comment was added on branch netbsd-3 on 2005-06-16 09:34:02 +0000
 1.2 07-Sep-2020  rillig make(1): extend and explain the test for comments
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.7 23-Apr-2024  rillig make: clean up comments, code and tests
 1.6 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.5 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.4 23-Jan-2022  rillig tests/make: migrate modts to varmod-to-separator and explain
 1.3 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.2 07-Sep-2020  rillig make(1): extend and explain the test for comments
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.4 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.3 13-Dec-2020  rillig branches: 1.3.8;
make(1): fix .ERROR_TARGET in compat -k mode (since 2010-04-07)
 1.2 13-Dec-2020  rillig make(1): add tests for variable expansion in .ERROR handling
 1.1 13-Dec-2020  rillig make(1): demonstrate wrong error handling in compat mode
 1.3.8.1 02-Aug-2025  perseant Sync with HEAD
 1.5 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.4 07-May-2022  rillig make: rename Compat_Run to Compat_MakeAll

No functional change.
 1.3 13-Dec-2020  rillig make(1): fix .ERROR_TARGET in compat -k mode (since 2010-04-07)
 1.2 13-Dec-2020  rillig make(1): add tests for variable expansion in .ERROR handling
 1.1 13-Dec-2020  rillig make(1): demonstrate wrong error handling in compat mode
 1.8 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.7 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.6 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.5 01-Jun-2023  rillig branches: 1.5.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 21-Jan-2021  rillig make(1): fix debug output for comparison operators in conditionals

This produces fewer warnings than before, but these were edge cases that
probably didn't matter in practice. The "Malformaed conditional" is
still generated, the set of accepted conditionals is still the same.
 1.3 08-Nov-2020  rillig make(1): add test for comparison of large integers
 1.2 11-Sep-2020  rillig make(1): fix tests about nonexistent = and === operators
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.8 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.7 07-Sep-2023  rillig branches: 1.7.2;
tests/make: fix test for conditions of the form 'a > b'
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 08-Nov-2020  rillig make(1): add test for comparison of large integers
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 11-Sep-2020  rillig make(1): fix tests about nonexistent = and === operators
 1.2 11-Sep-2020  rillig make(1): add tests for the unknown = and === operators
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.3 07-Sep-2023  rillig tests/make: fix test for conditions of the form 'a > b'
 1.2 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.3 07-Sep-2023  rillig tests/make: fix test for conditions of the form 'a > b'
 1.2 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.3 07-Sep-2023  rillig tests/make: fix test for conditions of the form 'a > b'
 1.2 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.3 07-Sep-2023  rillig tests/make: fix test for conditions of the form 'a > b'
 1.2 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.3 07-Sep-2023  rillig tests/make: fix test for conditions of the form 'a > b'
 1.2 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.1 23-Aug-2020  rillig make(1): add tests for numeric comparisons in .if directives
 1.13 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.12 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.11 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.10 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.9 04-Mar-2023  rillig branches: 1.9.2;
tests/make: test very small and very large numbers in conditions
 1.8 04-Sep-2022  rillig make: add more details to error message for numeric comparison

Before:
String comparison operator must be either == or !=

After:
Comparison with '>=' requires both operands 'no' and '10' to be numeric

Noticed by martin@ in pkgsrc/textproc/py-pygments.
 1.7 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.6 29-Jul-2021  rillig tests/make: test spaces around numbers in comparisons

Just to see whether it is possible to write a conditional in the form
${ ${A} < ${B} :? ${A} : ${B} }, that is, with leading and trailing
whitespace, to make it easier for humans to read the code.

It's not possible, the result of this computation cannot be used in
further numeric comparisons, at least not in .if directives. Leading
space would work, but trailing space wouldn't.

On the other hand, they would work in expressions of the form
${ ${A} < ${B} :? ... : ... } since in these, the condition is first
expanded and then parsed. But that is an implementation detail that is
not documented and it is also difficult to understand.
 1.5 21-Jan-2021  rillig make(1): replace warning + error with just an error in conditionals

Before, there was a "warning" for comparing strings using '<', which was
wrong. That warning was then followed by an error, after parsing the
whole conditional. This was only because it was easier to implement.

Replace the warning with an actual error. This only affects
conditionals in .if lines, the conditionals in the :? modifier such as
${"A" < "B":?smaller:greater} still print 2 errors.
 1.4 21-Jan-2021  rillig make(1): fix debug output for comparison operators in conditionals

This produces fewer warnings than before, but these were edge cases that
probably didn't matter in practice. The "Malformaed conditional" is
still generated, the set of accepted conditionals is still the same.
 1.3 08-Nov-2020  rillig make(1): add test for wrong comparison operator in conditional
 1.2 12-Sep-2020  rillig make(1): add test for Infinity and NaN

Neither is recognized by the make parser, which is good since the main
task of make is dependency resolution and text processing, not
calculating.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.8 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.7 04-Mar-2023  rillig branches: 1.7.2;
tests/make: test very small and very large numbers in conditions
 1.6 04-Sep-2022  rillig make: add more details to error message for numeric comparison

Before:
String comparison operator must be either == or !=

After:
Comparison with '>=' requires both operands 'no' and '10' to be numeric

Noticed by martin@ in pkgsrc/textproc/py-pygments.
 1.5 29-Jul-2021  rillig tests/make: test spaces around numbers in comparisons

Just to see whether it is possible to write a conditional in the form
${ ${A} < ${B} :? ${A} : ${B} }, that is, with leading and trailing
whitespace, to make it easier for humans to read the code.

It's not possible, the result of this computation cannot be used in
further numeric comparisons, at least not in .if directives. Leading
space would work, but trailing space wouldn't.

On the other hand, they would work in expressions of the form
${ ${A} < ${B} :? ... : ... } since in these, the condition is first
expanded and then parsed. But that is an implementation detail that is
not documented and it is also difficult to understand.
 1.4 08-Nov-2020  rillig make(1): add test for wrong comparison operator in conditional
 1.3 12-Sep-2020  rillig make(1): add test for Infinity and NaN

Neither is recognized by the make parser, which is good since the main
task of make is dependency resolution and text processing, not
calculating.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.16 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.15 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.14 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.13 28-Mar-2023  rillig branches: 1.13.2;
tests/make: add expectations for string comparison errors
 1.12 04-Sep-2022  rillig make: add more details to error message for numeric comparison

Before:
String comparison operator must be either == or !=

After:
Comparison with '>=' requires both operands 'no' and '10' to be numeric

Noticed by martin@ in pkgsrc/textproc/py-pygments.
 1.11 21-Jan-2021  rillig make(1): replace warning + error with just an error in conditionals

Before, there was a "warning" for comparing strings using '<', which was
wrong. That warning was then followed by an error, after parsing the
whole conditional. This was only because it was easier to implement.

Replace the warning with an actual error. This only affects
conditionals in .if lines, the conditionals in the :? modifier such as
${"A" < "B":?smaller:greater} still print 2 errors.
 1.10 21-Jan-2021  rillig make(1): fix debug output for comparison operators in conditionals

This produces fewer warnings than before, but these were edge cases that
probably didn't matter in practice. The "Malformaed conditional" is
still generated, the set of accepted conditionals is still the same.
 1.9 19-Jan-2021  rillig make(1): add test for unsupported relational string comparisons
 1.8 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.7 30-Oct-2020  rillig make(1): fix parse error in string literal in conditional

The string literal "${VAR} " had produced a "Malformed conditional", at
least since 2003. (That's the oldest make I have available for testing.)
Strange that nobody else noticed that in the last 17 years.
 1.6 30-Oct-2020  rillig make(1): add more test cases that fail in condition string literals
 1.5 30-Oct-2020  rillig make(1): demonstrate parse error in string interpolation in condition
 1.4 12-Sep-2020  rillig make(1): fix wording of parse error in conditionals

The word "should" is not appropriate for situations that eventually lead
to a parse error.
 1.3 11-Sep-2020  rillig make(1): fix tests about nonexistent = and === operators
 1.2 20-Aug-2020  rillig make(1): add test for string literals in comparisons
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.21 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.20 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.19 23-Apr-2024  rillig branches: 1.19.2;
make: clean up comments, code and tests
 1.18 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.17 28-Mar-2023  rillig tests/make: add expectations for string comparison errors
 1.16 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.15 11-Dec-2021  rillig tests/make: proofread and clean up comments for function 'empty'

This prepares a refactoring for handling the function 'empty' in
conditionals like '.if'.

The function 'empty' is fundamentally different from all other functions
since it is parsed differently and passes its result on different path
than the other functions. Splitting up these code paths will untangle
the control flow of parsing a condition like 'empty(VARNAME)'. It will
also remove several ARGSUSED and MAKE_ATTR_UNUSED that make the current
code smell.
 1.14 19-Jan-2021  rillig make(1): add test for unsupported relational string comparisons
 1.13 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.12 08-Nov-2020  rillig make(1): add test for comparing numbers with strings
 1.11 30-Oct-2020  rillig make(1): fix comments in test for string literals in conditions
 1.10 30-Oct-2020  rillig make(1): fix parse error in string literal in conditional

The string literal "${VAR} " had produced a "Malformed conditional", at
least since 2003. (That's the oldest make I have available for testing.)
Strange that nobody else noticed that in the last 17 years.
 1.9 30-Oct-2020  rillig make(1): add more test cases that fail in condition string literals
 1.8 30-Oct-2020  rillig make(1): add test for two variable expressions in a string literal
 1.7 30-Oct-2020  rillig make(1): demonstrate parse error in string interpolation in condition
 1.6 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.5 11-Sep-2020  rillig make(1): fix tests about nonexistent = and === operators
 1.4 11-Sep-2020  rillig make(1): add tests for the unknown = and === operators
 1.3 20-Aug-2020  rillig make(1): add test for string literals in comparisons
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.19.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 01-Jun-2023  rillig make: shorten function names, clean up comments

No functional change.
 1.2 11-Nov-2020  rillig make(1): add tests demonstrating bugs in TryParseNumber and EvalNotEmpty
 1.1 14-Sep-2020  rillig make(1): add tests for numbers in conditions
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 01-Jun-2023  rillig make: shorten function names, clean up comments

No functional change.
 1.3 08-Sep-2022  rillig tests/make: document an edge case in evaluating conditionals
 1.2 11-Nov-2020  rillig make(1): add tests demonstrating bugs in TryParseNumber and EvalNotEmpty
 1.1 14-Sep-2020  rillig make(1): add tests for numbers in conditions
 1.8 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.7 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.6 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.5 01-Jun-2023  rillig branches: 1.5.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.3 10-Dec-2021  rillig make: do not evaluate misplaced expressions in malformed conditions

This change only affects the behavior for parse errors. Syntactically
well-formed conditions work exactly as before.
 1.2 14-Dec-2020  rillig make(1): add test for variable expressions after a parse error

These variable expressions don't need to be expanded, and they aren't.
 1.1 14-Dec-2020  rillig make(1): add test for parsing the end of a condition
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.7 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.6 19-Nov-2023  rillig branches: 1.6.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.3 10-Dec-2021  rillig make: do not evaluate misplaced expressions in malformed conditions

This change only affects the behavior for parse errors. Syntactically
well-formed conditions work exactly as before.
 1.2 14-Dec-2020  rillig make(1): add test for variable expressions after a parse error

These variable expressions don't need to be expanded, and they aren't.
 1.1 14-Dec-2020  rillig make(1): add test for parsing the end of a condition
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.5 15-Nov-2020  rillig branches: 1.5.8;
make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 23-Aug-2020  rillig make(1): add tests for functions in .if conditions
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.8.1 02-Aug-2025  perseant Sync with HEAD
 1.13 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.12 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.11 06-Aug-2024  rillig make: add details to error messages about missing ')'
 1.10 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.9 23-Apr-2024  rillig branches: 1.9.2;
make: clean up comments, code and tests
 1.8 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.7 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 22-Jan-2021  rillig make(1): remove "warning" from missing closing parenthesis

This only affects the diagnostics for parse errors that involve a
missing closing parenthesis. Whether or not this is a parse error is
still the same.

It may look redundant to pass both the CondParser and the parsing
position pp to the functions, but that's necessary since during parsing,
not every code path updates the main parsing position immediately.
 1.5 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.4 07-Nov-2020  rillig make(1): add test for parse error in function defined()
 1.3 20-Aug-2020  rillig make(1): add test for parsing functions in .if conditions
 1.2 20-Aug-2020  rillig make(1): add test for the function defined(...)
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.15 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.14 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.13 06-Aug-2024  rillig make: add details to error messages about missing ')'
 1.12 23-Apr-2024  rillig branches: 1.12.2;
make: clean up comments, code and tests
 1.11 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.10 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.9 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.8 12-Dec-2021  rillig make: rename ParseFuncArg to ParseWord, update comments

No functional change.
 1.7 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.6 07-Nov-2020  rillig make(1): add test for parse error in function defined()
 1.5 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.4 27-Sep-2020  rillig make(1): normalize whitespace in source code

There is no more space tab. Either only tabs or only spaces or tabs
followed by spaces, but not spaces followed by tabs.
 1.3 20-Aug-2020  rillig make(1): add test for the function defined(...)
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.12.2.1 02-Aug-2025  perseant Sync with HEAD
 1.11 11-Jun-2025  sjg make: check variable names for invalid characters

Variable names should not contain white-space.
As is; make quietly ignores gmake syntax like
$(addprefix -I, $(INCLUDE_DIR_LIST))
which means we are not doing what the makefile wants, and the
user has no clue.

CheckVarname is called only if there are no modifiers to be applied
as :L and others legitimately can handle white-space,
it will issue a warning if illegal characters are found.
Currently only white-space is checked.

The NetBSD build produces a few warnings - in one case a makefile
intended for gmake, and the other some dubious constructs by bsd.prog.mk
in support of ATF tests such as OBJS.${PROG} when PROG is actually a list.

Reviewed by: rillig
 1.10 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.9 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.8 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.7 28-Jun-2023  rillig branches: 1.7.2;
tests/make: extend test for the 'empty' function in conditions
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 04-Mar-2023  rillig tests/make: improve explanations in test for 'empty' function
 1.4 11-Dec-2021  rillig tests/make: proofread and clean up comments for function 'empty'

This prepares a refactoring for handling the function 'empty' in
conditionals like '.if'.

The function 'empty' is fundamentally different from all other functions
since it is parsed differently and passes its result on different path
than the other functions. Splitting up these code paths will untangle
the control flow of parsing a condition like 'empty(VARNAME)'. It will
also remove several ARGSUSED and MAKE_ATTR_UNUSED that make the current
code smell.
 1.3 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.2 07-Nov-2020  rillig make(1): add test for parse error in condition using empty()
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.29 11-Jun-2025  sjg make: check variable names for invalid characters

Variable names should not contain white-space.
As is; make quietly ignores gmake syntax like
$(addprefix -I, $(INCLUDE_DIR_LIST))
which means we are not doing what the makefile wants, and the
user has no clue.

CheckVarname is called only if there are no modifiers to be applied
as :L and others legitimately can handle white-space,
it will issue a warning if illegal characters are found.
Currently only white-space is checked.

The NetBSD build produces a few warnings - in one case a makefile
intended for gmake, and the other some dubious constructs by bsd.prog.mk
in support of ATF tests such as OBJS.${PROG} when PROG is actually a list.

Reviewed by: rillig
 1.28 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.27 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.26 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.25 02-Jun-2024  rillig branches: 1.25.2;
make: sync VarEvalMode constant names with their debug log names
 1.24 19-Dec-2023  rillig make: clean up comments

No binary change, except for line numbers in assertions.
 1.23 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.22 11-Aug-2023  rillig tests/make: fix grammar in a test comment
 1.21 28-Jun-2023  rillig tests/make: extend test for the 'empty' function in conditions
 1.20 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.19 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.18 04-Mar-2023  rillig tests/make: improve explanations in test for 'empty' function
 1.17 28-Dec-2021  rillig tests/make: test function names without following '('
 1.16 11-Dec-2021  rillig make: inline ParseEmptyArg into CondParser_FuncCallEmpty

No functional change.
 1.15 11-Dec-2021  rillig tests/make: proofread and clean up comments for function 'empty'

This prepares a refactoring for handling the function 'empty' in
conditionals like '.if'.

The function 'empty' is fundamentally different from all other functions
since it is parsed differently and passes its result on different path
than the other functions. Splitting up these code paths will untangle
the control flow of parsing a condition like 'empty(VARNAME)'. It will
also remove several ARGSUSED and MAKE_ATTR_UNUSED that make the current
code smell.
 1.14 11-Apr-2021  rillig make: clean up remaining references to VarEvalFlags

VarEvalFlags has been replaced with VarEvalMode. There were some
comments and tests that still referred to the old names.

No functional change.
 1.13 15-Mar-2021  rillig make: replace enum bit-field with struct bit-field for VarEvalFlags

This makes the code easier to read, especially in var.c. It also makes
debugging sessions easier since some debuggers don't show enum
bit-fields symbolically as soon as more than one bit is set.

The code outside var.c is basically unchanged, except that instead of
passing the individual flags, there are 4 predefined evaluation modes.
These suffice for all practical use cases. Only in the implementation
deep inside var.c, the value of the flags keepDollar and keepUndef
differs.

There is no way of passing the struct to EnumFlags_ToString, which means
the ToString function has to be spelled out explicitly. This allows for
fine-tuning the representation in the debug log, to reduce the amount of
uppercae letters.

No functional change.
 1.12 22-Feb-2021  rillig make: update constant names in comments

No functional change.
 1.11 28-Nov-2020  rillig make(1): move test for recursive variable to cond-func-empty

Previously, the documentation of that test was much too short to explain
all the effects that happened in the bug situation from 2020-06-28 until
2020-07-02.
 1.10 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.9 07-Nov-2020  rillig make(1): add test for parse error in condition using empty()
 1.8 23-Sep-2020  rillig make(1): add tests for spaces in condition functions
 1.7 23-Sep-2020  rillig make(1): fix unexpected behavior in ::= variable modifier

Previously, the ::= modifier had returned an error value, which caused
the variable expression to be preserved. This behavior was not useful
in this case; it had only been intended to be used for undefined
variables.

To fix it, distinguish between parse errors, undefined variables and
regular empty strings.
 1.6 04-Sep-2020  rillig make(1): rename local functions for parsing conditions

The word "get" implies a cheap operation without side effects. Parsing
instead has lots of side effects, even if it's only that the parsing
position is updated.
 1.5 04-Sep-2020  rillig make(1): migrate get_mpt_arg to Var_ParsePP

This part is covered well by the unit tests. When I forgot to decrement
the linePtr, several of them failed reliably.
 1.4 04-Sep-2020  rillig make(1): add more explanation for undefined variable expressions
 1.3 03-Sep-2020  rillig make(1): add test for the empty function in conditionals
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.25.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.7 19-Nov-2023  rillig branches: 1.7.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.6 30-Nov-2020  rillig make(1): add test for directory cache and exists()
 1.5 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.4 28-Aug-2020  rillig make(1): extend test for the exists function in conditions
 1.3 23-Aug-2020  rillig make(1): add tests for functions in .if conditions
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 22-Nov-2020  rillig make(1): document the selection of the main target
 1.2 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.1 22-Nov-2020  rillig make(1): document the selection of the main target
 1.5 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 23-Jun-2023  rillig branches: 1.3.2;
make: warn about malformed patterns in ':M', ':N' and '.if make(...)'

These patterns shouldn't occur in practice, as their results are tricky
to predict. Generate a warning for now, and maybe an error later.

Reviewed by sjg@.
 1.2 25-Sep-2020  rillig make(1): add test for make() function in conditions
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.6 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.5 23-Jun-2023  rillig branches: 1.5.2;
make: warn about malformed patterns in ':M', ':N' and '.if make(...)'

These patterns shouldn't occur in practice, as their results are tricky
to predict. Generate a warning for now, and maybe an error later.

Reviewed by sjg@.
 1.4 22-Jun-2023  rillig make: clean up comments related to pattern matching
 1.3 25-Sep-2020  rillig make(1): add test for make() function in conditions
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.4 24-Oct-2020  rillig branches: 1.4.8;
make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 23-Aug-2020  rillig make(1): add tests for functions in .if conditions
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.8.1 02-Aug-2025  perseant Sync with HEAD
 1.15 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.14 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.13 07-Aug-2024  rillig make: in erroneous conditions, report the non-expanded text

In a condition, when a function call expression is missing its closing
parenthesis, there's no point in having the expanded argument text in
the error message.

When parsing a bare word in a condition, the trailing space was included
in that word, which was inconsistent, as the leading space was not
included either. Removing the trailing space from the word reduces the
cases where a multiple-inclusion guard steps in, but only in an edge
case that is irrelevant in practice.
 1.12 07-Aug-2024  rillig tests/make: demonstrate unintended parsing of words in conditions

A word is not supposed to include its trailing space, as it doesn't
contain its leading space either.
 1.11 06-Aug-2024  rillig make: add details to error messages about missing ')'
 1.10 06-Jul-2024  rillig make: error out on conditions containing the operators '&' and '|'

These abbreviated variants of the '&&' and '||' operators were never
documented, so error out in non-lint mode as well.
 1.9 01-Jun-2023  rillig branches: 1.9.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.8 07-Jan-2022  rillig tests/make: fix documentation in cond-func.mk
 1.7 12-Dec-2021  rillig make: generate more specific error message on malformed conditional
 1.6 22-Jan-2021  rillig make(1): remove "warning" from missing closing parenthesis

This only affects the diagnostics for parse errors that involve a
missing closing parenthesis. Whether or not this is a parse error is
still the same.

It may look redundant to pass both the CondParser and the parsing
position pp to the functions, but that's necessary since during parsing,
not every code path updates the main parsing position immediately.
 1.5 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.4 10-Nov-2020  rillig make(1): add tests for parsing conditionals, document a parsing bug
 1.3 10-Nov-2020  rillig make(1): add tests for edge cases in parsing conditionals
 1.2 08-Nov-2020  rillig make(1): add test for function argument with unbalanced braces
 1.1 20-Aug-2020  rillig make(1): add test for parsing functions in .if conditions
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.19 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.18 07-Aug-2024  rillig make: in erroneous conditions, report the non-expanded text

In a condition, when a function call expression is missing its closing
parenthesis, there's no point in having the expanded argument text in
the error message.

When parsing a bare word in a condition, the trailing space was included
in that word, which was inconsistent, as the leading space was not
included either. Removing the trailing space from the word reduces the
cases where a multiple-inclusion guard steps in, but only in an edge
case that is irrelevant in practice.
 1.17 07-Aug-2024  rillig tests/make: demonstrate unintended parsing of words in conditions

A word is not supposed to include its trailing space, as it doesn't
contain its leading space either.
 1.16 06-Aug-2024  rillig make: add details to error messages about missing ')'
 1.15 06-Jul-2024  rillig make: error out on conditions containing the operators '&' and '|'

These abbreviated variants of the '&&' and '||' operators were never
documented, so error out in non-lint mode as well.
 1.14 19-Nov-2023  rillig branches: 1.14.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.13 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.12 10-May-2023  rillig tests/make: clean up comments in tests
 1.11 07-Jan-2022  rillig tests/make: fix documentation in cond-func.mk
 1.10 28-Dec-2021  rillig tests/make: test function names without following '('
 1.9 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.8 10-Nov-2020  rillig make(1): add tests for parsing conditionals, document a parsing bug
 1.7 10-Nov-2020  rillig make(1): add tests for edge cases in parsing conditionals
 1.6 08-Nov-2020  rillig make(1): add test for function argument with unbalanced braces
 1.5 08-Nov-2020  rillig make(1): document what the directive ".if A&B" means
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 27-Sep-2020  rillig make(1): normalize whitespace in source code

There is no more space tab. Either only tabs or only spaces or tabs
followed by spaces, but not spaces followed by tabs.
 1.2 23-Sep-2020  rillig make(1): add tests for spaces in condition functions
 1.1 20-Aug-2020  rillig make(1): add test for parsing functions in .if conditions
 1.14.2.1 02-Aug-2025  perseant Sync with HEAD
 1.13 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.12 12-Jun-2025  rillig make: add program name to stack traces from sub-makes
 1.11 12-Jun-2025  rillig make: add quotes to "in directory" line in stack traces

The other lines in stack traces use quotes as well.
 1.10 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.9 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.8 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.7 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.6 30-Jun-2024  rillig make: error out on syntax error in conditions in ':?then:else' modifier

The 'Error' function only reports errors but does not affect the exit
status, the 'Parse_Error' function does, while providing more details to
find the cause of the syntax error.
 1.5 10-Dec-2023  rillig branches: 1.5.2;
make: remove redundant text from diagnostic about bad '?:' modifier
 1.4 19-Apr-2021  rillig make: use straight quotes for error 'Bad conditional expression'

This diagnostic was supposed to be an error, see ApplyModifier_IfElse.

When such an error occurs while the makefiles are read, make stops with
an error, as can be expected. But when such an error occurs later,
after all makefiles have been read, the message is printed but make does
not stop.

In lint mode (-dL), make stops in such a case. I didn't dare to make
this the default behavior, out of fear of breaking existing build
infrastructure, not only in NetBSD or pkgsrc, but also FreeBSD and other
operating systems that use the bmake distribution, generated from the
same source code.
 1.3 25-Jul-2020  rillig make(1): add test for undefined (or empty) variable in :? modifier
 1.2 01-May-2020  rillig usr.bin/make: fix test for late evaluated condition
 1.1 29-Apr-2020  rillig usr.bin/make: add test case for lazy conditions
 1.5.2.2 02-Aug-2025  perseant Sync with HEAD
 1.5.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.10 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.9 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.8 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.7 30-Jun-2024  rillig make: error out on syntax error in conditions in ':?then:else' modifier

The 'Error' function only reports errors but does not affect the exit
status, the 'Parse_Error' function does, while providing more details to
find the cause of the syntax error.
 1.6 10-Dec-2023  rillig branches: 1.6.2;
make: remove redundant text from diagnostic about bad '?:' modifier
 1.5 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.4 10-May-2023  rillig tests/make: clean up comments in tests
 1.3 15-Nov-2020  rillig make(1): clean up some tests

Fix some mistakes in comments.

Improve some comments to be easier understandable.

Inline variables that are irrelevant for the test at hand (RUN,
MAKE_CMD).

Remove references to functions and constants that have since been removed
or renamed.
 1.2 25-Jul-2020  rillig make(1): add test for undefined (or empty) variable in :? modifier
 1.1 29-Apr-2020  rillig usr.bin/make: add test case for lazy conditions
 1.6.2.2 02-Aug-2025  perseant Sync with HEAD
 1.6.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.4 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.3 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.2 01-Jun-2023  rillig branches: 1.2.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.1 08-Nov-2020  rillig make(1): in lint mode, only allow '&&' and '||', not '&' and '|'

These variants of the condition operators are neither documented in the
manual page nor are they used in practice.
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.2 01-Jun-2023  rillig branches: 1.2.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.1 08-Nov-2020  rillig make(1): in lint mode, only allow '&&' and '||', not '&' and '|'

These variants of the condition operators are neither documented in the
manual page nor are they used in practice.
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.6 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.5 06-Jul-2024  rillig make: error out on conditions containing the operators '&' and '|'

These abbreviated variants of the '&&' and '||' operators were never
documented, so error out in non-lint mode as well.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 10-Dec-2021  rillig tests/make: add more comprehensive tests for short-circuit evaluation
 1.2 10-Sep-2020  rillig make(1): add test for the &, && and &&& operators
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.13 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.12 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.11 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.10 06-Jul-2024  rillig make: error out on conditions containing the operators '&' and '|'

These abbreviated variants of the '&&' and '||' operators were never
documented, so error out in non-lint mode as well.
 1.9 17-Dec-2023  rillig branches: 1.9.2;
tests/make: in 'expect' lines, require the complete text of the line
 1.8 15-Aug-2023  rillig tests/make: show that '||' and '&&' must be preceded by whitespace
 1.7 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 10-Dec-2021  rillig tests/make: add more comprehensive tests for short-circuit evaluation
 1.5 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.4 10-Sep-2020  rillig make(1): add test for the &, && and &&& operators
 1.3 28-Aug-2020  rillig make(1): add tests for the &&, || and ! operators
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.6 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.5 01-Jun-2023  rillig branches: 1.5.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 19-Jan-2021  rillig make(1): demonstrate wrong return value in CondParser_Term
 1.3 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.2 15-Nov-2020  rillig make(1): add tests for the '!' operator in conditions
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.9 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.8 01-Jun-2023  rillig branches: 1.8.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 19-Jan-2021  rillig make(1): demonstrate wrong return value in CondParser_Term
 1.6 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.5 15-Nov-2020  rillig make(1): add tests for the '!' operator in conditions
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 28-Aug-2020  rillig make(1): add tests for the &&, || and ! operators
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.3 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.2 01-Jun-2023  rillig branches: 1.2.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.1 08-Nov-2020  rillig make(1): in lint mode, only allow '&&' and '||', not '&' and '|'

These variants of the condition operators are neither documented in the
manual page nor are they used in practice.
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.2 01-Jun-2023  rillig branches: 1.2.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.1 08-Nov-2020  rillig make(1): in lint mode, only allow '&&' and '||', not '&' and '|'

These variants of the condition operators are neither documented in the
manual page nor are they used in practice.
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.9 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.8 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.7 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.6 06-Jul-2024  rillig make: error out on conditions containing the operators '&' and '|'

These abbreviated variants of the '&&' and '||' operators were never
documented, so error out in non-lint mode as well.
 1.5 01-Jun-2023  rillig branches: 1.5.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 10-Dec-2021  rillig tests/make: add more comprehensive tests for short-circuit evaluation
 1.3 09-Dec-2021  rillig tests/make: prevent the bug from cond.c 1.283 from happening again
 1.2 10-Sep-2020  rillig make(1): add tests for the |, ||, ||| operators
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.15 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.14 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.13 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.12 06-Jul-2024  rillig make: error out on conditions containing the operators '&' and '|'

These abbreviated variants of the '&&' and '||' operators were never
documented, so error out in non-lint mode as well.
 1.11 17-Dec-2023  rillig branches: 1.11.2;
tests/make: in 'expect' lines, require the complete text of the line
 1.10 15-Aug-2023  rillig tests/make: show that '||' and '&&' must be preceded by whitespace
 1.9 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.8 10-Dec-2021  rillig tests/make: add more comprehensive tests for short-circuit evaluation
 1.7 09-Dec-2021  rillig tests/make: prevent the bug from cond.c 1.283 from happening again
 1.6 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.5 11-Sep-2020  rillig make(1): fix comment in test for the || operator in conditions

Thanks to wiz for discovering this.
 1.4 10-Sep-2020  rillig make(1): add tests for the |, ||, ||| operators
 1.3 28-Aug-2020  rillig make(1): add tests for the &&, || and ! operators
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.11.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.9 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.8 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.7 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.6 01-Jun-2023  rillig branches: 1.6.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 04-Sep-2022  rillig make: add more details to error message for numeric comparison

Before:
String comparison operator must be either == or !=

After:
Comparison with '>=' requires both operands 'no' and '10' to be numeric

Noticed by martin@ in pkgsrc/textproc/py-pygments.
 1.4 22-Jan-2022  rillig tests/make: add a few more tests, mainly for special targets
 1.3 19-Jan-2021  rillig make(1): demonstrate wrong return value in CondParser_Term
 1.2 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.8 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.7 01-Jun-2023  rillig branches: 1.7.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 04-Sep-2022  rillig make: add more details to error message for numeric comparison

Before:
String comparison operator must be either == or !=

After:
Comparison with '>=' requires both operands 'no' and '10' to be numeric

Noticed by martin@ in pkgsrc/textproc/py-pygments.
 1.5 22-Jan-2022  rillig tests/make: add a few more tests, mainly for special targets
 1.4 19-Jan-2021  rillig make(1): demonstrate wrong return value in CondParser_Term
 1.3 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.16 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.15 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.14 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.13 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.12 01-Jun-2023  rillig branches: 1.12.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.11 10-Dec-2021  rillig make: do not evaluate misplaced expressions in malformed conditions

This change only affects the behavior for parse errors. Syntactically
well-formed conditions work exactly as before.
 1.10 10-Dec-2021  rillig tests/make: extend test for parse errors in conditions
 1.9 19-Jan-2021  rillig make(1): add error handling for edge case in malformed conditions
 1.8 19-Jan-2021  rillig make(1): demonstrate missing error handling for malformed conditions
 1.7 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.6 15-Nov-2020  rillig make(1): add test for operator precedence using truth tables
 1.5 11-Sep-2020  rillig make(1): add rationale for evaluating expression after parse error
 1.4 11-Sep-2020  rillig make(1): fix line numbers from test result of the previous commit
 1.3 11-Sep-2020  rillig make(1): add test for evaluation of condition after parse error
 1.2 28-Aug-2020  rillig make(1): add test for unquoted string literals
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.12.2.1 02-Aug-2025  perseant Sync with HEAD
 1.18 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.17 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.16 01-Jun-2023  rillig branches: 1.16.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.15 10-Dec-2021  rillig make: do not evaluate misplaced expressions in malformed conditions

This change only affects the behavior for parse errors. Syntactically
well-formed conditions work exactly as before.
 1.14 10-Dec-2021  rillig tests/make: extend test for parse errors in conditions
 1.13 19-Jan-2021  rillig make(1): update references to the renamed CondParser functions
 1.12 19-Jan-2021  rillig make(1): add error handling for edge case in malformed conditions
 1.11 19-Jan-2021  rillig make(1): demonstrate missing error handling for malformed conditions
 1.10 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.9 15-Nov-2020  rillig make(1): add test for operator precedence using truth tables
 1.8 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.7 11-Sep-2020  rillig make(1): add rationale for evaluating expression after parse error
 1.6 11-Sep-2020  rillig make(1): add test for evaluation of condition after parse error
 1.5 11-Sep-2020  rillig make(1): rename CondGetString to CondParser_String

This describes the function's effect more accurately. The verb "get" is
not commonly associated to having side effects.
 1.4 28-Aug-2020  rillig make(1): add test for unquoted string literals
 1.3 28-Aug-2020  rillig make(1): add test for operator precedence in conditions
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.16.2.1 02-Aug-2025  perseant Sync with HEAD
 1.16 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.15 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.14 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.13 19-Oct-2023  rillig branches: 1.13.2;
tests/make: clean up, explain and reorganize several tests
 1.12 04-Mar-2023  rillig tests/make: use proper variable names in short-circuit test

The previous variable names V42, V66, iV1 and iV2 didn't carry enough
information to be readily readable, making the test hard to understand.

Rename the variables to be more expressive. While here, properly
explain what happened behind the scenes in 2020 and how the evaluation
of conditions was fixed after discovering the actual cause of the
unexpected error messages.
 1.11 01-Dec-2020  rillig make(1): adjust condition descriptions in test cond-short

Before, the conditions in the output had been expanded, which made them
illegible. The expanded conditions were unrealistic as well since the
evaluation flags differ between a condition and normal evaluation
(VARE_WANTRES, VARE_UNDEFERR).
 1.10 09-Jul-2020  sjg compare_expression: return after fetch lhs and rhs if !doEval

Otherwise we end up throwing warings/errors for valid
conditionals due to not expanding variables fully.

Add tests to catch this.

Reviewed by: rillig
 1.9 02-Jul-2020  rillig make(1): fix unnecessary evaluation of variables in :@var@ modifier
 1.8 02-Jul-2020  rillig make(1): fix unnecessary evaluation for :S :C := modifiers
 1.7 02-Jul-2020  rillig make(1): demonstrate some more cases for unintended evaluation
 1.6 02-Jul-2020  rillig make(1): fix unnecessary evaluation of :M and :N modifiers
 1.5 02-Jul-2020  rillig make(1): demonstrate another unintended variable evaluation
 1.4 02-Jul-2020  rillig make(1): fix edge case for evaluating unnecessary conditions
 1.3 02-Jul-2020  rillig make(1): demonstrate another unnecessary condition evaluation
 1.2 28-Jun-2020  rillig make(1): fix evaluation of unreachable conditions

Since 2015-10-11, make had evaluated unreachable conditions even though
the manual page said it didn't.
 1.1 28-Jun-2020  rillig make(1): demonstrate bug when evaluating conditions
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.24 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.23 19-Nov-2023  rillig branches: 1.23.2;
tests/make: replace 'variable expressions' with 'expressions'
 1.22 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.21 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.20 04-Mar-2023  rillig tests/make: use proper variable names in short-circuit test

The previous variable names V42, V66, iV1 and iV2 didn't carry enough
information to be readily readable, making the test hard to understand.

Rename the variables to be more expressive. While here, properly
explain what happened behind the scenes in 2020 and how the evaluation
of conditions was fixed after discovering the actual cause of the
unexpected error messages.
 1.19 27-Dec-2021  rillig make: clean up comments
 1.18 12-Dec-2021  rillig tests/make: add tests for irrelevant function calls
 1.17 07-Sep-2021  rillig tests/make: expand on the history of unnecessary evaluation
 1.16 14-Mar-2021  rillig tests/make: add test for short-circuit evaluation of modifiers
 1.15 01-Dec-2020  rillig make(1): document handling of irrelevant conditions before 2020-07-09
 1.14 01-Dec-2020  rillig make(1): adjust condition descriptions in test cond-short

Before, the conditions in the output had been expanded, which made them
illegible. The expanded conditions were unrealistic as well since the
evaluation flags differ between a condition and normal evaluation
(VARE_WANTRES, VARE_UNDEFERR).
 1.13 30-Nov-2020  rillig make(1): document how short-circuit evaluation behaved on 2020-07-03
 1.12 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.11 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.10 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.9 19-Aug-2020  rillig make(1): add empty lines to separate the test cases in cond-short
 1.8 19-Jul-2020  rillig make(1): add test for assignment operators in conditions
 1.7 09-Jul-2020  sjg compare_expression: return after fetch lhs and rhs if !doEval

Otherwise we end up throwing warings/errors for valid
conditionals due to not expanding variables fully.

Add tests to catch this.

Reviewed by: rillig
 1.6 02-Jul-2020  rillig make(1): demonstrate some more cases for unintended evaluation
 1.5 02-Jul-2020  rillig make(1): fix unnecessary evaluation of :M and :N modifiers
 1.4 02-Jul-2020  rillig make(1): demonstrate another unintended variable evaluation
 1.3 02-Jul-2020  rillig make(1): demonstrate another unnecessary condition evaluation
 1.2 28-Jun-2020  rillig make(1): fix evaluation of unreachable conditions

Since 2015-10-11, make had evaluated unreachable conditions even though
the manual page said it didn't.
 1.1 28-Jun-2020  rillig make(1): demonstrate bug when evaluating conditions
 1.23.2.1 02-Aug-2025  perseant Sync with HEAD
 1.11 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.10 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.9 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.8 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.7 01-Jun-2023  rillig branches: 1.7.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 04-Mar-2023  rillig tests/make: test very small and very large numbers in conditions
 1.5 27-Dec-2021  rillig make: clean up comments
 1.4 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.3 08-Nov-2020  rillig make(1): add test for hexadecimal numbers in conditionals
 1.2 14-Sep-2020  rillig make(1): add tests for numbers in conditions
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.11 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.10 19-Nov-2023  rillig branches: 1.10.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.9 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.8 04-Mar-2023  rillig tests/make: test very small and very large numbers in conditions
 1.7 02-Jan-2022  rillig make: clean up nitpicks

In ParseWord, the expressions '*p' and 'ch' are the same.

In ParseDependencyTargetWord, clean up a wordy comment and join two
conditions.

In the test cond-token-number, clarify that make doesn't convert from
hex to decimal but only from hex to internal representation.

No functional change.
 1.6 27-Dec-2021  rillig make: clean up comments
 1.5 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.4 08-Nov-2020  rillig make(1): add test for hexadecimal numbers in conditionals
 1.3 14-Sep-2020  rillig make(1): add tests for numbers in conditions
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.10.2.1 02-Aug-2025  perseant Sync with HEAD
 1.25 06-Jul-2025  rillig make: complain about unfinished escape sequences or string literals
 1.24 06-Jul-2025  rillig tests/make: demonstrate missing error for unfinished word in condition
 1.23 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.22 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.21 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.20 19-Nov-2023  rillig branches: 1.20.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.19 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.18 14-Feb-2023  rillig make: don't interpret the return value of Var_Parse

The return value of Var_Parse is largely redundant to the returned
string. The idea behind the type VarParseResult was to migrate all call
sites to checking this return value instead of the returned string, but
that hasn't happened. Instead, the additional type only added more
complexity.

There was a single place where that return value was actually used, when
parsing conditions. And even in that case, ignoring the VarParseResult
added back an error message that previously hid bugs, in the test
cond-token-plain.mk.

Even though these error messages are redundant in the other tests, they
don't hurt as they don't happen often.
 1.17 25-Sep-2022  rillig tests/make: reduce trailing whitespace
 1.16 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.15 08-Jan-2022  rillig make: fix reported line numbers of continuation lines (since 2002)

Previously, multi-line directives like '.info' or '.error' reported the
line number of their last line instead of their first line, which is
more usual. This also affected the debug log from '-dp'.
 1.14 30-Dec-2021  rillig tests/make: demonstrate edge case that evaluates an expression twice
 1.13 12-Dec-2021  rillig tests/make: refine comments for parsing and evaluating conditions
 1.12 21-Sep-2021  rillig make: do not allow unquoted 'left == right' after modifier ':?'

Having a static variable for state that clearly belongs in the parser
looked suspicious, and indeed it was wrong.

When the distinction between .if conditions and expressions of the form
${condition:?:} was added in cond.c 1.68 from 2015-05-05, a new unit
test was added, but it didn't cover this edge case. At that time, the
state of the condition parser consisted of a few global variables
instead of a separate data type, as would have been appropriate for
parsing nested conditions.
 1.11 21-Sep-2021  rillig tests/make: demonstrate unintended unquoted string in conditions
 1.10 21-Jun-2021  rillig make: fix grammar in error message for malformed conditional
 1.9 21-Jan-2021  rillig make(1): replace warning + error with just an error in conditionals

Before, there was a "warning" for comparing strings using '<', which was
wrong. That warning was then followed by an error, after parsing the
whole conditional. This was only because it was easier to implement.

Replace the warning with an actual error. This only affects
conditionals in .if lines, the conditionals in the :? modifier such as
${"A" < "B":?smaller:greater} still print 2 errors.
 1.8 21-Jan-2021  rillig make(1): fix debug output for comparison operators in conditionals

This produces fewer warnings than before, but these were edge cases that
probably didn't matter in practice. The "Malformaed conditional" is
still generated, the set of accepted conditionals is still the same.
 1.7 21-Jan-2021  rillig make(1): demonstrate parse error without error message in conditional
 1.6 21-Jan-2021  rillig make(1): add test case for bare word containing quotes
 1.5 21-Jan-2021  rillig make(1): add more tests for edge cases in conditionals
 1.4 21-Jan-2021  rillig make(1): add more tests for tokens in conditionals
 1.3 12-Sep-2020  rillig make(1): add tests for comparison tokens without whitespace
 1.2 11-Sep-2020  rillig make(1): add tests for really strange edge cases in conditions
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.20.2.1 02-Aug-2025  perseant Sync with HEAD
 1.23 06-Jul-2025  rillig make: complain about unfinished escape sequences or string literals
 1.22 06-Jul-2025  rillig tests/make: demonstrate missing error for unfinished word in condition
 1.21 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.20 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.19 19-Nov-2023  rillig branches: 1.19.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.18 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.17 14-Feb-2023  rillig make: don't interpret the return value of Var_Parse

The return value of Var_Parse is largely redundant to the returned
string. The idea behind the type VarParseResult was to migrate all call
sites to checking this return value instead of the returned string, but
that hasn't happened. Instead, the additional type only added more
complexity.

There was a single place where that return value was actually used, when
parsing conditions. And even in that case, ignoring the VarParseResult
added back an error message that previously hid bugs, in the test
cond-token-plain.mk.

Even though these error messages are redundant in the other tests, they
don't hurt as they don't happen often.
 1.16 25-Sep-2022  rillig tests/make: reduce trailing whitespace
 1.15 30-Dec-2021  rillig tests/make: demonstrate edge case that evaluates an expression twice
 1.14 12-Dec-2021  rillig tests/make: refine comments for parsing and evaluating conditions
 1.13 12-Dec-2021  rillig make: rename ParseFuncArg to ParseWord, update comments

No functional change.
 1.12 21-Sep-2021  rillig make: do not allow unquoted 'left == right' after modifier ':?'

Having a static variable for state that clearly belongs in the parser
looked suspicious, and indeed it was wrong.

When the distinction between .if conditions and expressions of the form
${condition:?:} was added in cond.c 1.68 from 2015-05-05, a new unit
test was added, but it didn't cover this edge case. At that time, the
state of the condition parser consisted of a few global variables
instead of a separate data type, as would have been appropriate for
parsing nested conditions.
 1.11 21-Sep-2021  rillig tests/make: demonstrate unintended unquoted string in conditions
 1.10 21-Jan-2021  rillig make(1): demonstrate parse error without error message in conditional
 1.9 21-Jan-2021  rillig make(1): add test case for bare word containing quotes
 1.8 21-Jan-2021  rillig make(1): add more tests for edge cases in conditionals
 1.7 21-Jan-2021  rillig make(1): add more tests for tokens in conditionals
 1.6 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.5 09-Nov-2020  rillig make(1): document handling of '#' and '\n' in conditionals
 1.4 12-Sep-2020  rillig make(1): add tests for comparison tokens without whitespace
 1.3 11-Sep-2020  rillig make(1): add tests for really strange edge cases in conditions
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.19.2.1 02-Aug-2025  perseant Sync with HEAD
 1.20 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.19 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.18 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.17 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.16 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.15 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.14 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.13 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.12 20-Apr-2024  rillig branches: 1.12.2;
make: provide more context information for parse/evaluate errors
 1.11 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.10 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.9 08-May-2022  rillig tests/make: fix typo in variable name
 1.8 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.7 08-Jan-2022  rillig make: fix reported line numbers of continuation lines (since 2002)

Previously, multi-line directives like '.info' or '.error' reported the
line number of their last line instead of their first line, which is
more usual. This also affected the debug log from '-dp'.
 1.6 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.5 21-Jan-2021  rillig make(1): add more tests for tokens in conditionals
 1.4 20-Dec-2020  rillig make(1): error out on unknown variable modifiers at parse time

Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such. This "error message"
also did not influence the exit status in the default mode but only in
-dL mode. The error message also didn't include any line number
information and was thus rude.
 1.3 11-Nov-2020  rillig make(1): fix line numbers in test cond-token-string
 1.2 10-Nov-2020  rillig make(1): add more tests for parsing .if directives

The details of parsing are quite tricky and not documented in the manual
page. Record the current behavior to be a little safer in future
refactorings.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.12.2.1 02-Aug-2025  perseant Sync with HEAD
 1.17 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.16 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.15 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.14 11-Jan-2025  rillig tests/make: force correct order of expected messages
 1.13 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.12 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.11 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.10 20-Apr-2024  rillig branches: 1.10.2;
make: provide more context information for parse/evaluate errors
 1.9 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.6 08-May-2022  rillig tests/make: fix typo in variable name
 1.5 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.4 21-Jan-2021  rillig make(1): add more tests for tokens in conditionals
 1.3 10-Nov-2020  rillig make(1): add more tests for parsing .if directives

The details of parsing are quite tricky and not documented in the manual
page. Record the current behavior to be a little safer in future
refactorings.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.10.2.1 02-Aug-2025  perseant Sync with HEAD
 1.11 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.10 04-Apr-2025  rillig make: fix error message for undefined variable in conditional

Previously, only ${UNDEF} had the proper error message, while
${UNDEF:M*} still produced the wrong "Malformed conditional".
 1.9 04-Apr-2025  rillig tests/make: demonstrate wrong error message for undefined variable

Found by wiz in pkgsrc/x11/gtk3.
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.6 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.5 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.2 20-Aug-2020  rillig make(1): add test for variable expressions in conditions
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.14 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.13 04-Apr-2025  rillig make: fix error message for undefined variable in conditional

Previously, only ${UNDEF} had the proper error message, while
${UNDEF:M*} still produced the wrong "Malformed conditional".
 1.12 04-Apr-2025  rillig tests/make: demonstrate wrong error message for undefined variable

Found by wiz in pkgsrc/x11/gtk3.
 1.11 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.10 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.9 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.8 19-Nov-2023  rillig branches: 1.8.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.7 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 25-Apr-2021  rillig tests/make: add tests for ${...} without operator in conditions

These tests are already covered in cond-cmp-unary.mk, but my first guess
was to search for these tests in cond-token-var.mk, so keep them in both
tests.
 1.5 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 20-Aug-2020  rillig make(1): add test for variable expressions in conditions
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.9 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.8 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.7 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.6 01-Jun-2023  rillig branches: 1.6.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 14-Feb-2023  rillig make: don't interpret the return value of Var_Parse

The return value of Var_Parse is largely redundant to the returned
string. The idea behind the type VarParseResult was to migrate all call
sites to checking this return value instead of the returned string, but
that hasn't happened. Instead, the additional type only added more
complexity.

There was a single place where that return value was actually used, when
parsing conditions. And even in that case, ignoring the VarParseResult
added back an error message that previously hid bugs, in the test
cond-token-plain.mk.

Even though these error messages are redundant in the other tests, they
don't hurt as they don't happen often.
 1.4 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.3 14-Sep-2020  rillig make(1): remove obsolete comments from tests
 1.2 14-Sep-2020  rillig make(1): don't require nested variables to be defined in conditions

This code only applies to lint mode (-dL) for now. After a test phase
and a thorough check for possible side effects, it will be activated in
normal mode, too. Having this code in lint mode is required to run
src/build.sh, which relies a lot on using variables with undefined
nested variables in conditions.

In the default mode, any errors about nested undefined variables are not
printed since in Var_Subst, oldVars is true. Therefore, it is not urgent
to properly handle these nested variables correctly there.
 1.1 14-Sep-2020  rillig make(1): add test for undefined expressions in conditions in lint mode
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.7 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.6 11-Jan-2025  rillig tests/make: force correct order of expected messages
 1.5 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.2 14-Sep-2020  rillig make(1): remove obsolete comments from tests
 1.1 14-Sep-2020  rillig make(1): add test for undefined expressions in conditions in lint mode
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.5 06-Mar-2011  sjg Add unit tests to check that exists(some/dir/) works

Also fix handling of sysV substitutions when lhs and variable are empty.

Also that modifiers do not cause errors during conditional tests
when undefined variables should otherwise be ok.
Ie. .if defined(nosuch) && ${nosuch:Mx} != ""
 1.4 29-Oct-2008  sjg If Parse_Error is called after curFile is invalid, set it to a dummy
to avoid seg-fault. Also the NULL filename will cause ParseVErrorInternal
to skip trying to report file and line number info.

If CondToken is called outside the context of a .if etc, variables in
the expression being parsed will already be expanded, so allow for
an unqouted number to jump us back into the compare logic.
This allows ${${SomeNumber:U42} > 0:?True:False} to work anywhere.

Job_Finish should process postCommands if it has commands or children.
 1.3 13-Apr-2004  sjg branches: 1.3.2;
Allow "string" and "${varspec}" on lhs of conditionals.
This makes it possible to use expressions like
${("${LIST:Msomething"}):?present:absent}
it also makes treatment of lhs and rhs more consistent, and
makes CondToken easier to read.

Update unit-test/cond1 to test new features.
 1.2 08-Apr-2004  sjg Revised patch for catching extraneous .else's
We actually need to tack condTop and skipIfLevel.
Bump MAXIF while here.
Enhance the unit-test for conditionals to exercise more code.

PR: 24420
 1.1 08-Apr-2004  sjg Add check for extraneous .else's - based on patch from Arne H. Juul
in PR/24420.
Add a unit-test for conditionals.
Also in the unit-test makefile strip any .CURDIR in output.

PR: 24420
 1.3.2.4 10-May-2004  tron Pull up revision 1.3 (requested by sjg in ticket #282):
Allow "string" and "${varspec}" on lhs of conditionals.
This makes it possible to use expressions like
${("${LIST:Msomething"}):?present:absent}
it also makes treatment of lhs and rhs more consistent, and
makes CondToken easier to read.
Update unit-test/cond1 to test new features.
 1.3.2.3 10-May-2004  tron Pull up revision 1.2 (requested by sjg in ticket #282):
Revised patch for catching extraneous .else's
We actually need to tack condTop and skipIfLevel.
Bump MAXIF while here.
Enhance the unit-test for conditionals to exercise more code.
PR: 24420
 1.3.2.2 10-May-2004  tron Pull up revision 1.1 (requested by sjg in ticket #282):
Add check for extraneous .else's - based on patch from Arne H. Juul
in PR/24420.
Add a unit-test for conditionals.
Also in the unit-test makefile strip any .CURDIR in output.
PR: 24420
 1.3.2.1 13-Apr-2004  tron file cond1 was added on branch netbsd-2-0 on 2004-05-10 15:23:33 +0000
 1.6 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.5 19-Apr-2021  rillig make: use straight quotes for error 'Bad conditional expression'

This diagnostic was supposed to be an error, see ApplyModifier_IfElse.

When such an error occurs while the makefiles are read, make stops with
an error, as can be expected. But when such an error occurs later,
after all makefiles have been read, the message is printed but make does
not stop.

In lint mode (-dL), make stops in such a case. I didn't dare to make
this the default behavior, out of fear of breaking existing build
infrastructure, not only in NetBSD or pkgsrc, but also FreeBSD and other
operating systems that use the bmake distribution, generated from the
same source code.
 1.4 21-Jan-2021  rillig make(1): replace warning + error with just an error in conditionals

Before, there was a "warning" for comparing strings using '<', which was
wrong. That warning was then followed by an error, after parsing the
whole conditional. This was only because it was easier to implement.

Replace the warning with an actual error. This only affects
conditionals in .if lines, the conditionals in the :? modifier such as
${"A" < "B":?smaller:greater} still print 2 errors.
 1.3 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.2 12-Sep-2020  rillig make(1): fix wording of parse error in conditionals

The word "should" is not appropriate for situations that eventually lead
to a parse error.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.4 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.3 15-Nov-2020  rillig make(1): add remarks to the tests about conditions
 1.2 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 23-Oct-2020  rillig make(1): move tests from cond2.mk to varmod-ifelse.mk
 1.1 05-May-2015  sjg When evaluating condtionals from .if we want to require
that the lhs is a variable reference, a number or a quoted string.
This helps avoid subtle bugs caused by typos.

When conditionals are being evaluated during variable expansion
we cannot be as strict becuase lhs will already have been expanded.

We therefor pass a boolean to Cond_EvalExpression to tell it how
lhs should be treated.

Add unit-tests/cond2.mk to test the above

Reviewed by: christos, joerg
 1.3 23-Oct-2020  rillig make(1): move tests from cond2.mk to varmod-ifelse.mk
 1.2 02-Dec-2015  sjg Fix evaluation of defined(FOO) and ${FOO} > 0
add a unit-test to catch it.
 1.1 05-May-2015  sjg When evaluating condtionals from .if we want to require
that the lhs is a variable reference, a number or a quoted string.
This helps avoid subtle bugs caused by typos.

When conditionals are being evaluated during variable expansion
we cannot be as strict becuase lhs will already have been expanded.

We therefor pass a boolean to Cond_EvalExpression to tell it how
lhs should be treated.

Add unit-tests/cond2.mk to test the above

Reviewed by: christos, joerg
 1.3 23-Sep-2020  rillig make(1): remove debug output from counter tests

Now that the tests work as intended, the debug information is no longer
necessary. It was only intended to track down the cause of the
unexpected behavior.
 1.2 23-Sep-2020  rillig make(1): fix unexpected behavior in ::= variable modifier

Previously, the ::= modifier had returned an error value, which caused
the variable expression to be preserved. This behavior was not useful
in this case; it had only been intended to be used for undefined
variables.

To fix it, distinguish between parse errors, undefined variables and
regular empty strings.
 1.1 23-Sep-2020  rillig make(1): add variant of the counter test

I had expected that using the ::+= modifier instead of the ::= modifier
would work, since the assignment modifier for COUNTER no longer contains
a reference to itself. But instead of ending up at 4, the counter even
goes up to 6.
 1.5 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.4 17-Oct-2020  rillig make(1): document why the counter tests failed before 2020-09-23
 1.3 23-Sep-2020  rillig make(1): remove debug output from counter tests

Now that the tests work as intended, the debug information is no longer
necessary. It was only intended to track down the cause of the
unexpected behavior.
 1.2 23-Sep-2020  rillig make(1): fix unexpected behavior in ::= variable modifier

Previously, the ::= modifier had returned an error value, which caused
the variable expression to be preserved. This behavior was not useful
in this case; it had only been intended to be used for undefined
variables.

To fix it, distinguish between parse errors, undefined variables and
regular empty strings.
 1.1 23-Sep-2020  rillig make(1): add variant of the counter test

I had expected that using the ::+= modifier instead of the ::= modifier
would work, since the assignment modifier for COUNTER no longer contains
a reference to itself. But instead of ending up at 4, the counter even
goes up to 6.
 1.8 23-Sep-2020  rillig make(1): remove debug output from counter tests

Now that the tests work as intended, the debug information is no longer
necessary. It was only intended to track down the cause of the
unexpected behavior.
 1.7 23-Sep-2020  rillig make(1): fix unexpected behavior in ::= variable modifier

Previously, the ::= modifier had returned an error value, which caused
the variable expression to be preserved. This behavior was not useful
in this case; it had only been intended to be used for undefined
variables.

To fix it, distinguish between parse errors, undefined variables and
regular empty strings.
 1.6 22-Sep-2020  rillig make(1): move VAR_JUNK and VAR_KEEP away from VarFlags

These two flags have nothing to do with a variable. They are only used
while evaluating a variable expression.

While here, rename the flags and make their documentation more precise.
 1.5 13-Sep-2020  rillig make(1): shorten debug output of ApplyModifiers

Having the words "eflags" and "vflags" in the debug output was too
repetitive. That they are flags is made obvious by the '|' separator,
and the flags have clearly distinguishable names (VARE_* vs. VAR_*),
which lowers the chance for confusion.
 1.4 08-Aug-2020  rillig make(1): add debug logging for Var_Parse

This will hopefully help with tracking down why the "Undefined variable"
error message is not triggered.

There is some other non-obvious behavior nearby. In Parse_DoVar, the !=
assignment operator evaluates the variable using VARE_UNDEFERR, but
there is not even a warning for the following line:

!= echo err ${UNDEFINED} 1>&2
 1.3 08-Aug-2020  rillig make(1): add more detailed debug logging for variable modifiers

Before a modifier is applied to a variable, it is not yet parsed,
therefore it is only possible to log a rough estimate of the modifier.
But after applying it, the parsing position has advanced, and the full
modifier can be logged.

In addition, to fully understand how the modifiers work, it's not enough
to just know the variable names and values, there are also some flags
that influence how the modifiers behave. The most influential is
VARE_WANTRES.

Thanks to sjg for the extensive review and valuable feedback on the
first drafts.
 1.2 02-Aug-2020  rillig make(1): remove debug output from uncommitted code from test

Note to self: don't accept the test results when there are uncommitted
parts in the code.
 1.1 02-Aug-2020  rillig make(1): add test for nested VAR_SUBST assignments
 1.6 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.5 17-Oct-2020  rillig make(1): document why the counter tests failed before 2020-09-23
 1.4 23-Sep-2020  rillig make(1): remove debug output from counter tests

Now that the tests work as intended, the debug information is no longer
necessary. It was only intended to track down the cause of the
unexpected behavior.
 1.3 23-Sep-2020  rillig make(1): fix unexpected behavior in ::= variable modifier

Previously, the ::= modifier had returned an error value, which caused
the variable expression to be preserved. This behavior was not useful
in this case; it had only been intended to be used for undefined
variables.

To fix it, distinguish between parse errors, undefined variables and
regular empty strings.
 1.2 23-Sep-2020  rillig make(1): add variant of the counter test

I had expected that using the ::+= modifier instead of the ::= modifier
would work, since the assignment modifier for COUNTER no longer contains
a reference to itself. But instead of ending up at 4, the counter even
goes up to 6.
 1.1 02-Aug-2020  rillig make(1): add test for nested VAR_SUBST assignments
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 01-Jun-2023  rillig branches: 1.3.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 25-Sep-2020  rillig make(1): fix missing check for duplicate commands in Parse_File
 1.1 25-Sep-2020  rillig make(1): add test for harmless bug in Parse_File

When there is a dependency group at the end of a top-level makefile,
this dependency group is not finished properly. This allows to add
further commands to the targets of this dependency group, which was not
intended.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 27-Sep-2020  rillig make(1): fix CRLF line endings in unit tests
 1.3 25-Sep-2020  rillig make(1): fix grammar and style in test dep-colon-bug-cross-file
 1.2 25-Sep-2020  rillig make(1): fix missing check for duplicate commands in Parse_File
 1.1 25-Sep-2020  rillig make(1): add test for harmless bug in Parse_File

When there is a dependency group at the end of a top-level makefile,
this dependency group is not finished properly. This allows to add
further commands to the targets of this dependency group, which was not
intended.
 1.2 17-Oct-2020  rillig make(1): add test for "target: source; command"
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 17-Oct-2020  rillig make(1): add test for "target: source; command"
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 23-Oct-2020  rillig make(1): add test for the '::' dependency operator
 1.1 23-Oct-2020  rillig make(1): add test for the '::' dependency operator
 1.2 22-Aug-2020  rillig make(1): add test for :: in the main target
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.4 26-Sep-2020  rillig make(1): add test for '::' dependency operator with .ALLTARGETS
 1.3 22-Aug-2020  rillig make(1): add test for :: in the main target
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.4 25-May-2024  rillig branches: 1.4.2;
tests/make: rename temporary file

The filename extension '.inc' is reserved for files that are checked
into version control.
 1.3 20-Jan-2022  rillig make: fix filename in warning about duplicate script (since 2018-12-22)
 1.2 20-Jan-2022  rillig tests/make: refine test for wrong diagnostic line

To trigger the faulty code path, the file where the targets gets its
first command must be included via its relative path. That was the case
when running 'cd usr.bin/make && make test' but not when running the
tests via ATF.
 1.1 19-Jan-2022  rillig tests/make: demonstrate wrong location in diagnostic (since 2018-12-22)

When a target has multiple places where commands are defined, the
diagnostics mixed up the filename in some cases.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 25-May-2024  rillig tests/make: rename temporary file

The filename extension '.inc' is reserved for files that are checked
into version control.
 1.3 20-Jan-2022  rillig make: fix filename in warning about duplicate script (since 2018-12-22)
 1.2 20-Jan-2022  rillig tests/make: refine test for wrong diagnostic line

To trigger the faulty code path, the file where the targets gets its
first command must be included via its relative path. That was the case
when running 'cd usr.bin/make && make test' but not when running the
tests via ATF.
 1.1 19-Jan-2022  rillig tests/make: demonstrate wrong location in diagnostic (since 2018-12-22)

When a target has multiple places where commands are defined, the
diagnostics mixed up the filename in some cases.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 22-Aug-2020  rillig make(1): add test for "no target to make"
 1.1 22-Aug-2020  rillig make(1): add test for "no target to make"
 1.7 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.6 12-Jun-2025  rillig make: add program name to stack traces from sub-makes
 1.5 12-Jun-2025  rillig make: add quotes to "in directory" line in stack traces

The other lines in stack traces use quotes as well.
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.2 19-Aug-2023  rillig branches: 1.2.2;
make: add more details to error message about invalid lines
 1.1 14-Dec-2021  rillig make: remove unreachable code for parsing the dependency operator

At the point where ParseDependencyOp is called, cp is guaranteed to
point to either ':' or '!'.

No functional change.
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 14-Dec-2021  rillig make: remove unreachable code for parsing the dependency operator

At the point where ParseDependencyOp is called, cp is guaranteed to
point to either ':' or '!'.

No functional change.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Dec-2020  rillig branches: 1.2.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.1 23-Oct-2020  rillig make(1): add test for dependencies of the form '%.o: %.c'
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 23-Oct-2020  rillig make(1): add test for dependencies of the form '%.o: %.c'
 1.10 14-Jan-2025  rillig make: simplify parsing of dependency lines

The evaluation modes that allow or deny undefined variables have the same
effect in this case, as Var_Subst does not return an error marker.
 1.9 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.8 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.7 02-Jun-2024  rillig branches: 1.7.2;
make: sync VarEvalMode constant names with their debug log names
 1.6 19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.5 13-Feb-2023  rillig tests/make: update test for evaluating undefined variables
 1.4 08-Sep-2020  rillig make(1): fix off-by-one error in SuffExpandChildren

In suff.c r1.144 from yesterday, in the line "cp += nested_p - cp", I
accidentally removed the "- 1". Since these "- 1" lines lead to slow
execution, each branch now increments the pointer separately by the
actually needed amount.

Fixing this bug posed way more new questions than it answered, and it
revealed an inconsistency in the parser about how characters are to be
escaped, and missing details in the documentation of Var_Parse, as well
as a parse error that unexpectedly doesn't stop make from continuing.
 1.3 03-Sep-2020  rillig make(1): add test for expansion of indirect variables in dependencies
 1.2 03-Sep-2020  rillig make: extend test for unresolved variables in dependencies

This is to ensure that the upcoming refactoring of Var_Parse in
SuffExpandChildren does not break anything.
 1.1 22-Aug-2020  rillig make(1): add test for deferred variable expansion in dependencies
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.13 14-Jan-2025  rillig make: simplify parsing of dependency lines

The evaluation modes that allow or deny undefined variables have the same
effect in this case, as Var_Subst does not return an error marker.
 1.12 02-Jun-2024  rillig branches: 1.12.2;
make: sync VarEvalMode constant names with their debug log names
 1.11 19-Dec-2023  rillig make: clean up comments

No binary change, except for line numbers in assertions.
 1.10 19-Nov-2023  rillig tests/make: replace 'variable expressions' with 'expressions'
 1.9 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.8 10-May-2023  rillig tests/make: clean up comments in tests
 1.7 13-Feb-2023  rillig tests/make: update test for evaluating undefined variables
 1.6 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.5 13-Sep-2020  rillig make(1): explain why the dep-var test behaves differently in lint mode
 1.4 08-Sep-2020  rillig make(1): fix off-by-one error in SuffExpandChildren

In suff.c r1.144 from yesterday, in the line "cp += nested_p - cp", I
accidentally removed the "- 1". Since these "- 1" lines lead to slow
execution, each branch now increments the pointer separately by the
actually needed amount.

Fixing this bug posed way more new questions than it answered, and it
revealed an inconsistency in the parser about how characters are to be
escaped, and missing details in the documentation of Var_Parse, as well
as a parse error that unexpectedly doesn't stop make from continuing.
 1.3 03-Sep-2020  rillig make(1): add test for expansion of indirect variables in dependencies
 1.2 03-Sep-2020  rillig make: extend test for unresolved variables in dependencies

This is to ensure that the upcoming refactoring of Var_Parse in
SuffExpandChildren does not break anything.
 1.1 22-Aug-2020  rillig make(1): add test for deferred variable expansion in dependencies
 1.12.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 19-Jan-2022  rillig tests/make: demonstrate wrong location in diagnostic (since 2018-12-22)

When a target has multiple places where commands are defined, the
diagnostics mixed up the filename in some cases.
 1.6 14-Dec-2021  rillig make: remove unreachable code for parsing the dependency operator

At the point where ParseDependencyOp is called, cp is guaranteed to
point to either ':' or '!'.

No functional change.
 1.5 23-Oct-2020  rillig make(1): add test for dependencies of the form '%.o: %.c'
 1.4 23-Oct-2020  rillig make(1): add test for the '::' dependency operator
 1.3 25-Sep-2020  rillig make(1): add test for harmless bug in Parse_File

When there is a dependency group at the end of a top-level makefile,
this dependency group is not finished properly. This allows to add
further commands to the targets of this dependency group, which was not
intended.
 1.2 08-Sep-2020  rillig make(1): add test for wildcards in dependency declarations
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 21-Jun-2023  rillig tests/make: document how wildcards behave in a dependency declaration
 1.3 08-Sep-2020  rillig make(1): add test for wildcards in dependency declarations
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 13-Dec-2021  rillig branches: 1.2.4;
tests/make: extend tests for parsing makefiles
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2.4.1 02-Aug-2025  perseant Sync with HEAD
 1.4 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.3 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 23-Oct-2020  rillig make(1): add test case in which .BEGIN depends on .END

Just for fun.
 1.2 27-Apr-2024  rillig make: clean up, test .NOPATH

Trim down the comments in the archive module, as they mainly repeated
the code. Trim down the binary code size in the archive module, as it
is rarely used.

In Var_Parse, delay two variable assignments until they are actually
needed.
 1.1 23-Oct-2020  rillig make(1): add test case in which .BEGIN depends on .END

Just for fun.
 1.2 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.3 26-Dec-2023  sjg branches: 1.3.2;
make: fix order of output in compat mode

Ensure that make's output is correctly ordered with the output of the
target's commands, even when the output does not go to a terminal.

Reviewed by: rillig
 1.2 29-Aug-2020  rillig make(1): add test for the special .IGNORE dependency source
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.4 29-Aug-2020  rillig make(1): explain the shuffled messages in the test output
 1.3 29-Aug-2020  rillig make(1): add test for the special .IGNORE dependency source
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.3 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 26-Jan-2022  rillig tests/make: test meta mode in jobs mode
 1.2 27-Nov-2020  rillig make(1): add very basic test about meta mode

This test is just meant to cover the existing code, it still needs to be
cleaned up to serve as a tutorial and to highlight the really
interesting points.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7 02-Mar-2022  sjg Add nofilemon to meta mode tests

The unit-tests for meta mode do not depend on filemon.
Adding nofilemon to .MAKE.MODE allows these to pass on
a system that would use filemon_dev but does not have
the module loaded.
 1.6 26-Jan-2022  rillig tests/make: test meta mode in jobs mode
 1.5 26-Jan-2022  rillig tests/make: remove unnecessary conditional processing for meta test

The .if/.else distracted from the main topic of the test and made it too
hard to see the main targets.
 1.4 27-Nov-2020  rillig make(1): clean up after a successful .META test
 1.3 27-Nov-2020  rillig make(1): add very basic test about meta mode

This test is just meant to cover the existing code, it still needs to be
cleaned up to serve as a tutorial and to highlight the really
interesting points.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 27-Apr-2024  rillig make: clean up, test .NOPATH

Trim down the comments in the archive module, as they mainly repeated
the code. Trim down the binary code size in the archive module, as it
is rarely used.

In Var_Parse, delay two variable assignments until they are actually
needed.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 27-Apr-2024  rillig make: clean up, test .NOPATH

Trim down the comments in the archive module, as they mainly repeated
the code. Trim down the binary code size in the archive module, as it
is rarely used.

In Var_Parse, delay two variable assignments until they are actually
needed.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7 18-Dec-2020  rillig make(1): spell nonexistent consistently
 1.6 18-Dec-2020  rillig make(1): use symbolic time for 0 in Make_Recheck

This makes the test depsrc-optional independent from the current time
zone.
 1.5 08-Nov-2020  rillig make(1): inline MakeAddChild into ExamineLater

This gets rid of a few void pointers and unspecific variable names like
"l" for the list that should have rather been called "examine" all the
time.

Add quotes around placeholders in debug messages. Especially for targets
like "all" the message had been syntactically misleading.
 1.4 08-Nov-2020  rillig make(1): fix debug output in out-of-date for cohorts (since 2003-11-14)

Before, a wrong cause for being out-of-date was printed in the debug log,
for optional cohorts. This was caused by having the same conditions
duplicated in the code, instead of putting them in a separate function.

Now the optional cohort is correctly identified as using the '::'
dependency operator.
 1.3 08-Nov-2020  rillig make(1): add test for wrong debug message in GNode_IsOODate
 1.2 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 08-Nov-2020  rillig make(1): fix debug output in out-of-date for cohorts (since 2003-11-14)

Before, a wrong cause for being out-of-date was printed in the debug log,
for optional cohorts. This was caused by having the same conditions
duplicated in the code, instead of putting them in a separate function.

Now the optional cohort is correctly identified as using the '::'
dependency operator.
 1.4 08-Nov-2020  rillig make(1): add test for wrong debug message in GNode_IsOODate
 1.3 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 27-Apr-2024  rillig make: clean up, test .NOPATH

Trim down the comments in the archive module, as they mainly repeated
the code. Trim down the binary code size in the archive module, as it
is rarely used.

In Var_Parse, delay two variable assignments until they are actually
needed.
 1.3 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 05-Sep-2020  rillig make(1): add tests for some of the special sources
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 29-Aug-2020  rillig make(1): add tests for .SILENT, .BEGIN and .END
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 29-Aug-2020  rillig make(1): add tests for .SILENT, .BEGIN and .END
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 18-Apr-2022  rillig tests/make: extend tests for .USE and .USEBEFORE
 1.3 22-Aug-2020  rillig make(1): add test for correct command order in .USE sources
 1.2 22-Aug-2020  rillig make(1): add test for the special source .USE
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 18-Apr-2022  rillig tests/make: extend tests for .USE and .USEBEFORE
 1.5 28-Dec-2021  rillig make: do not treat .USEBEFORE as candidate for the main target

A .USE target is not a candidate, so .USEBEFORE shouldn't either.

Since make.h 1.36 from 2001-07-03. In that commit, OP_USEBEFORE should
have been added to OP_NOTARGET.
 1.4 22-Aug-2020  rillig make(1): add test for correct command order in .USE sources
 1.3 22-Aug-2020  rillig make(1): add test for the special source .USE
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 22-Aug-2020  rillig make(1): add test for combining :: and .USEBEFORE
 1.1 22-Aug-2020  rillig make(1): add test for combining :: and .USEBEFORE
 1.4 18-Apr-2022  rillig tests/make: extend tests for .USE and .USEBEFORE
 1.3 22-Aug-2020  rillig make(1): extend test for .USEBEFORE

When several .USEBEFORE targets are added to another target, they are
added in reverse order. But the commands of each .USEBEFORE target are
added in normal order.
 1.2 22-Aug-2020  rillig make(1): add test for the special source .USEBEFORE
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9 18-Apr-2022  rillig tests/make: refine documentation of test for .USEBEFORE
 1.8 18-Apr-2022  rillig tests/make: extend tests for .USE and .USEBEFORE
 1.7 28-Dec-2021  rillig make: do not treat .USEBEFORE as candidate for the main target

A .USE target is not a candidate, so .USEBEFORE shouldn't either.

Since make.h 1.36 from 2001-07-03. In that commit, OP_USEBEFORE should
have been added to OP_NOTARGET.
 1.6 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.5 22-Aug-2020  rillig make(1): extend test for .USEBEFORE

When several .USEBEFORE targets are added to another target, they are
added in reverse order. But the commands of each .USEBEFORE target are
added in normal order.
 1.4 22-Aug-2020  rillig make(1): add test for the special source .USE
 1.3 22-Aug-2020  rillig make(1): add test for the special source .USEBEFORE
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 07-May-2022  rillig make: allow to randomize build order of targets

In complex dependency structures, when a build fails, a probable cause
is a missing dependency declaration between some files. In compat mode,
the build order is deterministic, in jobs mode, it is somewhat
deterministic. To explore more edge cases, add the line ".MAKE.MODE +=
randomize-targets" somewhere in the makefile.

Fixes PR bin/45226 by riastradh. Reviewed by christos.
 1.2 07-Sep-2020  rillig make(1): add test for the .WAIT dependency source
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 07-May-2022  rillig make: allow to randomize build order of targets

In complex dependency structures, when a build fails, a probable cause
is a missing dependency declaration between some files. In compat mode,
the build order is deterministic, in jobs mode, it is somewhat
deterministic. To explore more edge cases, add the line ".MAKE.MODE +=
randomize-targets" somewhere in the makefile.

Fixes PR bin/45226 by riastradh. Reviewed by christos.
 1.3 07-Sep-2020  rillig make(1): add test for the .WAIT dependency source
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.2 22-Dec-2020  rillig make(1): add test for undefined variable in dependency declaration
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.4 22-Dec-2020  rillig make(1): add test for undefined variable in dependency declaration
 1.3 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 24-Nov-2020  rillig branches: 1.2.8;
make(1): fix error handling for .BEGIN dependency in -k mode
 1.1 24-Nov-2020  rillig make(1): add test for bug in error handling of .BEGIN in -k mode
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 24-Nov-2020  rillig make(1): add test for bug in error handling of .BEGIN in -k mode
 1.2 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.1 24-Nov-2020  rillig branches: 1.1.8;
make(1): add test for bug in error handling of .BEGIN in -k mode
 1.1.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 24-Nov-2020  rillig make(1): add test for bug in error handling of .BEGIN in -k mode
 1.6 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.5 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 15-Nov-2020  rillig make(1): add tests for the .BEGIN node
 1.2 29-Aug-2020  rillig make(1): add tests for .SILENT, .BEGIN and .END
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.7 01-Jun-2023  rillig branches: 1.7.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 07-May-2022  rillig make: rename Compat_Run to Compat_MakeAll

No functional change.
 1.5 15-Nov-2020  rillig make(1): document why .BEGIN cannot be combined with .USE/.USEBEFORE
 1.4 15-Nov-2020  rillig make(1): add tests for the .BEGIN node
 1.3 29-Aug-2020  rillig make(1): add tests for .SILENT, .BEGIN and .END
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 01-Dec-2021  rillig tests/make: test target '.DEFAULT'
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 01-Dec-2021  rillig tests/make: test target '.DEFAULT'
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 26-Dec-2023  sjg branches: 1.4.2;
make: fix order of output in compat mode

Ensure that make's output is correctly ordered with the output of the
target's commands, even when the output does not go to a terminal.

Reviewed by: rillig
 1.3 18-Mar-2023  sjg make: handle .PHONY consitently on interrupt

JobDeleteTarget skips .PHONY targets
CompatDeleteTarget should do the same

This addresses https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269663
 1.2 25-Oct-2020  rillig make(1): add test for deleting targets using .DELETE_ON_ERROR
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 25-Oct-2020  rillig make(1): add test for deleting targets using .DELETE_ON_ERROR
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Dec-2020  rillig branches: 1.2.8;
make(1): don't make .END if the main targets already failed

This only applies to -k mode. By default, make exits earlier and skips
the .END node as well if an error occurs.
 1.1 06-Dec-2020  rillig make(1): add test for .END after failed main node
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.2 07-Dec-2020  rillig make(1): don't make .END if the main targets already failed

This only applies to -k mode. By default, make exits earlier and skips
the .END node as well if an error occurs.
 1.1 06-Dec-2020  rillig make(1): add test for .END after failed main node
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 24-Nov-2020  rillig branches: 1.2.8;
make(1): fix error handling for dependency of .END in -k mode

Fix one bug, find 4 new ones. All these bugs have been around since
2005-05-08, when dependencies on the .BEGIN, .END and .INTERRUPT nodes
were implemented. Before that, checking gn->made == ERROR was
appropriate, but adding the dependencies made ABORTED a new possible
error value from Compat_Make.
 1.1 24-Nov-2020  rillig make(1): add test for error in dependency of .END node in -k mode
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.3 07-May-2022  rillig make: rename Compat_Run to Compat_MakeAll

No functional change.
 1.2 06-Dec-2020  rillig make(1): add test for .END after failed main node
 1.1 24-Nov-2020  rillig make(1): add test for error in dependency of .END node in -k mode
 1.7 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.6 07-Dec-2020  rillig branches: 1.6.8;
make(1): don't make .END if the main targets already failed

This only applies to -k mode. By default, make exits earlier and skips
the .END node as well if an error occurs.
 1.5 07-Dec-2020  rillig make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.4 06-Dec-2020  rillig make(1): test all combinations of failed main and .END targets

Adding an individual test for each of the 16 combinations would have
been too much manual work, and it's not easy to come up with a good
naming scheme for all the tests, keeping them short and expressive at
the same time.
 1.3 06-Dec-2020  rillig make(1): add test for .END after failed main node
 1.2 24-Nov-2020  rillig make(1): fix missing "Stop." after failed .END node in -k mode
 1.1 24-Nov-2020  rillig make(1): add test for missing "Stop" after error in .END
 1.6.8.1 02-Aug-2025  perseant Sync with HEAD
 1.7 07-May-2022  rillig make: rename Compat_Run to Compat_MakeAll

No functional change.
 1.6 07-Dec-2020  rillig make(1): don't make .END if the main targets already failed

This only applies to -k mode. By default, make exits earlier and skips
the .END node as well if an error occurs.
 1.5 07-Dec-2020  rillig make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.4 06-Dec-2020  rillig make(1): test all combinations of failed main and .END targets

Adding an individual test for each of the 16 combinations would have
been too much manual work, and it's not easy to come up with a good
naming scheme for all the tests, keeping them short and expressive at
the same time.
 1.3 06-Dec-2020  rillig make(1): add test for .END after failed main node
 1.2 24-Nov-2020  rillig make(1): add test for error in dependency of .END node in -k mode
 1.1 24-Nov-2020  rillig make(1): add test for missing "Stop" after error in .END
 1.1 23-Sep-2020  rillig make(1): fix assertion failure in -j mode with .END node

There had been two separate global variables for the .END node, and in
parallel mode, only the one in jobs.c was initialized.

The code in JobRun heads over to Compat_Make without calling Compat_Run
first, which left the variable ENDNode uninitialized.
 1.1 23-Sep-2020  rillig make(1): fix assertion failure in -j mode with .END node

There had been two separate global variables for the .END node, and in
parallel mode, only the one in jobs.c was initialized.

The code in JobRun heads over to Compat_Make without calling Compat_Run
first, which left the variable ENDNode uninitialized.
 1.4 23-Oct-2020  rillig make(1): add test for .END depending on another target
 1.3 22-Sep-2020  rillig make(1): add test for unintended double expansion of deferred commands
 1.2 29-Aug-2020  rillig make(1): add tests for .SILENT, .BEGIN and .END
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 23-Oct-2020  rillig make(1): add test for .END depending on another target
 1.5 23-Sep-2020  rillig make(1): fix assertion failure in -j mode with .END node

There had been two separate global variables for the .END node, and in
parallel mode, only the one in jobs.c was initialized.

The code in JobRun heads over to Compat_Make without calling Compat_Run
first, which left the variable ENDNode uninitialized.
 1.4 22-Sep-2020  rillig make(1): add test for unintended double expansion of deferred commands
 1.3 29-Aug-2020  rillig make(1): add tests for .SILENT, .BEGIN and .END
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 22-Jan-2022  rillig branches: 1.2.4;
tests/make: add a few more tests, mainly for special targets
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2.4.1 02-Aug-2025  perseant Sync with HEAD
 1.4 22-Jan-2022  rillig tests/make: add a few more tests, mainly for special targets
 1.3 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 22-Jan-2022  rillig branches: 1.2.4;
tests/make: add a few more tests, mainly for special targets
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2.4.1 02-Aug-2025  perseant Sync with HEAD
 1.4 22-Jan-2022  rillig tests/make: add a few more tests, mainly for special targets
 1.3 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 22-Jan-2022  rillig tests/make: add a few more tests, mainly for special targets
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 22-Jan-2022  rillig tests/make: add a few more tests, mainly for special targets
 1.3 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 23-Jan-2022  rillig tests/make: add a few more tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 23-Jan-2022  rillig tests/make: add a few more tests
 1.3 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.8 20-Dec-2023  rillig branches: 1.8.2;
make: fix confusing debug logging when deleting a variable

Be clear when deleting a variable is ignored and state the reason,
instead of only providing a keyword as a hint for insiders.
 1.7 26-Mar-2022  rillig make: add space after colon in debug logging for variables

These log messages are intended for human interpretation, so don't make
them unnecessarily hard to read.
 1.6 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.5 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.4 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.3 08-Nov-2020  rillig make(1): add more tests for parsing .MAKEFLAGS lines
 1.2 23-Oct-2020  rillig make(1): add test for dollar in .MAKEFLAGS target
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 19-Nov-2023  rillig tests/make: replace 'variable expressions' with 'expressions'
 1.8 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.7 29-Nov-2021  rillig tests/make: test escape sequences in string literals for .MAKEFLAGS

These escape sequences differ from those in string literals in
conditions. In "assignments" to .MAKEFLAGS, \n is a newline, while in a
line like '.if ${VAR} == "\n"', it is simply the letter 'n'.
 1.6 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.5 08-Nov-2020  rillig make(1): add more tests for parsing .MAKEFLAGS lines
 1.4 23-Oct-2020  rillig make(1): add test for dollar in .MAKEFLAGS target
 1.3 10-Sep-2020  rillig make(1): add test for .MAKEFLAGS
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.5 28-Dec-2021  rillig branches: 1.5.4;
make: make debug logging for .ORDER more human-friendly

The interesting part of the .ORDER constraint is what is made before
what, so reveal this information in the debug log.

The debug output from the test looks a bit strange since it forces
'three' to be made before 'one', but that's because the test exercises
the edge case of introducing a circular dependency.
 1.4 28-Dec-2021  rillig make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.3 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.2 17-Jun-2021  rillig tests/make: add test for circular dependency in .ORDER
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.4.1 02-Aug-2025  perseant Sync with HEAD
 1.4 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.3 17-Jun-2021  rillig tests/make: add test for circular dependency in .ORDER
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 13-Dec-2021  rillig branches: 1.2.4;
tests/make: extend tests for parsing makefiles
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2.4.1 02-Aug-2025  perseant Sync with HEAD
 1.4 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.3 13-Dec-2021  rillig branches: 1.3.4;
tests/make: extend tests for parsing makefiles
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3.4.1 02-Aug-2025  perseant Sync with HEAD
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 19-May-2024  sjg Dir_FindFile treat sysIncPath and defSysIncPath as special

Rather than play games with adding .DOTLAST and then having to
exclude that from .SYSPATH, just have Dir_FindFile check if
path is sysIncPath or defSysIncPath and behave as if .DOTLAST seen
and also skip the final search of .CURDIR.

Fix Dir_SetSYSPATH to use defSysIncPath if sysIncPath is empty.
 1.4 30-Apr-2024  sjg Subst DEFSYSPATH in deptgt-phony
 1.3 30-Apr-2024  sjg make: ensure '.include <makefile>' respects MAKESYSPATH

Since Dir_FindFile is used by '.include' and its variants,
and will first search .CURDIR unless the give path starts with
".DOTLAST".

Update unit-tests/opt-m-include-dir to test this.
 1.2 11-Feb-2022  rillig tests/make: reproduce filesystem lookup of .PHONY nodes

As described in PR toolchain/15164.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 11-Feb-2022  rillig tests/make: reproduce filesystem lookup of .PHONY nodes

As described in PR toolchain/15164.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 18-Apr-2022  rillig make: only switch to POSIX mode if '.POSIX:' is the first line

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
says that in order to make a makefile POSIX-conforming, its first
non-comment line must be the special dependency line '.POSIX:' without
any source dependencies.

Previously, make switched to POSIX mode even if such a line occurred
anywhere else, which was allowed by POSIX but was deep in the
"unspecified behavior" area. For NetBSD make, there is no big
difference since it doesn't ship any <posix.mk> file, this change mainly
affects the bmake distribution.

Previously, makefiles that contain '.POSIX:' somewhere in the middle
could fail due to <posix.mk> resetting .SUFFIXES, among other things.

Suggested by Simon J. Gerraty, who also reviewed an earlier version of
this change.
 1.4 07-May-2022  rillig tests/make: document why deptgt-posix needs its own directory

As described in PR toolchain/15163, '.include <file>' first looks in the
current directory, using the system include path only as fallback.
 1.3 07-May-2022  rillig tests/make: clean up comments in test for .POSIX
 1.2 18-Apr-2022  sjg Never 'rm -rf ${TMPDIR}' when you cannot be sure what it is

Use a safer variable for a subdir of ${TMPDIR} that we know
we can remove safely.
 1.1 18-Apr-2022  rillig make: only switch to POSIX mode if '.POSIX:' is the first line

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
says that in order to make a makefile POSIX-conforming, its first
non-comment line must be the special dependency line '.POSIX:' without
any source dependencies.

Previously, make switched to POSIX mode even if such a line occurred
anywhere else, which was allowed by POSIX but was deep in the
"unspecified behavior" area. For NetBSD make, there is no big
difference since it doesn't ship any <posix.mk> file, this change mainly
affects the bmake distribution.

Previously, makefiles that contain '.POSIX:' somewhere in the middle
could fail due to <posix.mk> resetting .SUFFIXES, among other things.

Suggested by Simon J. Gerraty, who also reviewed an earlier version of
this change.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 12-Feb-2022  rillig make: fix echoing of command with '-' in silent target in jobs mode

Since job.c 1.83 from 2003-12-20, the command had been echoed even if
the target had the attribute '.SILENT'.

In sh-flags.exp, each removed 'echo' command is below a target name
matching the pattern 'opt-?j????-tgt-??s-cmd-?i?', which means that the
target was marked as silent, either through a global '.SILENT'
declaration or the command line option '-s' or the attribute '.SILENT'
on the target.

Reported by Alan Barrett in PR#45356.
 1.1 12-Feb-2022  rillig tests/make: demonstrate bug for .SILENT in jobs mode (since 2003)

Reported 2011 in PR#45356.
 1.3 15-Apr-2022  rillig tests/make: adjust expectations to actual behavior

The bug in deptgt-silent-jobs.mk has been fixed, the debug logging for
comparing conditions and for deleting global variables has changed
intentionally.
 1.2 12-Feb-2022  rillig make: fix echoing of command with '-' in silent target in jobs mode

Since job.c 1.83 from 2003-12-20, the command had been echoed even if
the target had the attribute '.SILENT'.

In sh-flags.exp, each removed 'echo' command is below a target name
matching the pattern 'opt-?j????-tgt-??s-cmd-?i?', which means that the
target was marked as silent, either through a global '.SILENT'
declaration or the command line option '-s' or the attribute '.SILENT'
on the target.

Reported by Alan Barrett in PR#45356.
 1.1 12-Feb-2022  rillig tests/make: demonstrate bug for .SILENT in jobs mode (since 2003)

Reported 2011 in PR#45356.
 1.3 15-Nov-2020  rillig make(1): add loud target to the .SILENT test
 1.2 10-Sep-2020  rillig make(1): add test for .SILENT
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 15-Nov-2020  rillig make(1): add loud target to the .SILENT test
 1.3 10-Sep-2020  rillig make(1): add test for .SILENT
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 07-May-2025  rillig make: add end marker for -dg1, -dg2 and -dg3 debug log

The marker helps distinguish the output from sub-makes from the output
of the primary make.
 1.4 21-Nov-2020  rillig branches: 1.4.8;
make(1): test that suffixes can be listed in any order
 1.3 21-Oct-2020  rillig make(1): add suffix number to the debug log

Previously, I had taken that lonely number in the debug log for the
sNum, but it was the reference count.
 1.2 28-Aug-2020  rillig make(1): add test for the undocumented .NULL special dependency target
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.8.1 02-Aug-2025  perseant Sync with HEAD
 1.4 21-Nov-2020  rillig make(1): test that suffixes can be listed in any order
 1.3 28-Aug-2020  rillig make(1): add test for the undocumented .NULL special dependency target
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.24 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.23 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.22 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.21 14-Jan-2025  rillig make: simplify parsing of dependency lines

The evaluation modes that allow or deny undefined variables have the same
effect in this case, as Var_Subst does not return an error marker.
 1.20 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.19 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.18 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.17 06-Jul-2024  rillig tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.
 1.16 05-Jul-2024  rillig make: in error messages, distinguish parsing from evaluating
 1.15 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.14 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.13 20-Apr-2024  rillig branches: 1.13.2;
make: provide more context information for parse/evaluate errors
 1.12 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.11 03-Jan-2023  rillig make: add more details to warning 'Extra targets ignored'

Seen in binutils/zlib/Makefile.in:1283, which defines both '.MAKE' and
'.PHONY' in the same line.
 1.10 28-Dec-2021  rillig make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.9 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.8 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.7 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.6 27-Dec-2020  rillig make(1): add test for ParseDependencyTargetWord
 1.5 15-Nov-2020  rillig make(1): add tests for edge cases when parsing directives
 1.4 14-Sep-2020  rillig make(1): in the deptgt test, describe what happens to the targets
 1.3 14-Sep-2020  rillig make(1): add test for the global variable 'targets' in parse.c
 1.2 14-Sep-2020  rillig make(1): add test for combining several special targets
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.24 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.23 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.22 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.21 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.20 06-Jul-2024  rillig tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.
 1.19 05-Jul-2024  rillig make: in error messages, distinguish parsing from evaluating
 1.18 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.17 20-Apr-2024  rillig branches: 1.17.2;
make: provide more context information for parse/evaluate errors
 1.16 17-Dec-2023  rillig tests/make: in 'expect' lines, require the complete text of the line
 1.15 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.14 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.13 03-Jan-2023  rillig make: add more details to warning 'Extra targets ignored'

Seen in binutils/zlib/Makefile.in:1283, which defines both '.MAKE' and
'.PHONY' in the same line.
 1.12 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.11 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.10 27-Dec-2020  rillig make(1): add test for ParseDependencyTargetWord
 1.9 15-Nov-2020  rillig make(1): add tests for edge cases when parsing directives
 1.8 18-Oct-2020  rillig make(1): rename Lst_Init to Lst_New

For the other types such as HashTable and Buffer, the Init function does
not allocate the memory for the structure itself, it only fills it.
 1.7 25-Sep-2020  rillig make(1): remove redundant variable inLine from parse.c

This variable has served at least 27 years bringing unnecessary
redundancy to the code. It was already redundant at 1993-03-21, when
the code was imported to NetBSD.
 1.6 25-Sep-2020  rillig make(1): rename ParseFinishLine to FinishDependencyGroup

Even after 27 or more years, it's not too late to fix bad function
names. This one for example does not finish a line but a dependency
group.
 1.5 14-Sep-2020  rillig make(1): in the deptgt test, describe what happens to the targets
 1.4 14-Sep-2020  rillig make(1): add test for the global variable 'targets' in parse.c
 1.3 14-Sep-2020  rillig make(1): add test for combining several special targets
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.17.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 22-Aug-2020  rillig make(1): add test for expanding wildcards in directories

This test covers DirExpandInt.
 1.1 22-Aug-2020  rillig make(1): add test for expanding wildcards in directories

This test covers DirExpandInt.
 1.7 31-Oct-2020  rillig make(1): add test for debug log for expansion of curly braces
 1.6 31-Oct-2020  rillig make(1): mark the output in test dir.mk with a prefix

This is needed to distinguish it from the debug log, which will be added
in the next commit.
 1.5 31-Jul-2020  rillig make(1): add a test for deeply nested brace dependency
 1.4 31-Jul-2020  rillig make(1): add more tests for expanding curly braces in dependencies
 1.3 31-Jul-2020  rillig make(1): fix regression and add test for empty brace expansion

This had been broken in r1.80 of dir.c, a few minutes ago.
 1.2 31-Jul-2020  rillig make(1): fix parsing of nested braces in dependency lines

Before, make could not parse {{thi,fou}r,fif}teen properly. It did
correctly split up the outer brace into "" + "{thi,fou}r,fif" + "teen",
but then, when expanding the inner braces, it interpreted the first
comma already as a separator, even though this comma was enclosed in
another set of braces.

This resulted in the wrong expansion "{thiteen", which produced the
error message. The next word "fouteen" was produced since the parser
stopped at the next closing brace. After this, parsing continued after
the closing brace, producing "rteen". Finally, the last expansion was
the correct "fifteen".
 1.1 31-Jul-2020  rillig make(1): add test for braces in dependency lines

The comment at DirExpandCurly says something about "recursively", but the
nested braces don't work.

The manual page only mentions that "{} may be used", but it keeps quiet
about the exact meaning and also doesn't mention any nesting.
 1.11 19-Dec-2023  rillig make: clean up comments

No binary change, except for line numbers in assertions.
 1.10 24-Jan-2023  sjg make: .SYSPATH: to add dirs to sysIncPath

.SYSPATH: with no sources will clear sysIncPath
otherwise sources are added

Reviewed by: rillig
 1.9 23-Jan-2021  rillig make(1): rename Dir_Expand to SearchPath_Expand

The main subject of this function is the search path. In this search
path the pattern is expanded.
 1.8 03-Nov-2020  rillig make(1): clean up unit tests
 1.7 31-Oct-2020  rillig make(1): add test for debug log for expansion of curly braces
 1.6 31-Oct-2020  rillig make(1): mark the output in test dir.mk with a prefix

This is needed to distinguish it from the debug log, which will be added
in the next commit.
 1.5 07-Sep-2020  rillig make(1): document that nested braces work as expected now
 1.4 31-Jul-2020  rillig make(1): add a test for deeply nested brace dependency
 1.3 31-Jul-2020  rillig make(1): add more tests for expanding curly braces in dependencies
 1.2 31-Jul-2020  rillig make(1): fix regression and add test for empty brace expansion

This had been broken in r1.80 of dir.c, a few minutes ago.
 1.1 31-Jul-2020  rillig make(1): add test for braces in dependency lines

The comment at DirExpandCurly says something about "recursively", but the
nested braces don't work.

The manual page only mentions that "{} may be used", but it keeps quiet
about the exact meaning and also doesn't mention any nesting.
 1.7 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.3 19-Aug-2023  rillig branches: 1.3.2;
make: add more details to error message about invalid lines
 1.2 23-Jan-2022  rillig tests/make: add a few more tests
 1.1 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 19-Aug-2023  rillig branches: 1.3.2;
make: add more details to error message about invalid lines
 1.2 23-Jan-2022  rillig tests/make: add a few more tests
 1.1 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.8 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.7 01-Jun-2023  rillig branches: 1.7.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 19-Dec-2020  rillig make(1): rewrite tests for misspelled .elif directive

Put the simple tests at the top, demonstrating that there are already
some cases in which the misspelled directive is detected. It's not
detected though if the surrounding conditional branch is skipped.
 1.5 12-Nov-2020  rillig make(1): move test for missing space after .if to correct file
 1.4 12-Nov-2020  rillig make(1): add test for missing space after .if directive
 1.3 10-Nov-2020  rillig make(1): add more tests for parsing .if directives

The details of parsing are quite tricky and not documented in the manual
page. Record the current behavior to be a little safer in future
refactorings.
 1.2 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 19-Dec-2020  rillig make(1): rewrite tests for misspelled .elif directive

Put the simple tests at the top, demonstrating that there are already
some cases in which the misspelled directive is detected. It's not
detected though if the surrounding conditional branch is skipped.
 1.6 12-Nov-2020  rillig make(1): move test for missing space after .if to correct file
 1.5 12-Nov-2020  rillig make(1): add test for missing space after .if directive
 1.4 10-Nov-2020  rillig make(1): add more tests for parsing .if directives

The details of parsing are quite tricky and not documented in the manual
page. Record the current behavior to be a little safer in future
refactorings.
 1.3 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.3 22-Jan-2022  rillig tests/make: explore edge cases involving .ifmake
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 22-Jan-2022  rillig tests/make: add a few more tests, mainly for special targets
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.6 01-Jun-2023  rillig branches: 1.6.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 09-Dec-2021  rillig make: remove period from end of error messages and warnings

The majority of the existing error messages and warnings does not
include a period at the end. Follow this style consistently.
 1.4 14-Dec-2020  rillig make(1): error out on .else with extraneous text
 1.3 13-Nov-2020  rillig make(1): in lint mode, check for ".else <cond>"
 1.2 29-Aug-2020  rillig make(1): add tests for .else and .for + .endif
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 14-Dec-2020  rillig make(1): error out on .else with extraneous text
 1.6 13-Nov-2020  rillig make(1): in lint mode, check for ".else <cond>"
 1.5 13-Nov-2020  rillig make(1): add more tests for parsing .else with argument
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 29-Aug-2020  rillig make(1): add tests for .else and .for + .endif
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.2 01-Jun-2023  rillig branches: 1.2.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.1 30-Dec-2020  rillig make(1): add test for .endfor without corresponding .for
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.1 30-Dec-2020  rillig make(1): add test for .endfor without corresponding .for
 1.7 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.6 01-Jun-2023  rillig branches: 1.6.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.4 09-Dec-2021  rillig make: remove period from end of error messages and warnings

The majority of the existing error messages and warnings does not
include a period at the end. Follow this style consistently.
 1.3 14-Dec-2020  rillig make(1): error out if an '.endif' contains extraneous text
 1.2 14-Dec-2020  rillig make(1): add more tests for parsing .endif
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.5 14-Dec-2020  rillig make(1): error out if an '.endif' contains extraneous text
 1.4 14-Dec-2020  rillig make(1): add more tests for parsing .endif
 1.3 12-Nov-2020  rillig make(1): add test for missing check on .endif with arguments
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 27-Jan-2021  rillig make(1): fix irrelevant message in -W mode
 1.2 26-Jan-2021  rillig make(1): demonstrate irrelevant message about warnings as errors
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 27-Jan-2021  rillig make(1): fix irrelevant message in -W mode
 1.4 26-Jan-2021  rillig make(1): demonstrate irrelevant message about warnings as errors
 1.3 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.3 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.6 19-Nov-2023  rillig branches: 1.6.2;
tests/make: test and explain exporting of variables
 1.5 20-Aug-2023  rillig tests/make: show a difference between 'export' and '.export'
 1.4 19-Aug-2023  rillig make: show realistic invalid line in error message

Previously, the error message 'Invalid line' showed only the expanded
line, which might or might not show the actual problem. To be more
helpful, add the unexpanded line to the error message in case they
differ.

Remove the special handling of invalid lines that result from merge
conflicts. RCS is not commonly used anymore, and mentioning CVS was too
specific. By echoing the whole line, the patterns '<<<<<<' and '>>>>>>'
are clear enough to hint at the problem.
 1.3 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.2 19-Aug-2023  rillig tests/make: provide instructions for reproducing bug in gmtime

The test is not enabled because its results differ too much between the
platforms.
 1.1 02-Oct-2020  rillig make(1): add tests for parsing and exporting variables

Once again, there are a few surprises deeply hidden inside the edge
cases.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.9 17-Dec-2023  rillig branches: 1.9.2;
tests/make: in 'expect' lines, require the complete text of the line
 1.8 19-Nov-2023  rillig tests/make: test and explain exporting of variables
 1.7 20-Aug-2023  rillig tests/make: show a difference between 'export' and '.export'
 1.6 19-Aug-2023  rillig make: show realistic invalid line in error message

Previously, the error message 'Invalid line' showed only the expanded
line, which might or might not show the actual problem. To be more
helpful, add the unexpanded line to the error message in case they
differ.

Remove the special handling of invalid lines that result from merge
conflicts. RCS is not commonly used anymore, and mentioning CVS was too
specific. By echoing the whole line, the patterns '<<<<<<' and '>>>>>>'
are clear enough to hint at the problem.
 1.5 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.4 19-Aug-2023  rillig tests/make: provide instructions for reproducing bug in gmtime

The test is not enabled because its results differ too much between the
platforms.
 1.3 17-Nov-2020  rillig make(1): fix test directive-export-gmake for dash

Dash only accepts environment variables whose names follow the usual
naming conventions. (I didn't look up the exact details.) In
particular, it rejects environment variables whose names start or end
with spaces.

This would result in an empty output from grep, in which case the exit
status from the shell command is non-zero, thus make prints an error
about this. This error message should not appear in the test output, to
keep the test output the same for all platforms.
 1.2 19-Oct-2020  rillig make(1): fix test directive-export-gmake.mk for dash
 1.1 02-Oct-2020  rillig make(1): add tests for parsing and exporting variables

Once again, there are a few surprises deeply hidden inside the edge
cases.
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.21 14-Jan-2025  rillig make: simplify parsing of dependency lines

The evaluation modes that allow or deny undefined variables have the same
effect in this case, as Var_Subst does not return an error marker.
 1.20 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.19 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.18 14-Apr-2024  rillig branches: 1.18.2;
make: add debug logging for .if and .for lines in -dp mode

This helps track down in which line a condition is evaluated.
 1.17 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.16 10-Jan-2022  rillig make: add debug logging for capturing the output of external commands

This applies to all 4 situations in which the output of an external
command is used for modifying a variable or an expression:

* the assignment operator '!='
* the assignment modifier '::!='
* the SUN shell modifier ':sh'
* the other shell modifier ':!cmd!'

Previously, only the shell modifier ':!cmd!' had debug logging.

Suggested by Christoph Badura.
 1.15 28-Dec-2021  rillig make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.14 20-Nov-2021  rillig make: use correct plural form in debug message
 1.13 06-Apr-2021  rillig make: reduce verbosity of the -dv debug logging for standard cases

The verbosity was already removed from LogBeforeApply, now it is
consistent between LogBeforeApply and LogAfterApply.
 1.12 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.11 05-Apr-2021  rillig make: omit unnecessary details from -dv debug log

When an expression is based on a defined variable, it does not matter
whether the evaluation mode is "eval" or "eval-defined", therefore omit
these details to reduce confusion.
 1.10 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.9 05-Apr-2021  rillig make: clean up debug logging for ':M' and ':N'

Using square brackets as quotes was confusing since patterns can contain
square brackets themselves.

The debug logging for VarMatch was a bit too detailed. Having the
"before" and "after" states is enough for all practically relevant
cases.
 1.8 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.7 03-Apr-2021  rillig make: replace enum bit-set with struct bit-fields

This makes the code easier to read, especially when setting one of the
flags to false.

No functional change.
 1.6 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.5 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.4 16-Feb-2021  rillig make: rename constants for VarFlags

The old prefix was "VAR_" and this prefix is used for several other
constants as well, which made it ambiguous.
 1.3 15-Feb-2021  rillig make: rename ExprDefined constants for debug logging
 1.2 02-Feb-2021  rillig make: replace VarExprFlags with VarExprStatus

The combination of !VEF_UNDEF && VEF_DEF was not possible, which made it
rather strange to model this state as a bit set.

The only functional change is the renamed constants in the debug output.

Using ENUM_VALUE_RTTI_2 felt like overengineering since it's harder to
understand than a simple array of names.
 1.1 29-Dec-2020  rillig make(1): add test that explains how variables are exported

Exporting the variables at the right time and with the correct values is
a subtle issue. The current implementation carefully marks variables as
ready to be exported, then exports them and at the same time tries to
export as few variables as possible, to avoid memory leaks. This test
describes and explains how all this works in detail.

This test also justifies that the call to Var_ReexportVars happens in
the make process itself, not in the child processes, no matter whether
these are created with vfork or (only theoretically) with plain fork.
This has changed in compat.c 1.217, job.c 1.390 and main.c 1.504 from
2020-12-27.
 1.18.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 03-Apr-2021  rillig make: replace enum bit-set with struct bit-fields

This makes the code easier to read, especially when setting one of the
flags to false.

No functional change.
 1.2 16-Feb-2021  rillig make: rename constants for VarFlags

The old prefix was "VAR_" and this prefix is used for several other
constants as well, which made it ambiguous.
 1.1 29-Dec-2020  rillig make(1): add test that explains how variables are exported

Exporting the variables at the right time and with the correct values is
a subtle issue. The current implementation carefully marks variables as
ready to be exported, then exports them and at the same time tries to
export as few variables as possible, to avoid memory leaks. This test
describes and explains how all this works in detail.

This test also justifies that the call to Var_ReexportVars happens in
the make process itself, not in the child processes, no matter whether
these are created with vfork or (only theoretically) with plain fork.
This has changed in compat.c 1.217, job.c 1.390 and main.c 1.504 from
2020-12-27.
 1.5 01-Jun-2024  rillig tests/make: test more modifiers and special variables
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 03-Oct-2020  rillig make(1): add test for .export-literal
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8 01-Jun-2024  rillig tests/make: test more modifiers and special variables
 1.7 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.6 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.5 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.4 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.3 03-Oct-2020  rillig make(1): add test for .export-literal
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.8 01-Jun-2024  rillig branches: 1.8.2;
tests/make: require all expected messages to be listed in the .mk files
 1.7 01-Jun-2024  sjg make: add .export-all

An explicit syntax for exporting all global variables is much safer
than allowing .export with no argument to do the same.

Add .export-all and have .export with no argument throw a warning saying
to use .export-all

Reviewed by: rillig
 1.6 19-Nov-2023  rillig tests/make: test and explain exporting of variables
 1.5 20-Aug-2023  rillig tests/make: show a difference between 'export' and '.export'
 1.4 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.3 12-Dec-2020  rillig make(1): extract ExportVars from Var_Export
 1.2 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 01-Jun-2024  rillig tests/make: require all expected messages to be listed in the .mk files
 1.11 01-Jun-2024  sjg make: add .export-all

An explicit syntax for exporting all global variables is much safer
than allowing .export with no argument to do the same.

Add .export-all and have .export with no argument throw a warning saying
to use .export-all

Reviewed by: rillig
 1.10 19-Nov-2023  rillig tests/make: test and explain exporting of variables
 1.9 20-Aug-2023  rillig tests/make: show a difference between 'export' and '.export'
 1.8 16-Feb-2021  rillig make: test exporting a variable that itself depends on a subprocess

When the point that "isn't going to end well" is reached, the stacktrace
is quite long but still reasonable:

main
main_ReadFiles
ReadAllMakefiles
ReadMakefile directive-export.mk
Parse_File
ParseLine # line 3 has: _!= :;:
ParseVarassign
Parse_DoVar
VarAssign_Eval
VarAssign_EvalShell # because of the '!='
Cmd_Exec :;:
Var_ReexportVars # before starting the subprocess
ExportVar EMPTY_SHELL
ExportVarEnv # was only marked for export
Var_Subst ${EMPTY_SHELL} # to get the value to export
VarSubstExpr ${EMPTY_SHELL}
Var_Parse ${EMPTY_SHELL}
Var_Subst ${:sh} # since EMPTY_SHELL= ${:sh}
VarSubstExpr ${:sh}
Var_Parse ${:sh}
ApplyModifiers
ApplySingleModifier :sh
ApplyModifier
ApplyModifier_SunShell :sh
Cmd_Exec "" # empty command
Var_ReexportVars
ExportVar EMPTY_SHELL
ExportVarEnv # skipping this edge case
 1.7 16-Feb-2021  rillig make: clarify what .export ${:U} means
 1.6 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.5 12-Dec-2020  rillig make(1): extract ExportVars from Var_Export
 1.4 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.3 29-Oct-2020  rillig make(1): add test for .export and Var_Delete
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 01-Jun-2023  rillig make: error out on a .break directive with arguments
 1.2 03-Sep-2022  rillig make: clean up handling of .break in .for loops

Move For_Break further up, as the functions in that file are sorted from
small to big. The cast from size_t to unsigned int is required by lint.

In parse.c, move the code into a separate function to keep
ParseDirective small. Its only job is to parse the directive and then
delegate to another function doing the actual work.

In the manual page, remove empty lines.

In the test, ensure that .break stops processing of the .for loop
immediately; anything after the .break is not processed anymore.
Replace ':=' with '=', as there is no need to evaluate '$i' early.
Check the expected value in the .mk file instead of the .exp file, to
keep the reading scope as small as possible.
 1.1 02-Sep-2022  sjg make: add .break to terminate .for loop early

When .break is encountered within a .for loop
it causes immediate termination.

Outside of a .for loop .break causes a parse error.

Reviewed by: christos
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 01-Jun-2023  rillig make: error out on a .break directive with arguments
 1.3 24-Sep-2022  rillig tests/make: add test for .if/.for/.if/.break
 1.2 03-Sep-2022  rillig make: clean up handling of .break in .for loops

Move For_Break further up, as the functions in that file are sorted from
small to big. The cast from size_t to unsigned int is required by lint.

In parse.c, move the code into a separate function to keep
ParseDirective small. Its only job is to parse the directive and then
delegate to another function doing the actual work.

In the manual page, remove empty lines.

In the test, ensure that .break stops processing of the .for loop
immediately; anything after the .break is not processed anymore.
Replace ':=' with '=', as there is no need to evaluate '$i' early.
Check the expected value in the .mk file instead of the .exp file, to
keep the reading scope as small as possible.
 1.1 02-Sep-2022  sjg make: add .break to terminate .for loop early

When .break is encountered within a .for loop
it causes immediate termination.

Outside of a .for loop .break causes a parse error.

Reviewed by: christos
 1.5 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.4 31-May-2024  rillig branches: 1.4.2;
tests/make: replace or document .error in tests

The text 'Missing argument for ".error"' in an .exp file may be a hint
for an accidentally broken test, so eliminate them as far as possible.
 1.3 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 01-Jun-2023  rillig make: add more details to debug logging of .for loops
 1.1 23-May-2022  rillig tests/make: document and demonstrate .for i containing .if empty(i)

PR bin/43821 describes the inconsistency that in a '.for i' loop, the
condition '.if ${i:M*.c}' works since 2009 while the seemingly
equivalent condition '.if !empty(i:M*.c)' does not access the variable
'i' from the .for loop but instead the global 'i'.

Resolving this situation in a backwards-compatible and non-surprising
way is hard, as make has grown several features during the last 20 years
that interact in various edge cases. For now, document the most obvious
pitfalls.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 31-May-2024  rillig tests/make: replace or document .error in tests

The text 'Missing argument for ".error"' in an .exp file may be a hint
for an accidentally broken test, so eliminate them as far as possible.
 1.3 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.2 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.1 23-May-2022  rillig tests/make: document and demonstrate .for i containing .if empty(i)

PR bin/43821 describes the inconsistency that in a '.for i' loop, the
condition '.if ${i:M*.c}' works since 2009 while the seemingly
equivalent condition '.if !empty(i:M*.c)' does not access the variable
'i' from the .for loop but instead the global 'i'.

Resolving this situation in a backwards-compatible and non-surprising
way is hard, as make has grown several features during the last 20 years
that interact in various edge cases. For now, document the most obvious
pitfalls.
 1.14 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.13 03-May-2025  rillig make: miscellaneous cleanups
 1.12 30-Mar-2025  rillig make: if there is an error in the items of a .for loop, don't iterate
 1.11 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.10 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.9 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.8 06-Jul-2024  rillig tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.
 1.7 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.6 20-Apr-2024  rillig branches: 1.6.2;
make: provide more context information for parse/evaluate errors
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 09-May-2023  rillig make: skip syntactically wrong .for loops

When a .for loop cannot be interpreted correctly, for example when there
are no iteration variables or the number of words doesn't match the
iteration variables, skip the body of the .for loop instead of
interpreting it once.
 1.3 08-May-2023  rillig make: disallow characters like '$' in variable names in .for loops

Fixes PR 53146.
 1.2 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.1 31-Dec-2020  rillig make(1): add test for error handling and expansion in .for loops
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.18 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.17 03-May-2025  rillig make: miscellaneous cleanups
 1.16 30-Mar-2025  rillig make: if there is an error in the items of a .for loop, don't iterate
 1.15 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.14 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.13 06-Jul-2024  rillig tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.
 1.12 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.11 01-Jun-2024  rillig branches: 1.11.2;
tests/make: test invalid character in a late .for variable name

This covers the cleanup code that frees the earlier variable names when
a late variable name is invalid.
 1.10 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.9 19-Dec-2023  rillig make: clean up comments

No binary change, except for line numbers in assertions.
 1.8 17-Dec-2023  rillig tests/make: in 'expect' lines, require the complete text of the line
 1.7 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 09-May-2023  rillig make: skip syntactically wrong .for loops

When a .for loop cannot be interpreted correctly, for example when there
are no iteration variables or the number of words doesn't match the
iteration variables, skip the body of the .for loop instead of
interpreting it once.
 1.4 08-May-2023  rillig make: disallow characters like '$' in variable names in .for loops

Fixes PR 53146.
 1.3 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.2 04-Apr-2021  rillig make: rename ambiguous functions

These two functions have counterparts that include the word 'Do' in
their name, which is confusing.

No functional change.
 1.1 31-Dec-2020  rillig make(1): add test for error handling and expansion in .for loops
 1.11.2.1 02-Aug-2025  perseant Sync with HEAD
 1.35 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.34 11-Apr-2025  rillig make: convert more messages to the "file:123" format
 1.33 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.32 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.31 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.30 07-Jul-2024  rillig tests/make: remove '# expect' lines from .exp file

These lines are only supposed to occur in .mk files.
 1.29 06-Jul-2024  rillig tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.
 1.28 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.27 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.26 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.25 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.24 14-Apr-2024  rillig branches: 1.24.2;
make: add debug logging for .if and .for lines in -dp mode

This helps track down in which line a condition is evaluated.
 1.23 19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.22 23-Jun-2023  rillig tests/make: explain and extend tests for expansion in .for loops
 1.21 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.20 01-Jun-2023  rillig make: add more details to debug logging of .for loops
 1.19 09-May-2023  rillig make: skip syntactically wrong .for loops

When a .for loop cannot be interpreted correctly, for example when there
are no iteration variables or the number of words doesn't match the
iteration variables, skip the body of the .for loop instead of
interpreting it once.
 1.18 08-May-2023  rillig make: disallow characters like '$' in variable names in .for loops

Fixes PR 53146.
 1.17 12-Jun-2022  rillig make: document ExprLen, which is part of a .for loop

No binary change
 1.16 27-Jan-2022  rillig tests/make: add more edge cases for expansion of .for loop body
 1.15 27-Jan-2022  rillig tests/make: explain escaping in .for loops, add more test cases
 1.14 09-Jan-2022  rillig tests/make: add placeholders for .PARSEDIR and .INCLUDEDFROMDIR

When run via 'cd usr.bin/make/unit-tests && make test', the tests are in
the current directory. When run via ATF, the tests are in
/usr/tests/usr.bin/make/unit-tests, while the current directory is a
temporary directory. Allow both variants, plus others that may occur in
the bmake distribution.
 1.13 09-Jan-2022  rillig make: fix crash for newline in .for value in -dp mode (since yesterday)
 1.12 02-Sep-2021  rillig make: rename for_var_len to ExprLen

The text ${VAR} is not a variable, it's a variable expression.

No functional change.
 1.11 25-Jun-2021  rillig make: prevent newline injection in .for loops

When a value of a .for loop contained a literal newline, such as from
the expression ${.newline}, that newline was passed verbatim to the
"expanded current body" of the .for loop. There it was interpreted as a
literal newline, which ended the current line and started a new one.
This resulted in several syntax errors.

In cases like these, print a more precise error message.
 1.10 25-Jun-2021  rillig tests/make: demonstrate newline injection in .for loop
 1.9 24-Jun-2021  rillig tests/make: test .for loop over a variable named '$'

It's an impractical edge case, nevertheless it's accepted by make.
 1.8 23-Feb-2021  rillig make: improve error message for unclosed modifier

Replace "variable specification" with the more modern "variable
expression", reduce the number of parentheses, output more than a single
character for modifiers, make it obvious that in expressions such as
${:Serror}, the "" means a variable name.
 1.7 15-Feb-2021  rillig make: improve comments in test for expansions in .for loops
 1.6 25-Jan-2021  rillig make(1): rename struct For to struct ForLoop

This removes the ambiguity whether For_Free is meant to be a
module-exported function or a local function associate with that struct.
Rename the affected functions as well.
 1.5 24-Jan-2021  rillig make(1): describe expansion of nested variables in .for values

These edge cases are not documented anywhere, and their behavior is
non-intuitive. For now, just describe them, don't try to fix them.
There may be people out there relying on exactly this behavior.
 1.4 24-Jan-2021  rillig make(1): let the test directive-for-escape exit successfully

There is no reason for a non-zero exit status here.
 1.3 31-Dec-2020  rillig make(1): add test for common and edge cases in .for loop expansion
 1.2 31-Dec-2020  rillig make(1): add tests for extreme edge cases of .for loop expansion
 1.1 31-Dec-2020  rillig make(1): add test for error handling and expansion in .for loops
 1.24.2.1 02-Aug-2025  perseant Sync with HEAD
 1.30 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.29 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.28 07-Jul-2024  rillig tests/make: remove '# expect' lines from .exp file

These lines are only supposed to occur in .mk files.
 1.27 06-Jul-2024  rillig tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.
 1.26 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.25 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.24 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.23 19-Nov-2023  rillig branches: 1.23.2;
tests/make: replace 'variable expressions' with 'expressions'
 1.22 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.21 23-Jun-2023  rillig tests/make: explain and extend tests for expansion in .for loops
 1.20 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.19 01-Jun-2023  rillig make: add more details to debug logging of .for loops
 1.18 09-May-2023  rillig make: skip syntactically wrong .for loops

When a .for loop cannot be interpreted correctly, for example when there
are no iteration variables or the number of words doesn't match the
iteration variables, skip the body of the .for loop instead of
interpreting it once.
 1.17 08-May-2023  rillig make: disallow characters like '$' in variable names in .for loops

Fixes PR 53146.
 1.16 12-Jun-2022  rillig make: document ExprLen, which is part of a .for loop

No binary change
 1.15 27-Jan-2022  rillig tests/make: add more edge cases for expansion of .for loop body
 1.14 27-Jan-2022  rillig tests/make: explain escaping in .for loops, add more test cases
 1.13 09-Jan-2022  rillig make: fix crash for newline in .for value in -dp mode (since yesterday)
 1.12 05-Dec-2021  rillig make: inline Str_Words into .for loop handling

This saves one memory allocation and a bit of copying, per .for loop.

No functional change.
 1.11 02-Sep-2021  rillig make: rename for_var_len to ExprLen

The text ${VAR} is not a variable, it's a variable expression.

No functional change.
 1.10 25-Jun-2021  rillig make: prevent newline injection in .for loops

When a value of a .for loop contained a literal newline, such as from
the expression ${.newline}, that newline was passed verbatim to the
"expanded current body" of the .for loop. There it was interpreted as a
literal newline, which ended the current line and started a new one.
This resulted in several syntax errors.

In cases like these, print a more precise error message.
 1.9 25-Jun-2021  rillig tests/make: demonstrate newline injection in .for loop
 1.8 24-Jun-2021  rillig tests/make: test .for loop over a variable named '$'

It's an impractical edge case, nevertheless it's accepted by make.
 1.7 15-Feb-2021  rillig make: improve comments in test for expansions in .for loops
 1.6 25-Jan-2021  rillig make(1): rename struct For to struct ForLoop

This removes the ambiguity whether For_Free is meant to be a
module-exported function or a local function associate with that struct.
Rename the affected functions as well.
 1.5 24-Jan-2021  rillig make(1): describe expansion of nested variables in .for values

These edge cases are not documented anywhere, and their behavior is
non-intuitive. For now, just describe them, don't try to fix them.
There may be people out there relying on exactly this behavior.
 1.4 24-Jan-2021  rillig make(1): let the test directive-for-escape exit successfully

There is no reason for a non-zero exit status here.
 1.3 31-Dec-2020  rillig make(1): add test for common and edge cases in .for loop expansion
 1.2 31-Dec-2020  rillig make(1): add tests for extreme edge cases of .for loop expansion
 1.1 31-Dec-2020  rillig make(1): add test for error handling and expansion in .for loops
 1.23.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.3 01-Jun-2023  rillig branches: 1.3.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 02-Jan-2022  rillig make: fix line number in error message about open conditionals
 1.1 29-Aug-2020  rillig make(1): add tests for .else and .for + .endif
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.1 29-Aug-2020  rillig make(1): add tests for .else and .for + .endif
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.3 01-Jun-2023  rillig branches: 1.3.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 01-Sep-2021  rillig tests/make: fix test directive-for-if

The additional lines 'VAR1' and 'VAR3' were supposed to be there from
the beginning. I somehow managed to commit an inconsistent state of the
.mk and the .exp file.
 1.1 30-Aug-2021  rillig tests/make: explain where "${var}" in .for loops comes from
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.2 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.1 30-Aug-2021  rillig tests/make: explain where "${var}" in .for loops comes from
 1.6 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.5 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 19-Dec-2020  rillig make(1): add test for backslash continuation lines in .for loops

This ensures that the line numbers for messages are the expected onces
in .for loops.

While experimenting with the backslash continuation lines, I noticed
that the reported line numbers for these are based on the number of
completely parsed physical lines, which nicely cancels out the + 1 that
has to be added for producing human-readable 1-based line numbers. It
would be more correct to report the parse errors on the first affected
line.
 1.2 19-Dec-2020  rillig make(1): fix line numbers in .for loops (since 2007-01-01)
 1.1 19-Dec-2020  rillig make(1): demonstrate wrong line numbers in .for loops, since 2007-01-01
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.5 01-Jun-2023  rillig branches: 1.5.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.3 19-Dec-2020  rillig make(1): add test for backslash continuation lines in .for loops

This ensures that the line numbers for messages are the expected onces
in .for loops.

While experimenting with the backslash continuation lines, I noticed
that the reported line numbers for these are based on the number of
completely parsed physical lines, which nicely cancels out the + 1 that
has to be added for producing human-readable 1-based line numbers. It
would be more correct to report the parse errors on the first affected
line.
 1.2 19-Dec-2020  rillig make(1): fix line numbers in .for loops (since 2007-01-01)
 1.1 19-Dec-2020  rillig make(1): demonstrate wrong line numbers in .for loops, since 2007-01-01
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 12-Jun-2025  rillig make: add program name to stack traces from sub-makes
 1.7 12-Jun-2025  rillig make: add quotes to "in directory" line in stack traces

The other lines in stack traces use quotes as well.
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.3 01-Apr-2024  rillig branches: 1.3.2;
make: exit immediately after reading a null byte from a makefile

The chance of other garbage bytes in such a file is just too high.
 1.2 09-Dec-2021  rillig make: remove period from end of error messages and warnings

The majority of the existing error messages and warnings does not
include a period at the end. Follow this style consistently.
 1.1 19-Dec-2020  rillig make(1): add test for null byte in .for loop body
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.4 01-Apr-2024  rillig branches: 1.4.2;
make: exit immediately after reading a null byte from a makefile

The chance of other garbage bytes in such a file is just too high.
 1.3 12-Jun-2022  rillig tests/make: make test for null bytes in .for loop more readable
 1.2 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.1 19-Dec-2020  rillig make(1): add test for null byte in .for loop body
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.31 01-Jul-2025  rillig tests/make: require "expect" comments to start a line

Lua's string.gmatch function doesn't allow the anchor "^"; but its
string.gsub function does.
 1.30 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.29 30-Mar-2025  rillig make: if there is an error in the items of a .for loop, don't iterate
 1.28 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.27 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.26 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.25 06-Jul-2024  rillig tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.
 1.24 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.23 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.22 20-Apr-2024  rillig branches: 1.22.2;
make: provide more context information for parse/evaluate errors
 1.21 06-Dec-2023  rillig tests/make: show how global variables are unaffected by .for loops
 1.20 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.19 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.18 01-Jun-2023  rillig make: add more details to debug logging of .for loops
 1.17 10-May-2023  rillig tests/make: clean up tests for .for loops

Most of the tests from forloop.mk were already in directive-for.mk.
 1.16 09-May-2023  rillig make: skip syntactically wrong .for loops

When a .for loop cannot be interpreted correctly, for example when there
are no iteration variables or the number of words doesn't match the
iteration variables, skip the body of the .for loop instead of
interpreting it once.
 1.15 08-May-2023  rillig make: disallow characters like '$' in variable names in .for loops

Fixes PR 53146.
 1.14 08-May-2023  rillig tests/make: add more tests for unusual variable names in .for loops
 1.13 08-May-2023  rillig make: fix parsing of unusual line continuations in .for loops
 1.12 08-Jan-2022  rillig make: fix reported line numbers of continuation lines (since 2002)

Previously, multi-line directives like '.info' or '.error' reported the
line number of their last line instead of their first line, which is
more usual. This also affected the debug log from '-dp'.
 1.11 08-Jan-2022  rillig tests/make: demonstrate edge case in parsing .for loops
 1.10 02-Jan-2022  rillig tests/make: test edge cases in .for loops
 1.9 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.8 27-Dec-2020  rillig make(1): add test for missing error handling in .for loop
 1.7 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.6 25-Oct-2020  rillig make(1): test funny character in .for variable names
 1.5 25-Oct-2020  rillig make(1): add test for escaping parentheses and braces in .for loops
 1.4 22-Sep-2020  rillig make(1): remove obsolete fix for PR bin/29985
 1.3 22-Sep-2020  rillig make(1): add test for .for loop from PR bin/29985
 1.2 14-Sep-2020  rillig make(1): add test for nested .for loops with the same variable name
 1.1 02-Sep-2020  rillig make(1): add test for the .for directive

For a long time, I had assumed that the iteration variables of a .for
loop are just normal global variables. This assumption was wrong but
didn't have any consequences.

The iteration variables of a .for loop can just be accessed like global
variables, therefore it is not obvious that they are implemented in a
completely different way.

There are some edge cases in conditions used inside .for loops, in which
the iteration variables cannot be used like normal variables. An
example is brought up in https://gnats.netbsd.org/47888, which observes
that the defined() and empty() functions in conditions only work with
variables but ignore the iteration "variables", simply because these are
not variables but only expressions.
 1.22.2.1 02-Aug-2025  perseant Sync with HEAD
 1.32 01-Jul-2025  rillig tests/make: require "expect" comments to start a line

Lua's string.gmatch function doesn't allow the anchor "^"; but its
string.gsub function does.
 1.31 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.30 30-Mar-2025  rillig make: if there is an error in the items of a .for loop, don't iterate
 1.29 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.28 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.27 06-Jul-2024  rillig tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.
 1.26 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.25 20-Apr-2024  rillig branches: 1.25.2;
make: provide more context information for parse/evaluate errors
 1.24 06-Dec-2023  rillig tests/make: show how global variables are unaffected by .for loops
 1.23 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.22 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.21 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.20 10-May-2023  rillig tests/make: clean up tests for .for loops

Most of the tests from forloop.mk were already in directive-for.mk.
 1.19 09-May-2023  rillig make: skip syntactically wrong .for loops

When a .for loop cannot be interpreted correctly, for example when there
are no iteration variables or the number of words doesn't match the
iteration variables, skip the body of the .for loop instead of
interpreting it once.
 1.18 08-May-2023  rillig make: disallow characters like '$' in variable names in .for loops

Fixes PR 53146.
 1.17 08-May-2023  rillig tests/make: add more tests for unusual variable names in .for loops
 1.16 08-May-2023  rillig make: fix parsing of unusual line continuations in .for loops
 1.15 01-Oct-2022  rillig tests/make: make comment in test for .for easier to understand
 1.14 23-Aug-2022  rillig tests/make: demonstrate that .for variables take precedence
 1.13 15-Jan-2022  rillig tests/make: ensure that the 'expect' comments in tests are correct

Based on tests/usr.bin/xlint/check-expect.lua.

For now, this extra check needs to be run manually.
 1.12 08-Jan-2022  rillig tests/make: demonstrate edge case in parsing .for loops
 1.11 02-Jan-2022  rillig tests/make: test edge cases in .for loops
 1.10 27-Dec-2020  rillig make(1): add test for missing error handling in .for loop
 1.9 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.8 25-Oct-2020  rillig make(1): test funny character in .for variable names
 1.7 25-Oct-2020  rillig make(1): add test for escaping parentheses and braces in .for loops
 1.6 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.5 22-Sep-2020  rillig make(1): remove obsolete fix for PR bin/29985
 1.4 22-Sep-2020  rillig make(1): add test for .for loop from PR bin/29985
 1.3 14-Sep-2020  rillig make(1): add test for nested .for loops with the same variable name
 1.2 02-Sep-2020  rillig make(1): fix wrong comments in test for the .for loop

These comments were my original assumptions, which I wrote before
running the test and before looking at the implementation.
 1.1 02-Sep-2020  rillig make(1): add test for the .for directive

For a long time, I had assumed that the iteration variables of a .for
loop are just normal global variables. This assumption was wrong but
didn't have any consequences.

The iteration variables of a .for loop can just be accessed like global
variables, therefore it is not obvious that they are implemented in a
completely different way.

There are some edge cases in conditions used inside .for loops, in which
the iteration variables cannot be used like normal variables. An
example is brought up in https://gnats.netbsd.org/47888, which observes
that the defined() and empty() functions in conditions only work with
variables but ignore the iteration "variables", simply because these are
not variables but only expressions.
 1.25.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.3 19-Aug-2023  rillig branches: 1.3.2;
make: add more details to error message about invalid lines
 1.2 23-Jan-2022  rillig tests/make: add a few more tests
 1.1 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 19-Aug-2023  rillig branches: 1.3.2;
make: add more details to error message about invalid lines
 1.2 23-Jan-2022  rillig tests/make: add a few more tests
 1.1 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.1 10-Nov-2020  rillig branches: 1.1.8;
make(1): add more tests for parsing .if directives

The details of parsing are quite tricky and not documented in the manual
page. Record the current behavior to be a little safer in future
refactorings.
 1.1.8.1 02-Aug-2025  perseant Sync with HEAD
 1.2 03-Jan-2025  rillig tests/make: properly label deeply nested .if directives
 1.1 10-Nov-2020  rillig branches: 1.1.8;
make(1): add more tests for parsing .if directives

The details of parsing are quite tricky and not documented in the manual
page. Record the current behavior to be a little safer in future
refactorings.
 1.1.8.1 02-Aug-2025  perseant Sync with HEAD
 1.14 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.13 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.12 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.11 01-Jun-2023  rillig branches: 1.11.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.10 23-Jan-2022  rillig tests/make: add a few more tests
 1.9 09-Jan-2022  rillig tests/make: ensure that '.ifn' is an unknown directive

Due to the way DetermineKindOfConditional works, it could have been that
'.ifn' is treated like the negation of the plain '.if'.
 1.8 19-Dec-2020  rillig make(1): fix error message for .info/.warning/.error without argument

Previously, the error message was "Unknown directive", which was
obviously wrong. The new error message is "Missing argument".
 1.7 14-Dec-2020  rillig make(1): add tests for parsing .if conditions
 1.6 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.5 12-Nov-2020  rillig make(1): move test for missing space after .if to correct file
 1.4 10-Nov-2020  rillig make(1): add more tests for parsing .if directives

The details of parsing are quite tricky and not documented in the manual
page. Record the current behavior to be a little safer in future
refactorings.
 1.3 10-Nov-2020  rillig make(1): fix error message when parsing unknown .if (since 2005-05-01)
 1.2 10-Nov-2020  rillig make(1): add tests for parsing conditionals, document a parsing bug
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.11.2.1 02-Aug-2025  perseant Sync with HEAD
 1.14 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.13 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.12 01-Jun-2023  rillig branches: 1.12.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.11 23-Jan-2022  rillig tests/make: add a few more tests
 1.10 09-Jan-2022  rillig tests/make: ensure that '.ifn' is an unknown directive

Due to the way DetermineKindOfConditional works, it could have been that
'.ifn' is treated like the negation of the plain '.if'.
 1.9 19-Dec-2020  rillig make(1): fix error message for .info/.warning/.error without argument

Previously, the error message was "Unknown directive", which was
obviously wrong. The new error message is "Missing argument".
 1.8 14-Dec-2020  rillig make(1): add tests for parsing .if conditions
 1.7 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.6 12-Nov-2020  rillig make(1): move test for missing space after .if to correct file
 1.5 10-Nov-2020  rillig make(1): add more tests for parsing .if directives

The details of parsing are quite tricky and not documented in the manual
page. Record the current behavior to be a little safer in future
refactorings.
 1.4 10-Nov-2020  rillig make(1): fix error message when parsing unknown .if (since 2005-05-01)
 1.3 10-Nov-2020  rillig make(1): add tests for parsing conditionals, document a parsing bug
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.12.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 23-Jan-2022  rillig tests/make: add a few more tests
 1.3 21-Jan-2021  rillig make(1): add tests for string literals in .ifdef
 1.2 08-Nov-2020  rillig make(1): add test for function call in .ifdef directive
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 23-Jan-2022  rillig tests/make: add a few more tests
 1.4 21-Jan-2021  rillig make(1): add tests for string literals in .ifdef
 1.3 08-Nov-2020  rillig make(1): add test for function call in .ifdef directive
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.8 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.7 01-Jun-2023  rillig branches: 1.7.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 22-Jan-2022  rillig tests/make: explore edge cases involving .ifmake
 1.5 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.4 11-Nov-2020  rillig make(1): add test to cover the If_Eval call in EvalNotEmpty
 1.3 30-Aug-2020  rillig make(1): extend test for .ifmake and .MAKEFLAGS
 1.2 29-Aug-2020  rillig make(1): add test for the .ifmake directive
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.11 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.10 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.9 22-Jan-2022  rillig tests/make: explore edge cases involving .ifmake
 1.8 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.7 11-Nov-2020  rillig make(1): add test to cover the If_Eval call in EvalNotEmpty
 1.6 08-Nov-2020  rillig make(1): add test for .ifmake 0 and .ifmake 1
 1.5 06-Nov-2020  rillig make(1): fix indentation in test directive-ifmake
 1.4 30-Aug-2020  rillig make(1): extend test for .ifmake and .MAKEFLAGS
 1.3 29-Aug-2020  rillig make(1): add test for the .ifmake directive
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.6 19-Jun-2023  rillig branches: 1.6.2;
tests/make: test triple negation in '.ifndef'
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 04-Oct-2020  rillig make(1): add tests for .ifndef and .ifnmake
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.8 19-Jun-2023  rillig tests/make: test triple negation in '.ifndef'
 1.7 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.5 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.4 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.3 04-Oct-2020  rillig make(1): add tests for .ifndef and .ifnmake
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 04-Oct-2020  rillig make(1): add tests for .ifndef and .ifnmake
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.4 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.3 04-Oct-2020  rillig make(1): add tests for .ifndef and .ifnmake
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.6 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.5 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.4 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.3 01-Jun-2023  rillig branches: 1.3.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 13-Sep-2020  rillig make(1): fix line number in expected test result for .include
 1.1 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.5 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 01-Feb-2021  rillig make: rename Parse_include_file to IncludeFile
 1.2 13-Sep-2020  rillig make(1): test another attempt at resuming from fatal errors
 1.1 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.17 11-Apr-2025  rillig make: convert more messages to the "file:123" format
 1.16 07-Aug-2024  rillig make: in erroneous conditions, report the non-expanded text

In a condition, when a function call expression is missing its closing
parenthesis, there's no point in having the expanded argument text in
the error message.

When parsing a bare word in a condition, the trailing space was included
in that word, which was inconsistent, as the leading space was not
included either. Removing the trailing space from the word reduces the
cases where a multiple-inclusion guard steps in, but only in an edge
case that is irrelevant in practice.
 1.15 07-Aug-2024  rillig tests/make: demonstrate unintended parsing of words in conditions

A word is not supposed to include its trailing space, as it doesn't
contain its leading space either.
 1.14 17-Dec-2023  rillig branches: 1.14.2;
tests/make: extend tests for include guards and empty expressions
 1.13 17-Dec-2023  rillig tests/make: add tests for spacing in multiple-inclusion guards
 1.12 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.11 11-Aug-2023  rillig make: clean up multiple-inclusion guards

No functional change.
 1.10 21-Jun-2023  sjg Cleanup guard tests

The .PARSEFILE:tA tests add no value, the correct form
is ${.PARSEDIR:tA}/${.PARSEFILE} but even there :tA rarely matters.
 1.9 21-Jun-2023  rillig make: skip a file protected by a multiple-inclusion guard more often

In practice, the common situation is that a file is first included,
defines its multiple-inclusion guard and is then skipped instead of
being included again.

The other way round is that the multiple-inclusion guard is defined when
the file is included first. In that case, the file is now regarded as
guarded as well.
 1.8 21-Jun-2023  rillig tests/make: clean up and extend tests for multiple-inclusion guards

Multiple-inclusion guards can be defined either as variables or as
targets. Rename the variable tests so they include the word 'variable'.

Add tests to cover special characters in guard names (both variable and
target), just in case ParseVarnameGuard gets removed someday.

Document the pitfalls associated with choosing a naming scheme for
guards that leads to name clashes, such as with .PARSEFILE without
.PARSEDIR.
 1.7 21-Jun-2023  sjg Allow guard targets to use variables.

I commonly use __${.PARSEDIR:tA}__ where a unique guard
is needed, __${.PARSEDIR}__ is also useful in many cases.

Combination of patch from rillig and mine
 1.6 20-Jun-2023  rillig make: allow targets to be used as multiple-inclusion guards

This style is used by FreeBSD, among others.
 1.5 19-Jun-2023  rillig make: add tests for full code coverage of multiple-inclusion guards
 1.4 19-Jun-2023  rillig make: if a makefile is protected by a guard, only include it once

"looks reasonable" sjg@
 1.3 18-Jun-2023  rillig tests/make: clean up test for multiple-inclusion guards
 1.2 18-Jun-2023  rillig tests/make: extend test for multiple-inclusion guards
 1.1 16-Jun-2023  rillig tests/make: add test for multiple-inclusion guards
 1.14.2.1 02-Aug-2025  perseant Sync with HEAD
 1.19 11-Apr-2025  rillig make: convert more messages to the "file:123" format
 1.18 07-Aug-2024  rillig make: in erroneous conditions, report the non-expanded text

In a condition, when a function call expression is missing its closing
parenthesis, there's no point in having the expanded argument text in
the error message.

When parsing a bare word in a condition, the trailing space was included
in that word, which was inconsistent, as the leading space was not
included either. Removing the trailing space from the word reduces the
cases where a multiple-inclusion guard steps in, but only in an edge
case that is irrelevant in practice.
 1.17 07-Aug-2024  rillig tests/make: demonstrate unintended parsing of words in conditions

A word is not supposed to include its trailing space, as it doesn't
contain its leading space either.
 1.16 17-Dec-2023  rillig branches: 1.16.2;
tests/make: extend tests for include guards and empty expressions
 1.15 17-Dec-2023  rillig tests/make: add tests for spacing in multiple-inclusion guards
 1.14 17-Dec-2023  rillig make: clean up names of local variables

No binary change.
 1.13 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.12 11-Aug-2023  rillig make: clean up multiple-inclusion guards

No functional change.
 1.11 21-Jun-2023  sjg Cleanup guard tests

The .PARSEFILE:tA tests add no value, the correct form
is ${.PARSEDIR:tA}/${.PARSEFILE} but even there :tA rarely matters.
 1.10 21-Jun-2023  rillig make: skip a file protected by a multiple-inclusion guard more often

In practice, the common situation is that a file is first included,
defines its multiple-inclusion guard and is then skipped instead of
being included again.

The other way round is that the multiple-inclusion guard is defined when
the file is included first. In that case, the file is now regarded as
guarded as well.
 1.9 21-Jun-2023  rillig tests/make: clean up and extend tests for multiple-inclusion guards

Multiple-inclusion guards can be defined either as variables or as
targets. Rename the variable tests so they include the word 'variable'.

Add tests to cover special characters in guard names (both variable and
target), just in case ParseVarnameGuard gets removed someday.

Document the pitfalls associated with choosing a naming scheme for
guards that leads to name clashes, such as with .PARSEFILE without
.PARSEDIR.
 1.8 21-Jun-2023  sjg Allow guard targets to use variables.

I commonly use __${.PARSEDIR:tA}__ where a unique guard
is needed, __${.PARSEDIR}__ is also useful in many cases.

Combination of patch from rillig and mine
 1.7 20-Jun-2023  rillig make: allow targets to be used as multiple-inclusion guards

This style is used by FreeBSD, among others.
 1.6 19-Jun-2023  rillig make: add tests for full code coverage of multiple-inclusion guards
 1.5 19-Jun-2023  rillig make: if a makefile is protected by a guard, only include it once

"looks reasonable" sjg@
 1.4 18-Jun-2023  rillig tests/make: clean up test for multiple-inclusion guards
 1.3 18-Jun-2023  rillig tests/make: align variable name in test for multiple-inclusion guards
 1.2 18-Jun-2023  rillig tests/make: extend test for multiple-inclusion guards
 1.1 16-Jun-2023  rillig tests/make: add test for multiple-inclusion guards
 1.16.2.1 02-Aug-2025  perseant Sync with HEAD
 1.18 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.17 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.16 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.15 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.14 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.13 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.12 20-Apr-2024  rillig branches: 1.12.2;
make: provide more context information for parse/evaluate errors
 1.11 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.10 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.9 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.8 14-Dec-2021  rillig tests/make: disable test that behaves differently in ATF
 1.7 14-Dec-2021  rillig tests/make: test traditional include directive
 1.6 03-Dec-2021  rillig tests/make: demonstrate .include with erroneous expression
 1.5 03-Dec-2021  rillig tests/make: test .include with expressions
 1.4 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.3 31-Oct-2020  rillig make(1): fix off-by-one bug in ParseTrackInput (since 2015-11-26)
 1.2 31-Oct-2020  rillig make(1): add test for off-by-one bug in ParseTrackInput
 1.1 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.12.2.1 02-Aug-2025  perseant Sync with HEAD
 1.20 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.19 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.18 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.17 11-Jan-2025  rillig tests/make: force correct order of expected messages
 1.16 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.15 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.14 20-Apr-2024  rillig branches: 1.14.2;
make: provide more context information for parse/evaluate errors
 1.13 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.12 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.11 15-Jan-2022  rillig tests/make: ensure that the 'expect' comments in tests are correct

Based on tests/usr.bin/xlint/check-expect.lua.

For now, this extra check needs to be run manually.
 1.10 07-Jan-2022  rillig make: fix null pointer when including empty file (since 2022-01-01)

Calling malloc(0) may return a null pointer, but callers of bmake_malloc
do not expect that.

Reported by Chris Pinnock, found by cross-compiling NetBSD on OpenBSD,
where tools/groff creates Makefile.dep files of size 0.
 1.9 14-Dec-2021  rillig tests/make: disable test that behaves differently in ATF
 1.8 14-Dec-2021  rillig tests/make: test traditional include directive
 1.7 03-Dec-2021  rillig tests/make: demonstrate .include with erroneous expression
 1.6 03-Dec-2021  rillig tests/make: test .include with expressions
 1.5 21-Nov-2020  rillig make(1): add test for .include with trailing garbage in the line
 1.4 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.3 31-Oct-2020  rillig make(1): fix off-by-one bug in ParseTrackInput (since 2015-11-26)
 1.2 31-Oct-2020  rillig make(1): add test for off-by-one bug in ParseTrackInput
 1.1 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.14.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.9 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.8 01-Jun-2023  rillig branches: 1.8.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 08-Jan-2022  rillig make: fix reported line numbers of continuation lines (since 2002)

Previously, multi-line directives like '.info' or '.error' reported the
line number of their last line instead of their first line, which is
more usual. This also affected the debug log from '-dp'.
 1.6 19-Dec-2020  rillig make(1): fix error message for .info/.warning/.error without argument

Previously, the error message was "Unknown directive", which was
obviously wrong. The new error message is "Missing argument".
 1.5 19-Dec-2020  rillig make(1): add test for backslash continuation lines in .for loops

This ensures that the line numbers for messages are the expected onces
in .for loops.

While experimenting with the backslash continuation lines, I noticed
that the reported line numbers for these are based on the number of
completely parsed physical lines, which nicely cancels out the + 1 that
has to be added for producing human-readable 1-based line numbers. It
would be more correct to report the parse errors on the first affected
line.
 1.4 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.3 15-Nov-2020  rillig make(1): add tests for edge cases when parsing directives
 1.2 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.11 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.10 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.9 08-Jan-2022  rillig make: fix reported line numbers of continuation lines (since 2002)

Previously, multi-line directives like '.info' or '.error' reported the
line number of their last line instead of their first line, which is
more usual. This also affected the debug log from '-dp'.
 1.8 19-Dec-2020  rillig make(1): fix error message for .info/.warning/.error without argument

Previously, the error message was "Unknown directive", which was
obviously wrong. The new error message is "Missing argument".
 1.7 19-Dec-2020  rillig make(1): add test for backslash continuation lines in .for loops

This ensures that the line numbers for messages are the expected onces
in .for loops.

While experimenting with the backslash continuation lines, I noticed
that the reported line numbers for these are based on the number of
completely parsed physical lines, which nicely cancels out the + 1 that
has to be added for producing human-readable 1-based line numbers. It
would be more correct to report the parse errors on the first affected
line.
 1.6 13-Dec-2020  rillig make(1): adjust timestamps in unit tests

These could not be known before the previous commit.
 1.5 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.4 15-Nov-2020  rillig make(1): add tests for edge cases when parsing directives
 1.3 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 01-Jun-2023  rillig branches: 1.3.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.1 13-Dec-2020  rillig make(1): add test for misspelled directives

This test allows the other directive-* tests to focus on the purpose of
the individual directive, allowing these tests to continue after
parsing, without errors.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 13-Dec-2020  rillig make(1): adjust timestamps in unit tests

These could not be known before the previous commit.
 1.2 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.1 13-Dec-2020  rillig make(1): add test for misspelled directives

This test allows the other directive-* tests to focus on the purpose of
the individual directive, allowing these tests to continue after
parsing, without errors.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.3 19-Aug-2023  rillig branches: 1.3.2;
make: add more details to error message about invalid lines
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 19-Aug-2023  rillig branches: 1.5.2;
make: add more details to error message about invalid lines
 1.4 23-Jan-2022  rillig tests/make: add a few more tests
 1.3 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.2 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.1 13-Sep-2020  rillig make(1): add tests for the various .include directives
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.15 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.14 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.13 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.12 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.11 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.10 20-Apr-2024  rillig branches: 1.10.2;
make: provide more context information for parse/evaluate errors
 1.9 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.8 08-Jan-2022  rillig make: fix reported line numbers of continuation lines (since 2002)

Previously, multi-line directives like '.info' or '.error' reported the
line number of their last line instead of their first line, which is
more usual. This also affected the debug log from '-dp'.
 1.7 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.6 16-Feb-2021  rillig make: demonstrate inconsistency in .undef of an exported variable
 1.5 22-Dec-2020  rillig make(1): allow .undef to undefine multiple variables at once

Since make doesn't support variable names containing spaces, this edge
case is not enough reason to stop this feature. Having multiple
variable names as arguments nicely aligns with other directives such as
.for and .export.
 1.4 19-Dec-2020  rillig make(1): error out if .undef has not exactly 1 argument
 1.3 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.2 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.10.2.1 02-Aug-2025  perseant Sync with HEAD
 1.17 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.16 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.15 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.14 20-Apr-2024  rillig branches: 1.14.2;
make: provide more context information for parse/evaluate errors
 1.13 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.12 26-Mar-2022  rillig make: fix crash on .undef of an environment variable (since 2020-10-06)
 1.11 25-Mar-2022  rillig tests/make: test .undef for exported global variables
 1.10 16-Feb-2021  rillig make: demonstrate inconsistency in .undef of an exported variable
 1.9 22-Dec-2020  rillig make(1): allow .undef to undefine multiple variables at once

Since make doesn't support variable names containing spaces, this edge
case is not enough reason to stop this feature. Having multiple
variable names as arguments nicely aligns with other directives such as
.for and .export.
 1.8 19-Dec-2020  rillig make(1): error out if .undef has not exactly 1 argument
 1.7 19-Dec-2020  rillig make(1): add tests for undefining variables with exotic names
 1.6 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.5 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 23-Aug-2020  rillig make(1): move test for .undef into separate file
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.14.2.1 02-Aug-2025  perseant Sync with HEAD
 1.15 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.14 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.13 01-Jun-2023  rillig branches: 1.13.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.12 26-Mar-2022  rillig make: add space after colon in debug logging for variables

These log messages are intended for human interpretation, so don't make
them unnecessarily hard to read.
 1.11 06-Apr-2021  rillig make: reduce verbosity of the -dv debug logging for standard cases

The verbosity was already removed from LogBeforeApply, now it is
consistent between LogBeforeApply and LogAfterApply.
 1.10 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.9 05-Apr-2021  rillig make: omit unnecessary details from -dv debug log

When an expression is based on a defined variable, it does not matter
whether the evaluation mode is "eval" or "eval-defined", therefore omit
these details to reduce confusion.
 1.8 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.7 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.6 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.5 15-Feb-2021  rillig make: rename ExprDefined constants for debug logging
 1.4 12-Dec-2020  rillig make(1): error out on misspelled .export directives
 1.3 12-Dec-2020  rillig make(1): error out on misspelled .unexport-env
 1.2 06-Dec-2020  rillig make(1): add test for directive unexport-env
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.8 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.7 12-Dec-2020  rillig make(1): error out on misspelled .export directives
 1.6 12-Dec-2020  rillig make(1): error out on misspelled .unexport-env
 1.5 06-Dec-2020  rillig make(1): fix comment in test for directive unexport-env
 1.4 06-Dec-2020  rillig make(1): add test for directive unexport-env
 1.3 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 01-Jun-2023  rillig branches: 1.7.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.5 12-Dec-2020  rillig make(1): error out on misspelled .export directives
 1.4 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.3 30-Oct-2020  sjg Fix directive-unexport to focus only on the variables we care about
 1.2 30-Oct-2020  rillig make(1): add test for an edge case of .unexport
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 30-Jun-2025  rillig tests/make: force expected lines to be listed in execution order

The diagnostics from the program to check the "expect" lines in the unit
test files were hard to follow since the "out-of-order" lines were
confusing. For out-of-order lines, state where they should be placed
instead.
 1.8 01-Jun-2023  rillig branches: 1.8.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.6 12-Dec-2020  rillig make(1): error out on misspelled .export directives
 1.5 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.4 30-Oct-2020  sjg Fix directive-unexport to focus only on the variables we care about
 1.3 30-Oct-2020  rillig make(1): add test for an edge case of .unexport
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 01-Jul-2025  rillig tests/make: require "expect" comments to start a line

Lua's string.gmatch function doesn't allow the anchor "^"; but its
string.gsub function does.
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.6 01-Jun-2023  rillig branches: 1.6.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.4 19-Dec-2020  rillig make(1): fix error message for .info/.warning/.error without argument

Previously, the error message was "Unknown directive", which was
obviously wrong. The new error message is "Missing argument".
 1.3 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.2 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 01-Jul-2025  rillig tests/make: require "expect" comments to start a line

Lua's string.gmatch function doesn't allow the anchor "^"; but its
string.gsub function does.
 1.9 17-Dec-2023  rillig branches: 1.9.2;
tests/make: in 'expect' lines, require the complete text of the line
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.6 19-Dec-2020  rillig make(1): fix error message for .info/.warning/.error without argument

Previously, the error message was "Unknown directive", which was
obviously wrong. The new error message is "Missing argument".
 1.5 13-Dec-2020  rillig make(1): adjust timestamps in unit tests

These could not be known before the previous commit.
 1.4 13-Dec-2020  rillig make(1): error out on misspelled directives

Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice. See the
test directive-misspellings.mk for further details.
 1.3 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.11 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.10 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.9 19-Aug-2023  rillig branches: 1.9.2;
make: show realistic invalid line in error message

Previously, the error message 'Invalid line' showed only the expanded
line, which might or might not show the actual problem. To be more
helpful, add the unexpanded line to the error message in case they
differ.

Remove the special handling of invalid lines that result from merge
conflicts. RCS is not commonly used anymore, and mentioning CVS was too
specific. By echoing the whole line, the patterns '<<<<<<' and '>>>>>>'
are clear enough to hint at the problem.
 1.8 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.7 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.6 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.5 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.4 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.3 15-Nov-2020  rillig make(1): add tests for edge cases when parsing directives
 1.2 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.9 19-Nov-2023  rillig branches: 1.9.2;
tests/make: replace 'variable expressions' with 'expressions'
 1.8 19-Aug-2023  rillig make: show realistic invalid line in error message

Previously, the error message 'Invalid line' showed only the expanded
line, which might or might not show the actual problem. To be more
helpful, add the unexpanded line to the error message in case they
differ.

Remove the special handling of invalid lines that result from merge
conflicts. RCS is not commonly used anymore, and mentioning CVS was too
specific. By echoing the whole line, the patterns '<<<<<<' and '>>>>>>'
are clear enough to hint at the problem.
 1.7 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.6 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.5 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.4 15-Nov-2020  rillig make(1): add tests for edge cases when parsing directives
 1.3 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.5 28-Jul-2020  rillig make(1): add test for including a nonexistent or empty file
 1.4 28-Jul-2020  rillig make(1): add tests for unknown indented directives

It's quite expected that the .${:Uinfo} is not yet expanded when the
directive is parsed, otherwise the directive would have been accepted.
The surprising thing is that it is expanded at the point where the error
message is generated.
 1.3 28-Jul-2020  rillig make(1): when parsing an unknown directive, print the directive name
 1.2 28-Jul-2020  rillig make(1): refine test for detecting misspellings in directives

The names of directives are only checked if the lines are actually
relevant. In all other cases, the amount of work is reduced to the bare
minimum, which is just to scan for line continuations.
 1.1 27-Jul-2020  rillig make(1): add tests for parsing directives like .if and .info
 1.7 03-Nov-2020  rillig make(1): move tests from directives.mk to separate tests
 1.6 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.5 28-Jul-2020  rillig make(1): add test for including a nonexistent or empty file
 1.4 28-Jul-2020  rillig make(1): add test about possibly ambiguous suffix rule
 1.3 28-Jul-2020  rillig make(1): add tests for unknown indented directives

It's quite expected that the .${:Uinfo} is not yet expanded when the
directive is parsed, otherwise the directive would have been accepted.
The surprising thing is that it is expanded at the point where the error
message is generated.
 1.2 28-Jul-2020  rillig make(1): refine test for detecting misspellings in directives

The names of directives are only checked if the lines are actually
relevant. In all other cases, the amount of work is reduced to the bare
minimum, which is just to scan for line continuations.
 1.1 27-Jul-2020  rillig make(1): add tests for parsing directives like .if and .info
 1.4 03-Nov-2020  rillig make(1): in tests, replace "dollar character" with "dollar sign"
 1.3 17-May-2020  rillig usr.bin/make: fix test for dollar and backslash at eol

The previous version of this test relied on the way how the shell
interprets a lonely backslash at the end of the line. The NetBSD and
FreeBSD shells print the backslash, while Bash doesn't.

While here, make the escaping a bit simpler and align the test
descriptions with the actual test data.
 1.2 10-May-2020  rillig usr.bin/make: fix typo in dollar test
 1.1 10-May-2020  rillig usr.bin/make: add tests for surprising dollar removal
 1.4 03-Nov-2020  rillig make(1): in tests, replace "dollar character" with "dollar sign"
 1.3 17-May-2020  rillig usr.bin/make: fix test for dollar and backslash at eol

The previous version of this test relied on the way how the shell
interprets a lonely backslash at the end of the line. The NetBSD and
FreeBSD shells print the backslash, while Bash doesn't.

While here, make the escaping a bit simpler and align the test
descriptions with the actual test data.
 1.2 10-May-2020  rillig usr.bin/make: fix typo in dollar test
 1.1 10-May-2020  rillig usr.bin/make: add tests for surprising dollar removal
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 08-Apr-2010  sjg Process .ERROR the same as .BEGIN, .END etc
so that it cannot be the default target.
Add unit-tests for .info - .error, and .ERROR.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 25-Oct-2015  sjg branches: 1.2.28;
PrintOnError: fflush stdout before running .ERROR

produces more consistent results in unit-tests.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2.28.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 26-Feb-2006  apb Make ".WAIT" apply recursively to all children of nodes on the right
hand side of the .WAIT, except when the recursive interpretation would
cause a cycle in the dependency graph.

Discussed in tech-toolchain. Reviewed by christos, sjg.
 1.2 08-Oct-2017  sjg Ensure consistent results on different platforms.

With cycle.1.99 being written to stdout and
make: Graph cycles through `cycle.2.*`
to stderr, the order in which they are captured
varies on some platforms.
By redirecting stderr through the same pipe
as stdout we get more consistent result.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.2 08-Oct-2017  sjg Ensure consistent results on different platforms.

With cycle.1.99 being written to stdout and
make: Graph cycles through `cycle.2.*`
to stderr, the order in which they are captured
varies on some platforms.
By redirecting stderr through the same pipe
as stdout we get more consistent result.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 04-Aug-2025  sjg Use printf rather than echo -n
 1.1 04-Aug-2025  sjg echo.inc make ECHO_SCRIPT reusable
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 25-Jul-2020  rillig make(1): add tests for previously uncovered code
 1.6 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.5 04-Feb-2021  rillig make: rename context and ctxt to scope

This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.

Renaming the variable 'ctxt' was trivial since that word is used nowhere
else. In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope. It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.
 1.4 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.3 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.2 27-Jul-2020  rillig make(1): add test for unsetting an environment variable in -e mode
 1.1 25-Jul-2020  rillig make(1): add tests for previously uncovered code
 1.3 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 24-May-2010  sjg Don't missinterpret targets that start with .info
 1.1 08-Apr-2010  sjg Process .ERROR the same as .BEGIN, .END etc
so that it cannot be the default target.
Add unit-tests for .info - .error, and .ERROR.
 1.5 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.4 01-Jun-2023  rillig branches: 1.4.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 03-Nov-2020  rillig make(1): clean up tests error.mk and escape.mk
 1.2 28-Sep-2020  sjg Ensure that parse errors report 'stopped in'
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 03-Nov-2020  rillig make(1): clean up tests error.mk and escape.mk
 1.2 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.8 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.7 09-Sep-2014  apb Add a test for backslash-newline at the very end of a command script.
 1.6 09-Sep-2014  apb Change @echo to echo in several places in escape.mk,
to make it easier to spot changes in what make sends to the shell.
Adjust escape.out to match.
 1.5 24-Aug-2014  apb In either a variable assignmentor a command, backslash-backslash-newline
does not escape the newline. This is compatible with gmake.
 1.4 24-Aug-2014  apb Our practice is that an even number of backslashes before a newline
in a variable assignment simply stores the backslashes as part of the
value, and treats the newline as though it was not escaped. This
is compatible with GNU make.
 1.3 24-Aug-2014  apb Our practice, despite what POSIX might say, is that "\#"
in a variable assignment stores "#" as part of the value.
The "\" is not taken literally, and the "#" does not begin a comment.
 1.2 24-Aug-2014  apb Adjust tests to correct for the fact that end-of-line comments
in variable assignments should not be included in the value.

Also fix more typos.
 1.1 24-Aug-2014  apb Add tests for backslash escaping in make(1).

Many of these tests fail, and I have populated the escape.exp file with
the results that I expect, not with the results that make(1) actually
produces.

Also update the set lists for these tests.
 1.15 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.14 03-Nov-2020  rillig make(1): clean up tests error.mk and escape.mk
 1.13 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.12 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.11 07-Jan-2020  rillig usr.bin/make: fix typos in comment
 1.10 09-Sep-2014  apb branches: 1.10.16;
Add a test for backslash-newline at the very end of a command script.
 1.9 09-Sep-2014  apb Change @echo to echo in several places in escape.mk,
to make it easier to spot changes in what make sends to the shell.
Adjust escape.out to match.
 1.8 24-Aug-2014  apb In either a variable assignmentor a command, backslash-backslash-newline
does not escape the newline. This is compatible with gmake.
 1.7 24-Aug-2014  apb Our practice is that an even number of backslashes before a newline
in a variable assignment simply stores the backslashes as part of the
value, and treats the newline as though it was not escaped. This
is compatible with GNU make.
 1.6 24-Aug-2014  apb Our practice, despite what POSIX might say, is that "\#"
in a variable assignment stores "#" as part of the value.
The "\" is not taken literally, and the "#" does not begin a comment.
 1.5 24-Aug-2014  apb Convert the variable printing tests to use .USE rules,
to ensure that the value printed always comes from the expected variable.
 1.4 24-Aug-2014  apb Adjust tests to correct for the fact that end-of-line comments
in variable assignments should not be included in the value.

Also fix more typos.
 1.3 24-Aug-2014  apb Fix more typos in variable names.
 1.2 24-Aug-2014  apb Fix typos in variable names, and in a comment.
 1.1 24-Aug-2014  apb Add tests for backslash escaping in make(1).

Many of these tests fail, and I have populated the escape.exp file with
the results that I expect, not with the results that make(1) actually
produces.

Also update the set lists for these tests.
 1.10.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 05-Oct-2007  sjg branches: 1.1.2;
Add the ability to .export variables to the environment.
 1.1.2.2 06-Nov-2007  matt sync with HEAD
 1.1.2.1 05-Oct-2007  matt file export was added on branch matt-armv6 on 2007-11-06 23:36:04 +0000
 1.3 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 21-Apr-2010  sjg If we do .export (all) and have any variables that involve :sh
we will hit an error (var is recursive) while trying to evaluate that.
Fix, and add a unit test for this.
 1.1 05-Oct-2007  sjg branches: 1.1.2;
Add the ability to .export variables to the environment.
 1.1.2.2 06-Nov-2007  matt sync with HEAD
 1.1.2.1 05-Oct-2007  matt file export-all was added on branch matt-armv6 on 2007-11-06 23:36:05 +0000
 1.2 10-Apr-2015  sjg export-all.mk should be including export.mk
sadly some shells do not grok named signals.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.6 01-Jun-2024  sjg make: add .export-all

An explicit syntax for exporting all global variables is much safer
than allowing .export with no argument to do the same.

Add .export-all and have .export with no argument throw a warning saying
to use .export-all

Reviewed by: rillig
 1.5 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.4 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.3 27-Jul-2020  rillig make(1): prepare test for .export to show all exported variables

Currently the unit tests don't cover exporting of local variables like
.TARGET or @. To see the effects, all exported variables must be listed
by the tests.
 1.2 10-Apr-2015  sjg export-all.mk should be including export.mk
sadly some shells do not grok named signals.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 22-Mar-2013  sjg branches: 1.1.4; 1.1.10;
Add unit-test for export-env and gmake export
 1.1.10.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.10.1 22-Mar-2013  yamt file export-env was added on branch yamt-pagecache on 2014-05-22 11:42:46 +0000
 1.1.4.2 23-Jun-2013  tls resync from head
 1.1.4.1 22-Mar-2013  tls file export-env was added on branch tls-maxphys on 2013-06-23 06:29:01 +0000
 1.2 18-Feb-2016  sjg Add .export-literal to avoid the need for $$ dance when trying to put
unexpanded variables into environment.

Reviewed by: christos
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.3 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.2 18-Feb-2016  sjg Add .export-literal to avoid the need for $$ dance when trying to put
unexpanded variables into environment.

Reviewed by: christos
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 07-Aug-2020  rillig make(1): add test for exporting variables
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 13-Sep-2020  rillig make(1): fix explanations in test for exporting variables
 1.2 08-Aug-2020  rillig make(1): clean up Var_UnExport

Mark the parameter as constant since it is not modified.

Remove tests for '\n' since these can never succeed.

newenv can never be NULL since neither of bmake_malloc or bmake_realloc
returns NULL.

Improve variable names: vlist was too unexpressive.

Add debug logging since unexporting variables is an uncommon operation
that directly affects the observable environment of the child processes.

Fix CRLF line endings in a few unit tests.
 1.1 07-Aug-2020  rillig make(1): add test for exporting variables
 1.7 09-Feb-2022  rillig tests/make: use more distinctive placeholder for TMPDIR
 1.6 06-Feb-2021  sjg Avoid test failures when more than one user run them.

Use a private TMPDIR
a subdir of .OBJDIR if using it
otherwise /tmp/uid${.MAKE.UID}
 1.5 10-Oct-2020  sjg Limit output of export tests to POSIX compatible env vars
 1.4 22-Aug-2020  sjg Add .SHELL as read-only variable

The .SHELL variable represents the shellPath used to run
scripts.

Reviewed by: rillig, christos
 1.3 27-Jul-2020  rillig make(1): add test for exporting single-character variables
 1.2 27-Jul-2020  rillig make(1): prepare test for .export to show all exported variables

Currently the unit tests don't cover exporting of local variables like
.TARGET or @. To see the effects, all exported variables must be listed
by the tests.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.12 09-Sep-2022  sjg Handle deprecation of egrep
 1.11 05-Dec-2021  rillig tests/make: migrate to jemalloc > 100

When I started working on usr.bin/make in 2020, I used NetBSD 8, which
used jemalloc 100.

After updating to NetBSD 8 to 9.99.x, the debugging options for jemalloc
stopped working since MALLOC_OPTIONS had been replaced with MALLOC_CONF
in 2019.

Enable malloc debugging again, to reliably reproduce the use-after-free
for the variable modifier ':@'.
 1.10 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.9 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.8 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.7 17-Oct-2020  rillig make(1): document why the ampersand is not listed in export.exp
 1.6 27-Sep-2020  rillig make(1): run tests with jemalloc debugging enabled

This protects against very simple memory allocation bugs such as
migrating Lst_ForEachUntil to Lst_ForEach without remembering that
Lst_ForEachUntil can handle the situation where the current list node is
removed from the list, but Lst_ForEach cannot. This happens in
Make_ExpandUse, for example.
 1.5 08-Aug-2020  rillig make(1): clean up Var_UnExport

Mark the parameter as constant since it is not modified.

Remove tests for '\n' since these can never succeed.

newenv can never be NULL since neither of bmake_malloc or bmake_realloc
returns NULL.

Improve variable names: vlist was too unexpressive.

Add debug logging since unexporting variables is an uncommon operation
that directly affects the observable environment of the child processes.

Fix CRLF line endings in a few unit tests.
 1.4 28-Jul-2020  sjg Use egrep rather than grep -E

Also we need to exclude noise that some shells include.
This is why the original test restricted itself to checking
for UT_* in env.
 1.3 27-Jul-2020  rillig make(1): add test for exporting single-character variables
 1.2 27-Jul-2020  rillig make(1): prepare test for .export to show all exported variables

Currently the unit tests don't cover exporting of local variables like
.TARGET or @. To see the effects, all exported variables must be listed
by the tests.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 19-Jun-2012  sjg branches: 1.1.4;
Add unit-tests for .for
 1.1.4.2 30-Oct-2012  yamt sync with head
 1.1.4.1 19-Jun-2012  yamt file forloop was added on branch yamt-pagecache on 2012-10-30 19:00:23 +0000
 1.5 10-May-2023  rillig tests/make: clean up tests for .for loops

Most of the tests from forloop.mk were already in directive-for.mk.
 1.4 03-Nov-2020  rillig make(1): in test forloop.mk, replace shell execution with .info

It's easier to read in the code, and the output has line information to
better relate the output to the code.
 1.3 25-Oct-2020  rillig make(1): use complete words in error message for .for loop
 1.2 01-May-2020  rillig usr.bin/make: add test demonstrating that .for stops at newline
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.8 10-May-2023  rillig tests/make: clean up tests for .for loops

Most of the tests from forloop.mk were already in directive-for.mk.
 1.7 03-Nov-2020  rillig make(1): in test forloop.mk, replace shell execution with .info

It's easier to read in the code, and the output has line information to
better relate the output to the code.
 1.6 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.5 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.4 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.3 02-Sep-2020  rillig make(1): fix typo in unit test for the .for loop
 1.2 01-May-2020  rillig usr.bin/make: add test demonstrating that .for stops at newline
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 07-Oct-2009  sjg The parser used to break dependency lines at ';' without regard
for substitution patterns. This (perhaps coupled with the
new handling of .for variables in ${:U<value>...) caused interesting
results for lines like:

.for file in ${LIST}
for-subst: ${file:S;^;${here}/;g}

add a unit-test to keep an eye on this.
 1.2 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.4 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.3 03-Nov-2020  rillig make(1): document the interesting part of the test forsubst.mk
 1.2 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3 07-May-2025  rillig make: add end marker for -dg1, -dg2 and -dg3 debug log

The marker helps distinguish the output from sub-makes from the output
of the primary make.
 1.2 02-Feb-2021  rillig branches: 1.2.8;
make: remove overengineered Enum_ValueToString

For printing the status of a GNode, there was already made_name (now
renamed to GNodeMade_Name), which prints user-friendly text instead of
the bare enum constant names.

To do this change confidently, I first had to demonstrate that the
output really affects something other than just the word "UNMADE". There
had not been a test for that case before, and the test immediately
discovered a bug in the -dg2 and -dg3 options. This bug is one of the
oldest in make, dating back to at least 1993.
 1.1 07-Nov-2020  rillig make(1): add test for OP_SUBMAKE
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 07-Nov-2020  rillig make(1): add test for OP_SUBMAKE
 1.1 03-Oct-2020  rillig make(1): add test demonstrating the Towers of Hanoi puzzle

It's not the primary task of make to handle procedure calls with
parameters, combined with lexical scoping, therefore the code does not
look as straight-forward or clean as in other programming languages. It
feels more like squeezing a programming problem from the imperative
world into the world of declarative dependencies.

A more idiomatic way of implementing this puzzle should be as a
dependency graph since that's both the natural structure of the puzzle
and the primary domain of make. Something like having a main target
"hanoi-5" that depends on intermediate targets of the form
"move-1.2.3.4.5-_._._._._-_._._._._", each representing a single
configuration of the stacks. These targets could be generated
dynamically. A benefit of this implementation would be that the puzzle
could be resumed from an arbitrary configuration, just just from the
initial configuration.
 1.5 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.4 19-Jan-2023  rillig tests/make: remove dependency on expr(1) from a test

This saves 124 calls to the shell.
 1.3 08-May-2022  rillig tests/make: add test for option '-X', clean up comments
 1.2 08-Jan-2022  rillig tests/make: test line numbers in debug output for parsing files
 1.1 03-Oct-2020  rillig make(1): add test demonstrating the Towers of Hanoi puzzle

It's not the primary task of make to handle procedure calls with
parameters, combined with lexical scoping, therefore the code does not
look as straight-forward or clean as in other programming languages. It
feels more like squeezing a programming problem from the imperative
world into the world of declarative dependencies.

A more idiomatic way of implementing this puzzle should be as a
dependency graph since that's both the natural structure of the puzzle
and the primary domain of make. Something like having a main target
"hanoi-5" that depends on intermediate targets of the form
"move-1.2.3.4.5-_._._._._-_._._._._", each representing a single
configuration of the stacks. These targets could be generated
dynamically. A benefit of this implementation would be that the puzzle
could be resumed from an arbitrary configuration, just just from the
initial configuration.
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 07-Apr-2011  joerg Add the :hash modifier to compute a 32bit hash of an variable.
This uses MurmurHash3 to get a reasonable collission-free hash with
small code. The result is endian neutral.
 1.2 04-Sep-2020  rillig make(1): extend tests for the :hash variable modifier

The previous test vectors didn't contain any hash with a leading zero.
This could have been a simple programming mistake by using %8x instead
of the intended %08x. Using snprintf wouldn't have been possible anyway
since the hex digits are printed in little-endian order, but without
reversing the bits of each digit. Kind of unusual, but doesn't affect
the distribution of the hashes.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 04-Sep-2020  rillig make(1): extend tests for the :hash variable modifier

The previous test vectors didn't contain any hash with a leading zero.
This could have been a simple programming mistake by using %8x instead
of the intended %08x. Using snprintf wouldn't have been possible anyway
since the hex digits are printed in little-endian order, but without
reversing the bits of each digit. Kind of unusual, but doesn't affect
the distribution of the hashes.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 07-Aug-2020  rillig make(1): enable test for .IMPSRC

Having this test disabled was very confusing since its content didn't
match the actual behavior, and this also differs from the GNU make
behavior.
 1.1 23-Aug-2014  christos PR/46096: Jarmo Jaakkola: fix many problems with dependencies (PR 49086)

Quite extensive rewrite of the Suff module. Some ripple effects into
Parse and Targ modules too.

Dependency searches in general were made to honor explicit rules so
implicit and explicit sources are no longer applied on targets that
do not invoke a transformation rule.

Archive member dependency search was rewritten. Explicit rules now
work properly and $(.TARGET) is set correctly. POSIX semantics for
lib(member.o) and .s1.a rules are supported.

.SUFFIXES list maintenance was rewritten so that scanning of existing
rules works when suffixes are added and that clearing the suffix list
removes single suffix rules too. Transformation rule nodes are now
mixed with regular nodes so they are available as regular targets too
if needed (especially after the known suffixes are cleared).

The .NULL target was documented in the manual page, especially to
warn against using it when a single suffix rule would work.
A deprecation warning was also added to the manual and make also
warns the user if it encounters .NULL.

Search for suffix rules no longer allows the explicit dependencies
to override the selected transformation rule. A check is made in
the search that the transformation that would be tried does not
already exist in the chain. This prevents getting stuck in an infinite
loop under specific circumstances. Local variables are now set
before node's children are expanded so dynamic sources work in
multi-stage transformations. Make_HandleUse() no longer expands
the added children for transformation nodes, preventing triple
expansion and allowing the Suff module to properly postpone their
expansion until proper values are set for the local variables.

Directory prefix is no longer removed from $(.PREFIX) if the target
is found via directory search.

The last rule defined is now used instead of the first one (POSIX
requirement) in case a rule is defined multiple times. Everything
defined in the first instance is undone, but things added "globally"
are honored. To implement this, each node tracks attribute bits
which have been set by special targets (global) instead of special
sources (local). They also track dependencies that were added by
a rule with commands (local) instead of rule with no commands (global).

New attribute, OP_FROM_SYS_MK is introduced. It is set on all targets
found in system makefiles so that they are not eligible to become
the main target. We cannot just set OP_NOTMAIN because it is one of
the attributes inherited from transformation and .USE rules and would
make any eligible target that uses a built-in inference rule ineligible.

The $(.IMPSRC) local variable now works like in gmake: it is set to
the first prerequisite for explicit rules. For implicit rules it
is still the implied source.

The manual page is improved regarding the fixed features. Test cases
for the fixed problems are added.

Other improvements in the Suff module include:
- better debug messages for transformation rule search (length of
the chain is now visualized by indentation)
- Suff structures are created, destroyed and moved around by a set
of maintenance functions so their reference counts are easier
to track (this also gets rid of a lot of code duplication)
- some unreasonably long functions were split into smaller ones
- many local variables had their names changed to describe their
purpose instead of their type
 1.3 07-Aug-2020  rillig make(1): enable test for .IMPSRC

Having this test disabled was very confusing since its content didn't
match the actual behavior, and this also differs from the GNU make
behavior.
 1.2 30-Aug-2014  sjg Replace use of $() with ${}
$() means something special to the shell, so ${} reduces confusion
and is used almost exclusively in the rest of the makefiles.

Discussed with: christos
 1.1 23-Aug-2014  christos PR/46096: Jarmo Jaakkola: fix many problems with dependencies (PR 49086)

Quite extensive rewrite of the Suff module. Some ripple effects into
Parse and Targ modules too.

Dependency searches in general were made to honor explicit rules so
implicit and explicit sources are no longer applied on targets that
do not invoke a transformation rule.

Archive member dependency search was rewritten. Explicit rules now
work properly and $(.TARGET) is set correctly. POSIX semantics for
lib(member.o) and .s1.a rules are supported.

.SUFFIXES list maintenance was rewritten so that scanning of existing
rules works when suffixes are added and that clearing the suffix list
removes single suffix rules too. Transformation rule nodes are now
mixed with regular nodes so they are available as regular targets too
if needed (especially after the known suffixes are cleared).

The .NULL target was documented in the manual page, especially to
warn against using it when a single suffix rule would work.
A deprecation warning was also added to the manual and make also
warns the user if it encounters .NULL.

Search for suffix rules no longer allows the explicit dependencies
to override the selected transformation rule. A check is made in
the search that the transformation that would be tried does not
already exist in the chain. This prevents getting stuck in an infinite
loop under specific circumstances. Local variables are now set
before node's children are expanded so dynamic sources work in
multi-stage transformations. Make_HandleUse() no longer expands
the added children for transformation nodes, preventing triple
expansion and allowing the Suff module to properly postpone their
expansion until proper values are set for the local variables.

Directory prefix is no longer removed from $(.PREFIX) if the target
is found via directory search.

The last rule defined is now used instead of the first one (POSIX
requirement) in case a rule is defined multiple times. Everything
defined in the first instance is undone, but things added "globally"
are honored. To implement this, each node tracks attribute bits
which have been set by special targets (global) instead of special
sources (local). They also track dependencies that were added by
a rule with commands (local) instead of rule with no commands (global).

New attribute, OP_FROM_SYS_MK is introduced. It is set on all targets
found in system makefiles so that they are not eligible to become
the main target. We cannot just set OP_NOTMAIN because it is one of
the attributes inherited from transformation and .USE rules and would
make any eligible target that uses a built-in inference rule ineligible.

The $(.IMPSRC) local variable now works like in gmake: it is set to
the first prerequisite for explicit rules. For implicit rules it
is still the implied source.

The manual page is improved regarding the fixed features. Test cases
for the fixed problems are added.

Other improvements in the Suff module include:
- better debug messages for transformation rule search (length of
the chain is now visualized by indentation)
- Suff structures are created, destroyed and moved around by a set
of maintenance functions so their reference counts are easier
to track (this also gets rid of a lot of code duplication)
- some unreasonably long functions were split into smaller ones
- many local variables had their names changed to describe their
purpose instead of their type
 1.15 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.14 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.13 01-Jun-2023  rillig branches: 1.13.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.12 19-Jan-2023  rillig tests/make: rename files that are not test cases
 1.11 09-Jan-2022  rillig make: remove redundant lines from stack traces

These lines repeated the information from the .for loop line above them.
 1.10 08-Jan-2022  rillig make: add details about .for loop variables to stack traces

The stack traces are enabled with the debug logging option '-dp'.
 1.9 08-Jan-2022  rillig make: fix stack traces in -dp mode (since 2021-01-26)

Previously, the stack traces omitted some lines that seemed to be
redundant. As a result, the stack traces contained confusing line
numbers.
 1.8 28-Dec-2021  rillig make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.7 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.6 26-Jan-2021  rillig make(1): in -dp mode, print stack trace with each diagnostic

This makes it easier to track down where a warning or an error
originated from. This information could be further enriched for .for
loops, to also include the variable names and their values. For now,
it's good enough to replace the large comment describing how a stack
trace _could_ be generated with actual code that implements that idea.

The syntax of the locations is <filename>:<lineno>, which intentionally
differs from the traditional "<filename>" line <lineno>, since the
former is more widely supported by editors and IDEs.

Having this stacktrace information is especially intended for
complicated systems built upon make, such as pkgsrc.
 1.5 14-Sep-2020  rillig make(1): describe how Parse_Error might print stack traces

In deeply nested include chains and .for loops this may be a useful
feature. It's a little tricky to generate an intuitive stack trace,
though not impossible. This explanation also serves as a detailed
documentation about how the .include and .for directives are
implemented.
 1.4 05-Sep-2020  rillig make(1): fix .INCLUDEDFROMDIR/.INCLUDEDFROMFILE
 1.3 05-Sep-2020  rillig make(1): add test for .INCLUDEDFILE combined with .for loops

The .for loops are implemented as a special kind of .include, therefore
they affect the .INCLUDEDFROM variable.
 1.2 05-Sep-2020  rillig make(1): make test for .INCLUDEDFROMDIR simpler

The .info and .warning directives provide exactly the early expansion
that this test needs. No more .for for getting a snapshot of a
variable.
 1.1 17-May-2020  rillig usr.bin/make: demonstrate actual behavior of .INCLUDEDFROMFILE
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.8 19-Jan-2023  rillig tests/make: rename files that are not test cases
 1.7 08-Jan-2022  rillig make: fix stack traces in -dp mode (since 2021-01-26)

Previously, the stack traces omitted some lines that seemed to be
redundant. As a result, the stack traces contained confusing line
numbers.
 1.6 22-Jan-2021  rillig make(1): fix test for .INCLUDEDFROMFILE

The test did not test the intended variable before.

If the implementation of the .INCLUDEDFROMFILE had been wrong before,
the test would have succeeded nevertheless since it tested whether the
variable named "include-main.mk" was defined, which was obviously never
the case since that's the value of the variable, not the name.
 1.5 05-Sep-2020  rillig make(1): fix .INCLUDEDFROMDIR/.INCLUDEDFROMFILE
 1.4 05-Sep-2020  rillig make(1): add test for .INCLUDEDFILE combined with .for loops

The .for loops are implemented as a special kind of .include, therefore
they affect the .INCLUDEDFROM variable.
 1.3 05-Sep-2020  rillig make(1): make test for .INCLUDEDFROMDIR simpler

The .info and .warning directives provide exactly the early expansion
that this test needs. No more .for for getting a snapshot of a
variable.
 1.2 27-Jul-2020  rillig make(1): document where to fix the .INCLUDEDFROM bug
 1.1 17-May-2020  rillig usr.bin/make: demonstrate actual behavior of .INCLUDEDFROMFILE
 1.1 19-Jan-2023  rillig tests/make: rename files that are not test cases
 1.10 19-Jan-2023  rillig tests/make: rename files that are not test cases
 1.9 08-Jan-2022  rillig make: fix stack traces in -dp mode (since 2021-01-26)

Previously, the stack traces omitted some lines that seemed to be
redundant. As a result, the stack traces contained confusing line
numbers.
 1.8 07-Jan-2022  rillig make: rename IFile and its fields to match their actual content

For lines that use backslash continuation, the human-readable line
number does not equal the number of raw lines that have been read from
the file.

The big comment in PrintStackTrace has become outdated, it still
referred to first_lineno. Due to the bugs documented in
opt-debug-parse.mk, that function needs to be redone completely.

No functional change.
 1.7 02-Nov-2020  rillig make(1): remove word "Ptr" from variable names

Whether or not a variable is a pointer is obvious from the context.
Since the introduction of function prototypes in C90, this information
is checked by the compiler and no longer needs to be encoded in the
variable names.
 1.6 25-Oct-2020  rillig make(1): rename type Vector to PtrVector

This allows the name Vector to be used for a more generic vector type,
which will be added soon.
 1.5 18-Oct-2020  rillig make(1): rename Stack to Vector

Both Var_Dump and GetActuallyIncludingFile access more than only the top
item of the stack, therefore it is more honest to rename the data type.
 1.4 14-Sep-2020  rillig make(1): describe how Parse_Error might print stack traces

In deeply nested include chains and .for loops this may be a useful
feature. It's a little tricky to generate an intuitive stack trace,
though not impossible. This explanation also serves as a detailed
documentation about how the .include and .for directives are
implemented.
 1.3 05-Sep-2020  rillig make(1): add test for .INCLUDEDFILE combined with .for loops

The .for loops are implemented as a special kind of .include, therefore
they affect the .INCLUDEDFROM variable.
 1.2 05-Sep-2020  rillig make(1): make test for .INCLUDEDFROMDIR simpler

The .info and .warning directives provide exactly the early expansion
that this test needs. No more .for for getting a snapshot of a
variable.
 1.1 17-May-2020  rillig usr.bin/make: demonstrate actual behavior of .INCLUDEDFROMFILE
 1.1 19-Jan-2023  rillig tests/make: rename files that are not test cases
 1.5 19-Jan-2023  rillig tests/make: rename files that are not test cases
 1.4 26-Jan-2021  rillig make(1): in -dp mode, print stack trace with each diagnostic

This makes it easier to track down where a warning or an error
originated from. This information could be further enriched for .for
loops, to also include the variable names and their values. For now,
it's good enough to replace the large comment describing how a stack
trace _could_ be generated with actual code that implements that idea.

The syntax of the locations is <filename>:<lineno>, which intentionally
differs from the traditional "<filename>" line <lineno>, since the
former is more widely supported by editors and IDEs.

Having this stacktrace information is especially intended for
complicated systems built upon make, such as pkgsrc.
 1.3 05-Sep-2020  rillig make(1): add test for .INCLUDEDFILE combined with .for loops

The .for loops are implemented as a special kind of .include, therefore
they affect the .INCLUDEDFROM variable.
 1.2 05-Sep-2020  rillig make(1): make test for .INCLUDEDFROMDIR simpler

The .info and .warning directives provide exactly the early expansion
that this test needs. No more .for for getting a snapshot of a
variable.
 1.1 17-May-2020  rillig usr.bin/make: demonstrate actual behavior of .INCLUDEDFROMFILE
 1.2 14-Nov-2020  rillig make(1): test ignoring errors from shell commands in jobs mode
 1.1 07-Nov-2020  rillig make(1): add test for job command flags
 1.2 14-Nov-2020  rillig make(1): test ignoring errors from shell commands in jobs mode
 1.1 07-Nov-2020  rillig make(1): add test for job command flags
 1.2 29-Sep-2020  rillig make(1): fix test job-output-long-lines

The test failed on Linux since the test relied on the two child
processes interleaving each other. This is not guaranteed to happen
though.
 1.1 27-Sep-2020  rillig make(1): add test for merging long lines of job output
 1.4 01-Nov-2020  rillig make(1): reduce amount of work in test job-output-long-lines.mk

The effect that some of the separator lines start at the end of another
line is still visible.
 1.3 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.2 29-Sep-2020  rillig make(1): fix test job-output-long-lines

The test failed on Linux since the test relied on the two child
processes interleaving each other. This is not guaranteed to happen
though.
 1.1 27-Sep-2020  rillig make(1): add test for merging long lines of job output
 1.4 03-Sep-2022  rillig make: fix handling of null bytes in the output in jobs mode

The test job-output-null failed occasionally, depending on the exact
timing of the child's write and make's read.
 1.3 12-Sep-2021  rillig tests/make: make output of test job-output-null clearer

Having 5 times the word 'hello' in the output doesn't help at
understanding the test and how the output was produced.

Bash 5 sometimes makes this test fail by adding '2b' and '2c' to the
output.
 1.2 03-Jul-2021  rillig tests/make: make test job-output-null more portable

Previously, the test dependend on implementation details of the system's
printf command.

Thank you sjg for the detailed analysis on macOS, FreeBSD and Linux.
 1.1 15-Apr-2021  rillig tests/make: demonstrate handling of null bytes
 1.4 03-Sep-2022  rillig make: fix handling of null bytes in the output in jobs mode

The test job-output-null failed occasionally, depending on the exact
timing of the child's write and make's read.
 1.3 12-Sep-2021  rillig tests/make: make output of test job-output-null clearer

Having 5 times the word 'hello' in the output doesn't help at
understanding the test and how the output was produced.

Bash 5 sometimes makes this test fail by adding '2b' and '2c' to the
output.
 1.2 03-Jul-2021  rillig tests/make: make test job-output-null more portable

Previously, the test dependend on implementation details of the system's
printf command.

Thank you sjg for the detailed analysis on macOS, FreeBSD and Linux.
 1.1 15-Apr-2021  rillig tests/make: demonstrate handling of null bytes
 1.2 13-Jun-2025  rillig branches: 1.2.4;
make: do not discard empty lines in the output of a command
 1.1 05-Jun-2025  rillig make: remove empty line from diagnostic, add tests for output handling

The warning for the invalid internal option "-J" does not need a
trailing newline, as that is provided by Parse_Error already.

Having this newline in the output demonstrated a previously unknown bug
in handling the output of child commands in parallel mode. There, empty
lines are randomly discarded, depending on the chunks in which the
output from the child process is copied to make's stdout. See
job-output.mk for a demonstration.

The test for the Korn shell did not run the Korn shell in error handling
mode, as the error handling mode only affects the parallel mode but the
test didn't switch to that mode.

After fixing the shell-ksh.mk test, the single '"' in the output looked
suspicious, and indeed, the shell-csh.mk test had the same problem of
filtering more characters from the output than intended.
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 13-Jun-2025  perseant file job-output.exp was added on branch perseant-exfatfs on 2025-08-02 05:58:35 +0000
 1.2 13-Jun-2025  rillig branches: 1.2.4;
make: do not discard empty lines in the output of a command
 1.1 05-Jun-2025  rillig make: remove empty line from diagnostic, add tests for output handling

The warning for the invalid internal option "-J" does not need a
trailing newline, as that is provided by Parse_Error already.

Having this newline in the output demonstrated a previously unknown bug
in handling the output of child commands in parallel mode. There, empty
lines are randomly discarded, depending on the chunks in which the
output from the child process is copied to make's stdout. See
job-output.mk for a demonstration.

The test for the Korn shell did not run the Korn shell in error handling
mode, as the error handling mode only affects the parallel mode but the
test didn't switch to that mode.

After fixing the shell-ksh.mk test, the single '"' in the output looked
suspicious, and indeed, the shell-csh.mk test had the same problem of
filtering more characters from the output than intended.
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 13-Jun-2025  perseant file job-output.mk was added on branch perseant-exfatfs on 2025-08-02 05:58:35 +0000
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 16-Jun-2021  rillig branches: 1.2.4;
make: fix error handling in jobs mode

By using the same error handling code as in the branch for non-empty
commands, the behavior is the same again as before 2021-01-29.
 1.1 16-Jun-2021  rillig tests/make: demonstrate wrong error handling in jobs mode
 1.2.4.1 02-Aug-2025  perseant Sync with HEAD
 1.1 16-Jun-2021  rillig tests/make: demonstrate wrong error handling in jobs mode
 1.1 29-Jan-2021  rillig make(1): demonstrate unnecessary creation of empty files in jobs mode
 1.2 30-Jan-2021  rillig make(1): add test for combining the options -j, -n, -t

This is a preparation for refactoring the complicated condition in
JobStart.
 1.1 29-Jan-2021  rillig make(1): demonstrate unnecessary creation of empty files in jobs mode
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Jan-2024  sjg branches: 1.2.2;
make: more consistent error messages

Move %s: progname from Job_CheckCommands to Fatal
to avoid is being repeated when Job_CheckCommands is passed Error.

This means some errors from var also report progname (and level)
which is useful.

Reviewed by: rillig
 1.1 01-Dec-2020  rillig make(1): add tests for suppressing "stopped in"

These tests demonstrate the unwanted behavior described in PR bin/55578
and PR bin/55832.
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 01-Dec-2020  rillig make(1): add tests for suppressing "stopped in"

These tests demonstrate the unwanted behavior described in PR bin/55578
and PR bin/55832.
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 07-Jan-2024  sjg branches: 1.4.2;
make: more consistent error messages

Move %s: progname from Job_CheckCommands to Fatal
to avoid is being repeated when Job_CheckCommands is passed Error.

This means some errors from var also report progname (and level)
which is useful.

Reviewed by: rillig
 1.3 08-Jan-2021  sjg Ensure PrintOnError always reports 'stopped in' on first call.

We may still suppress the rest of the noise if shouldDieQuietly
says to, but the 'stopped in' output is too important to lose.
Avoid repeating it though in the same process.

For the case of aborting due to failure detected elsewhere,
exit 6 so we have a clue.

PR: 55578
Reviewed by:
 1.2 07-Jan-2021  sjg Remove .MAKE from nested target which is not a sub-make

This does not fix the issue, just makes the unit-test more accurate.

PR: 55578
Reviewed by: rillig
 1.1 01-Dec-2020  rillig make(1): add tests for suppressing "stopped in"

These tests demonstrate the unwanted behavior described in PR bin/55578
and PR bin/55832.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 07-Jan-2021  sjg Remove .MAKE from nested target which is not a sub-make

This does not fix the issue, just makes the unit-test more accurate.

PR: 55578
Reviewed by: rillig
 1.1 01-Dec-2020  rillig make(1): add tests for suppressing "stopped in"

These tests demonstrate the unwanted behavior described in PR bin/55578
and PR bin/55832.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Jan-2024  sjg branches: 1.2.2;
make: more consistent error messages

Move %s: progname from Job_CheckCommands to Fatal
to avoid is being repeated when Job_CheckCommands is passed Error.

This means some errors from var also report progname (and level)
which is useful.

Reviewed by: rillig
 1.1 01-Dec-2020  rillig make(1): add tests for suppressing "stopped in"

These tests demonstrate the unwanted behavior described in PR bin/55578
and PR bin/55832.
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 01-Dec-2020  rillig make(1): add tests for suppressing "stopped in"

These tests demonstrate the unwanted behavior described in PR bin/55578
and PR bin/55832.
 1.8 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.7 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.6 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.5 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.4 20-Apr-2024  rillig branches: 1.4.2;
make: provide more context information for parse/evaluate errors
 1.3 09-Dec-2021  rillig make: remove period from end of error messages and warnings

The majority of the existing error messages and warnings does not
include a period at the end. Follow this style consistently.
 1.2 01-Nov-2020  rillig make(1): in lint mode, exit with error status on errors

Calling Parse_Error during parsing has always led to a nonzero exit
status. Calling Parse_Error later, when expanding the shell commands,
has had no effect on the exit status. Neither had calling Error.

To make make a reliable tool, it has to report errors as they occur.
Enable this strict behavior in lint mode for now. Lint mode has to be
enabled explicitly, preserving the default behavior.
 1.1 03-Aug-2020  rillig make(1): in lint mode, disallow dynamic variable names in :@ modifier

This is an extremely obscure feature that hopefully nobody ever
considered using.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.4 30-Jan-2021  rillig make(1): update documentation of test lint.mk
 1.3 15-Sep-2020  rillig make(1): move flags for lint test into the test itself
 1.2 08-Aug-2020  rillig make(1): clean up Var_UnExport

Mark the parameter as constant since it is not modified.

Remove tests for '\n' since these can never succeed.

newenv can never be NULL since neither of bmake_malloc or bmake_realloc
returns NULL.

Improve variable names: vlist was too unexpressive.

Add debug logging since unexporting variables is an uncommon operation
that directly affects the observable environment of the child processes.

Fix CRLF line endings in a few unit tests.
 1.1 03-Aug-2020  rillig make(1): in lint mode, disallow dynamic variable names in :@ modifier

This is an extremely obscure feature that hopefully nobody ever
considered using.
 1.5 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.4 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.3 03-Oct-2020  rillig make(1): do not export variable names starting with '-'

By convention, names of environment variables consist of uppercase
letters and underscores. Most of them start with an uppercase letter.
In a few cases, the names also contain lowercase letters, such as in
http_proxy.

Variable names starting with a hyphen are confusing and might be
mistaken as command line options. Therefore don't export these.

This also affects a few edge cases that don't occur in practice, such as
setting .MAKE.EXPORTED=-env or .MAKE.EXPORTED=-literal. These had not
worked as expected anyway.
 1.2 03-Oct-2020  rillig make(1): explain the purpose of the test make-exported
 1.1 09-Aug-2020  rillig make(1): add test for non-obvious .MAKE.EXPORTED edge case
 1.7 09-Sep-2022  sjg Handle deprecation of egrep
 1.6 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.5 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.4 03-Oct-2020  rillig make(1): ignore -env and -literal in assignments to .MAKE.EXPORTED

Previously, assigning the string "-env" to the variable .MAKE.EXPORTED
had the same effect as the .export-env directive. This was only due to
a sloppy implementation, not by design.

For the string "-literal" and the directive .export-literal, the
situation was even worse since the actually executed code was a wild
mixture between .export and .export-literal that in the end exported the
expanded form of the variable. Therefore there was no practical use
case of this implementation flaw.
 1.3 03-Oct-2020  rillig make(1): do not export variable names starting with '-'

By convention, names of environment variables consist of uppercase
letters and underscores. Most of them start with an uppercase letter.
In a few cases, the names also contain lowercase letters, such as in
http_proxy.

Variable names starting with a hyphen are confusing and might be
mistaken as command line options. Therefore don't export these.

This also affects a few edge cases that don't occur in practice, such as
setting .MAKE.EXPORTED=-env or .MAKE.EXPORTED=-literal. These had not
worked as expected anyway.
 1.2 03-Oct-2020  rillig make(1): explain the purpose of the test make-exported
 1.1 09-Aug-2020  rillig make(1): add test for non-obvious .MAKE.EXPORTED edge case
 1.4 11-Apr-2025  rillig make: use "file:123" format in meta mode
 1.3 27-Jan-2022  sjg branches: 1.3.4;
Allow local variable assignments in dependency lines

The variable is set in the context of the target.
This syntax has been supported by gmake for ~ever.
If necessary a makefile can set .MAKE.TARGET_LOCAL_VARIABLES=false
to disable this.

Expose GetBooleanExpr so parse.c can use it.
 1.2 14-Jan-2022  sjg Add unit-test for .MAKE.META.CMP_FILTER
 1.1 30-Nov-2020  sjg Add some tests for meta mode
 1.3.4.1 02-Aug-2025  perseant Sync with HEAD
 1.6 02-Mar-2022  sjg Add nofilemon to meta mode tests

The unit-tests for meta mode do not depend on filemon.
Adding nofilemon to .MAKE.MODE allows these to pass on
a system that would use filemon_dev but does not have
the module loaded.
 1.5 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.4 27-Jan-2022  sjg Allow local variable assignments in dependency lines

The variable is set in the context of the target.
This syntax has been supported by gmake for ~ever.
If necessary a makefile can set .MAKE.TARGET_LOCAL_VARIABLES=false
to disable this.

Expose GetBooleanExpr so parse.c can use it.
 1.3 14-Jan-2022  sjg Add unit-test for .MAKE.META.CMP_FILTER
 1.2 05-Dec-2020  sjg Don't let gcov mess up results
 1.1 30-Nov-2020  sjg Add some tests for meta mode
 1.2 25-Feb-2023  sjg make: meta-ignore tests will not work if TMPDIR is /tmp

Since /tmp and /var/tmp are always part of .MAKE.META.IGNORE_PATHS
the varname-dot-make-meta-ignore_* tests will not work
if TMPDIR is either (or subdir) of those.
 1.1 23-Feb-2023  sjg Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR
 1.3 05-Aug-2025  sjg meta-output.mk diff output

We construct output such that it should match what we
can extract from output.meta, so diff the two.
This way the test cannot pass if meta.c is capturing
something inaccurately - other than the trailing newline.
 1.2 04-Aug-2025  sjg meta-output.mk: Allow for echo that does not support -n

On latest Darwin, /bin/sh builtin echo does not do -n

There will be others, so test if echo -n works and adjust.

Capture only the command output from the meta file so
that results can be consistent whether echo -n works or not.
 1.1 03-Aug-2025  sjg make: ensure output captured in meta file is accurate

In CollectOutput() a newline before the end of job->outBuf
results in a short write to stdout, but meta_job_output()
was recording the entire string in the meta file, so on
next call the left overs would be duplicated in the meta file.

Pass a length to meta_job_output() if it should only report part of
the data in meta file.
 1.5 05-Aug-2025  sjg meta-output.mk diff output

We construct output such that it should match what we
can extract from output.meta, so diff the two.
This way the test cannot pass if meta.c is capturing
something inaccurately - other than the trailing newline.
 1.4 04-Aug-2025  sjg Use printf rather than echo -n
 1.3 04-Aug-2025  sjg echo.inc make ECHO_SCRIPT reusable
 1.2 04-Aug-2025  sjg meta-output.mk: Allow for echo that does not support -n

On latest Darwin, /bin/sh builtin echo does not do -n

There will be others, so test if echo -n works and adjust.

Capture only the command output from the meta file so
that results can be consistent whether echo -n works or not.
 1.1 03-Aug-2025  sjg make: ensure output captured in meta file is accurate

In CollectOutput() a newline before the end of job->outBuf
results in a short write to stdout, but meta_job_output()
was recording the entire string in the meta file, so on
next call the left overs would be duplicated in the meta file.

Pass a length to meta_job_output() if it should only report part of
the data in meta file.
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 06-Mar-2011  sjg Add unit tests to check that exists(some/dir/) works

Also fix handling of sysV substitutions when lhs and variable are empty.

Also that modifiers do not cause errors during conditional tests
when undefined variables should otherwise be ok.
Ie. .if defined(nosuch) && ${nosuch:Mx} != ""
 1.2 08-Oct-2020  rillig make(1): move test for .CURDIR from misc.mk to varname-dot-curname.mk
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 08-Oct-2020  rillig make(1): move test for .CURDIR from misc.mk to varname-dot-curname.mk
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 11-May-2006  sjg Remove the modterm case from moderrs, the syntax errors
generated by /bin/sh on other systems are not consistent.
 1.1 11-May-2006  sjg Extract the variable modifier logic to a separate function.
This cuts Var_Parse in half! and allows the modifier logic to
be used recursively - when getting modifiers via variables.

Add new unit-test, to check that certain error cases are handled
correctly.
 1.54 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.53 30-Mar-2025  rillig make: fix error message for invalid ":[...]" modifier

The unparsed value of the modifier argument can already be seen in the
stack trace, but the modifier argument may contain expressions and the
expanded value of these expressions was hidden up to now. See the EMPTY
test at the bottom of varmod-select-words.mk for details.
 1.52 30-Mar-2025  rillig make: let the ":t" modifiers fall back to the ":from=to" modifier

Suggested by https://bugs.freebsd.org/285726.

This means that the ":t" modifiers cannot have future extensions that
include a "=", as that may break existing code.
 1.51 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.50 29-Mar-2025  rillig make: stop parsing after seeing an unknown modifier in an expression

Previously, after an expression such as ${VAR:Z::::}, make detected the
unknown modifier ":Z" and then continued parsing, which produced
unnecessary follow-up error messages. It was also necessary to
distinguish the error cases when logging the result of an applied
modifier in -dv mode.

Unify the error handling cases of a syntax error, an evaluation error
and an unknown modifier, to avoid the unnecessary follow-up error
messages.

The test in varmod-edge.mk now produces ":}" from the erroneous
expression, which may be misleading and thus will be looked at in a
follow-up commit.

The general idea of this patch was reviewed by sjg, I made a few
nonsubstantial changes after the review.
 1.49 29-Mar-2025  rillig make: fix error message for unclosed expression

Even in an unclosed expression such as "${VAR:from=to", the modifier
":from=to" needs to be recognized as such, instead of giving an error
message about an "Unknown modifier ":from=to"".
 1.48 29-Mar-2025  rillig make: add more details to error message about unfinished modifier

These details allow to quickly see the place where the syntax error is,
based on the surrounding lines from the stack trace.
 1.47 29-Mar-2025  rillig make: add details about indirect modifiers to the stack traces

Previously, the error message "Unfinished modifier (',' missing)" from
moderrs.mk didn't provide enough context to understand where and why the
comma was missing.
 1.46 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.45 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.44 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.43 20-Jul-2024  rillig tests/make: remove redundant context information

The affected target is already mentioned in the line containing the
error message.
 1.42 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.41 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.40 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.39 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.38 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.37 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.36 30-Jun-2024  rillig tests/make: replace 'want' comments with 'expect' directives

The 'want' comments needed to be cross-checked manually, which was
error-prone, as can be seen in the "Unknown modifier" messages that got
out of sync.
 1.35 20-Apr-2024  rillig branches: 1.35.2;
make: provide more context information for parse/evaluate errors
 1.34 19-Nov-2023  rillig tests/make: replace 'variable expressions' with 'expressions'
 1.33 19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.32 21-Jun-2021  rillig tests/make: remove unnecessary -dL from moderrs.mk

It was only needed for the test for unmatched subexpressions in the
modifier ':C'. That test has been moved to varmod-subst-regex.mk.
 1.31 21-Jun-2021  rillig tests/make: move and extend test for unmatched '\1' in ':C'

This test lived together with a few unrelated tests in moderrs.mk, it is
better placed in varmod-subst-regex.mk though.

While here, extend, document and explain the test since its purpose was
not obvious from reading the code alone.
 1.30 21-Jun-2021  sjg Do not report unmatched regex subexpressions

It is not always an error for a subexpression to have not matched,
since the regex library can/does not convey how many matches are
expected, only report an error if opts.strict (-dL)

Reviewed by: christos
 1.29 23-Feb-2021  rillig make: improve error message for bad modifier in variable expression

The improvement is especially noteable for variable expressions based on
the empty variable, see moderrs.exp:103.
 1.28 23-Feb-2021  rillig make: add test for confusing error message for bad modifier

In the expression ${:U}, the variable name is empty. Since these
expressions are generated by .for loops, the error messages for them
must not end with a trailing space. Putting the variable name in quotes
helps against that.
 1.27 23-Feb-2021  rillig make: improve error message for unclosed modifier

Replace "variable specification" with the more modern "variable
expression", reduce the number of parentheses, output more than a single
character for modifiers, make it obvious that in expressions such as
${:Serror}, the "" means a variable name.
 1.26 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.25 23-Feb-2021  rillig make: quote ':S' in error message about missing delimiter
 1.24 23-Feb-2021  rillig make: add quotes around variable name in an error message
 1.23 01-Nov-2020  rillig make(1): treat malformed :range, :ts and :[...] as errors

Before, integer overflow in the :[1..2] modifier had not been detected,
and the actual behavior varied between ILP64 and LP64I32 machines.

Before, the :ts modifier accepted character literals like \012345 and
\x1F600, which don't fit in a single character and were thus truncated.

Before, the :range modifier issued an "Unknown modifier" error message
for :range=x, which was not quite correct. The error message in this
case is now "Invalid number".
 1.22 01-Nov-2020  rillig make(1): demonstrate parsing bugs in test moderrs.mk

When a malformed variable expression is parsed, the remaining part of
the expression is passed unmodified to the output. This is unexpected
and wrong.
 1.21 01-Nov-2020  rillig make(1): renumber the tests in moderrs.mk, remove duplicates
 1.20 01-Nov-2020  rillig make(1): make test names in moderrs.mk more descriptive
 1.19 01-Nov-2020  rillig make(1): precisely describe the expected output in the test moderrs.mk

By making "want:" the same length as "make:", the remaining text in
these lines can be compared easily.
 1.18 01-Nov-2020  rillig make(1): separate sections of moderrs.mk with empty lines
 1.17 01-Nov-2020  rillig make(1): add section headings to the test moderrs.mk
 1.16 25-Aug-2020  rillig make(1): move test for the ::= modifier to varmod-assign
 1.15 09-Aug-2020  rillig make(1): improve test for undefined subexpression in :C modifier

In the previous test output, it was unnecessarily hard to see what
happens because of the many empty strings. Enclosing the capturing
groups in parentheses helps against this.
 1.14 09-Aug-2020  rillig make(1): add test for undefined subexpression in the :C modifier
 1.13 08-Aug-2020  rillig make(1): improve error message in case of unfinished modifiers

The previous error message "Unclosed substitution" was wrong for several
reasons.

It is not about "unclosed", but about "unfinished" since in the
:@var@...@ modifier the missing '@' does not really close anything.

The word "substitution" may have originated in a time where :S and
:from=to were the only modifiers, and these were indeed substitutions,
but several other modifiers aren't.

The :S and :C modifiers allow an arbitrary delimiter, therefore it is
helpful to enclose the delimiter in quotes, just in case someone chooses
')' or '{' or even ' ' as delimiter.
 1.12 31-Jul-2020  rillig make(1): add test for parsing an incomplete :t modifier

This looks a lot like undefined behavior, just like in :S and :C before.
 1.11 31-Jul-2020  rillig make(1): fix undefined behavior when parsing malformed :C modifier

Same as in the :S modifier.
 1.10 31-Jul-2020  rillig make(1): fix undefined behavior in malformed :S modifier

The unit tests failed on Ubuntu, and by looking closely at the code, it
was trivial to see the out-of-bounds memory read.

Other modifiers may have the same problem and will be inspected later.
 1.9 29-Jul-2020  rillig make(1): fix segfault when evaluating ${::=value}

The bug had been in the handling of the SysV modifier for many years, but
it had not been triggered since the "parsing position for the next
modifier" had been initialized to a non-NULL pointer.

In var.v r1.350, this pointer had been initialized to NULL instead since
every ApplyModifier function must set it in every case where it returns
anything except "default_case".

There might have been a slight chance of tricking make to output a wrong
error message, but nothing worse.
 1.8 29-Jul-2020  rillig make(1): add enough tests to cover the ApplyModifier functions

Only a few return statements are still missing from the code coverage.

In ApplyModifier_Assign, the test for an empty variable name is skipped
for now since it segfaults.

In ApplyModifier_SysV after the second ParseModifierPart, the branch for
the missing delimiter is not reached since this case is already checked
for in the first part of the function. To trigger this branch, a
specially crafted, unrealistic string needs to be created, and that's too
complicated for the moment.
 1.7 29-Jul-2020  rillig make(1): add unit tests for parse errors in modifiers
 1.6 28-Jul-2020  rillig make(1): add test for modifier part with unbalanced braces
 1.5 26-Jul-2020  rillig make(1): add tests for :!...! parse errors
 1.4 26-Jul-2020  rillig make(1): add test for missing input validation in :[123] modifier
 1.3 26-Jul-2020  rillig make(1): fix missing error message about missing @ delimiter

This had been broken since 2020-07-03, during a "refactoring".
 1.2 26-Jul-2020  rillig make(1): add test about missing delimiters in :@ modifier

These error conditions have been broken since var.c 1.236 on 2020-07-03.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.35.2.2 02-Aug-2025  perseant Sync with HEAD
 1.35.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.47 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.46 30-Mar-2025  rillig make: let the ":t" modifiers fall back to the ":from=to" modifier

Suggested by https://bugs.freebsd.org/285726.

This means that the ":t" modifiers cannot have future extensions that
include a "=", as that may break existing code.
 1.45 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.44 29-Mar-2025  rillig make: stop parsing after seeing an unknown modifier in an expression

Previously, after an expression such as ${VAR:Z::::}, make detected the
unknown modifier ":Z" and then continued parsing, which produced
unnecessary follow-up error messages. It was also necessary to
distinguish the error cases when logging the result of an applied
modifier in -dv mode.

Unify the error handling cases of a syntax error, an evaluation error
and an unknown modifier, to avoid the unnecessary follow-up error
messages.

The test in varmod-edge.mk now produces ":}" from the erroneous
expression, which may be misleading and thus will be looked at in a
follow-up commit.

The general idea of this patch was reviewed by sjg, I made a few
nonsubstantial changes after the review.
 1.43 29-Mar-2025  rillig make: fix error message for unclosed expression

Even in an unclosed expression such as "${VAR:from=to", the modifier
":from=to" needs to be recognized as such, instead of giving an error
message about an "Unknown modifier ":from=to"".
 1.42 29-Mar-2025  rillig make: add more details to error message about unfinished modifier

These details allow to quickly see the place where the syntax error is,
based on the surrounding lines from the stack trace.
 1.41 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.40 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.39 20-Jul-2024  rillig tests/make: remove redundant context information

The affected target is already mentioned in the line containing the
error message.
 1.38 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.37 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.36 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.35 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.34 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.33 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.32 30-Jun-2024  rillig tests/make: replace 'want' comments with 'expect' directives

The 'want' comments needed to be cross-checked manually, which was
error-prone, as can be seen in the "Unknown modifier" messages that got
out of sync.
 1.31 19-Nov-2023  rillig branches: 1.31.2;
tests/make: replace 'variable expressions' with 'expressions'
 1.30 21-Jun-2021  rillig tests/make: remove unnecessary -dL from moderrs.mk

It was only needed for the test for unmatched subexpressions in the
modifier ':C'. That test has been moved to varmod-subst-regex.mk.
 1.29 21-Jun-2021  rillig tests/make: move and extend test for unmatched '\1' in ':C'

This test lived together with a few unrelated tests in moderrs.mk, it is
better placed in varmod-subst-regex.mk though.

While here, extend, document and explain the test since its purpose was
not obvious from reading the code alone.
 1.28 21-Jun-2021  sjg Do not report unmatched regex subexpressions

It is not always an error for a subexpression to have not matched,
since the regex library can/does not convey how many matches are
expected, only report an error if opts.strict (-dL)

Reviewed by: christos
 1.27 23-Feb-2021  rillig make: add test for confusing error message for bad modifier

In the expression ${:U}, the variable name is empty. Since these
expressions are generated by .for loops, the error messages for them
must not end with a trailing space. Putting the variable name in quotes
helps against that.
 1.26 23-Feb-2021  rillig make: improve error message for unclosed modifier

Replace "variable specification" with the more modern "variable
expression", reduce the number of parentheses, output more than a single
character for modifiers, make it obvious that in expressions such as
${:Serror}, the "" means a variable name.
 1.25 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.24 01-Nov-2020  rillig make(1): treat malformed :range, :ts and :[...] as errors

Before, integer overflow in the :[1..2] modifier had not been detected,
and the actual behavior varied between ILP64 and LP64I32 machines.

Before, the :ts modifier accepted character literals like \012345 and
\x1F600, which don't fit in a single character and were thus truncated.

Before, the :range modifier issued an "Unknown modifier" error message
for :range=x, which was not quite correct. The error message in this
case is now "Invalid number".
 1.23 01-Nov-2020  rillig make(1): demonstrate parsing bugs in test moderrs.mk

When a malformed variable expression is parsed, the remaining part of
the expression is passed unmodified to the output. This is unexpected
and wrong.
 1.22 01-Nov-2020  rillig make(1): renumber the tests in moderrs.mk, remove duplicates
 1.21 01-Nov-2020  rillig make(1): make test names in moderrs.mk more descriptive
 1.20 01-Nov-2020  rillig make(1): precisely describe the expected output in the test moderrs.mk

By making "want:" the same length as "make:", the remaining text in
these lines can be compared easily.
 1.19 01-Nov-2020  rillig make(1): separate sections of moderrs.mk with empty lines
 1.18 01-Nov-2020  rillig make(1): add section headings to the test moderrs.mk
 1.17 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.16 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.15 25-Aug-2020  rillig make(1): move test for the ::= modifier to varmod-assign
 1.14 09-Aug-2020  rillig make(1): improve test for undefined subexpression in :C modifier

In the previous test output, it was unnecessarily hard to see what
happens because of the many empty strings. Enclosing the capturing
groups in parentheses helps against this.
 1.13 09-Aug-2020  rillig make(1): add test for undefined subexpression in the :C modifier
 1.12 08-Aug-2020  rillig make(1): improve error message in case of unfinished modifiers

The previous error message "Unclosed substitution" was wrong for several
reasons.

It is not about "unclosed", but about "unfinished" since in the
:@var@...@ modifier the missing '@' does not really close anything.

The word "substitution" may have originated in a time where :S and
:from=to were the only modifiers, and these were indeed substitutions,
but several other modifiers aren't.

The :S and :C modifiers allow an arbitrary delimiter, therefore it is
helpful to enclose the delimiter in quotes, just in case someone chooses
')' or '{' or even ' ' as delimiter.
 1.11 31-Jul-2020  rillig make(1): remove outdated comment from unit test

It had indeed been undefined behavior and was fixed in var.c r1.359 today
in the morning.
 1.10 31-Jul-2020  rillig make(1): add test for parsing an incomplete :t modifier

This looks a lot like undefined behavior, just like in :S and :C before.
 1.9 31-Jul-2020  rillig make(1): fix undefined behavior when parsing malformed :C modifier

Same as in the :S modifier.
 1.8 29-Jul-2020  rillig make(1): fix segfault when evaluating ${::=value}

The bug had been in the handling of the SysV modifier for many years, but
it had not been triggered since the "parsing position for the next
modifier" had been initialized to a non-NULL pointer.

In var.v r1.350, this pointer had been initialized to NULL instead since
every ApplyModifier function must set it in every case where it returns
anything except "default_case".

There might have been a slight chance of tricking make to output a wrong
error message, but nothing worse.
 1.7 29-Jul-2020  rillig make(1): add enough tests to cover the ApplyModifier functions

Only a few return statements are still missing from the code coverage.

In ApplyModifier_Assign, the test for an empty variable name is skipped
for now since it segfaults.

In ApplyModifier_SysV after the second ParseModifierPart, the branch for
the missing delimiter is not reached since this case is already checked
for in the first part of the function. To trigger this branch, a
specially crafted, unrealistic string needs to be created, and that's too
complicated for the moment.
 1.6 29-Jul-2020  rillig make(1): add unit tests for parse errors in modifiers
 1.5 28-Jul-2020  rillig make(1): add test for modifier part with unbalanced braces
 1.4 26-Jul-2020  rillig make(1): add tests for :!...! parse errors
 1.3 26-Jul-2020  rillig make(1): add test for missing input validation in :[123] modifier
 1.2 26-Jul-2020  rillig make(1): add test about missing delimiters in :@ modifier

These error conditions have been broken since var.c 1.236 on 2020-07-03.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.31.2.2 02-Aug-2025  perseant Sync with HEAD
 1.31.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.3 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 07-Sep-2009  sjg PR: 41998

:Ufu\:goo

should expand to fu:goo even when it appears in :M${:Ufu\:goo}
When scanning for :M do not compress \: if we know we have
to call Var_Subst.
 1.1 20-Feb-2004  sjg Fix :M so that modifiers in nested variables don't terminate parsing
early. Add a unit-test to verify it works and keeps working.
Re-jig the unit-tests so that all are sub makefiles.
 1.5 16-Jun-2023  rillig tests/make: clean up tests for the ':M' and ':S' modifiers
 1.4 16-Aug-2020  rillig make(1): move tests for the :M modifier into separate files

The test for the different escaping has been adjusted to actually show
the different parsing results in the test output. To do this, it had to
get its own file since it needs the -dv debug flag and specialized
post-processing.
 1.3 21-Apr-2017  sjg Str_Match: fix closure tests for [^] and add unit-test.
 1.2 13-Apr-2017  sjg Add test case for :M[^A-Z]
 1.1 21-Aug-2014  apb branches: 1.1.2; 1.1.4;
Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.10 16-Jun-2023  rillig tests/make: clean up tests for the ':M' and ':S' modifiers
 1.9 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.8 16-Aug-2020  rillig make(1): move tests for the :M modifier into separate files

The test for the different escaping has been adjusted to actually show
the different parsing results in the test output. To do this, it had to
get its own file since it needs the -dv debug flag and specialized
post-processing.
 1.7 01-Aug-2020  rillig make(1): add test for inconsistent interpretation of :M and :N modifiers
 1.6 15-Jun-2020  rillig make(1): fix performance problem in specially crafted :M modifier

This fix was previously suspected to make the vax build fail. The next
build succeeded though, and it started 2 hours before this fix was
reverted.
 1.5 14-Jun-2020  rillig usr.bin/make: revert performance improvement

That change might be the cause of a build failure for vax.
http://releng.netbsd.org/builds/HEAD/202006131940Z/ builds fine.
http://releng.netbsd.org/builds/HEAD/202006141020Z/ doesn't.

The build fails with:
/home/source/ab/HEAD/src/external/gpl3/gcc/dist/gcc/machmode.h:524:28:
error: 'mode_size_inline' was not declared in this scope
 1.4 13-Jun-2020  rillig usr.bin/make: make Str_Match faster for repeated asterisks

Conceptually related to https://en.wikipedia.org/wiki/ReDoS.
 1.3 21-Apr-2017  sjg Str_Match: fix closure tests for [^] and add unit-test.
 1.2 13-Apr-2017  sjg Add test case for :M[^A-Z]
 1.1 21-Aug-2014  apb branches: 1.1.2; 1.1.4;
Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.8 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.7 11-Apr-2011  sjg Add a test case for sysV modifier subst
 1.6 23-Apr-2010  sjg PR: 42850
Reviewed by:

Reduced the "expected to exist" dirs in path to just
/ /bin and /tmp
and change the "not expected to exist" dir to something
even less likely.
Add a comment to suggest why.
 1.5 22-Apr-2010  sjg PR: 42850
Reviewed by:

modmisc: since we apply an exists() test to $paths, be conservative
in what we expect.

Run the unit tests with -r -m / so that we do not fail if there
is no sys.mk present.
 1.4 11-May-2006  sjg Extract the variable modifier logic to a separate function.
This cuts Var_Parse in half! and allows the modifier logic to
be used recursively - when getting modifiers via variables.

Add new unit-test, to check that certain error cases are handled
correctly.
 1.3 26-Feb-2006  wiz Fix typo.
 1.2 26-Feb-2006  sjg Using ./bin in the test case, causes problems when 'make test' is
run from 'unit-tests' rather than the parent dir.
 1.1 26-Feb-2006  sjg Update man page and add test case for specifying modifiers via variable.
Also allow said variable to appear anywhere in the modifier list.
 1.48 16-Jun-2023  rillig tests/make: clean up tests for the ':M' and ':S' modifiers
 1.47 20-Dec-2020  rillig make(1): move tests for indirect modifiers around

The next commit will error out on unknown modifiers and influence the
exit status. The test modmisc.mk contains both parse time tests and run
time tests. To prevent the latter from being run, the parse error is
moved to varmod-indirect.mk, which only contains parse time tests.
 1.46 23-Aug-2020  rillig make(1): move tests for the :tu and :_ modifiers into separate files
 1.45 23-Aug-2020  rillig make(1): move tests for :hash :range :localtime into separate files
 1.44 23-Aug-2020  rillig make(1): move tests for :H :E :R :T into separate files
 1.43 16-Aug-2020  rillig make(1): move tests for the :gmtime and ::= modifiers to separate files
 1.42 16-Aug-2020  rillig make(1): move tests for :S, :C, :@ from modmisc to their separate tests
 1.41 09-Aug-2020  rillig make(1): add test that demonstrates possible delimiters for :S
 1.40 09-Aug-2020  rillig make(1): explain the mod-subst-dollar test
 1.39 09-Aug-2020  rillig make(1): add another test case for mod-subst-dollar

Having only 8 dollar signs does not prove anything. It might still be
the result of 3 substitutions in a row. Having 5 substitutions in a row
is less likely though.
 1.38 08-Aug-2020  rillig make(1): add test for the :gmtime modifier with indirect time
 1.37 08-Aug-2020  rillig make(1): add test for unknown sub-modifier of the :S modifier
 1.36 07-Aug-2020  rillig make(1): add tests for creative variable names in the :@ modifier
 1.35 01-Aug-2020  rillig make(1): fix error message when regcomp fails

If regcomp fails, it's not the regex substitution that is erroneous, but
the regex compilation.
 1.34 01-Aug-2020  rillig make(1): add tests for indirect modifiers
 1.33 31-Jul-2020  rillig make(1): add test for chaining the :S modifier without colon
 1.32 29-Jul-2020  rillig make(1): remove unnecessary assignments to st->next

No change in the size of the resulting binary. Apparently GCC already
knew these assignments were redundant.
 1.31 29-Jul-2020  rillig make(1): add unit tests for parse errors in modifiers
 1.30 27-Jul-2020  rillig make(1): replace macros with functions

Having the hidden parameter st->endc in the macro made it unnecessarily
difficult to understand the code.
 1.29 26-Jul-2020  rillig make(1): use consistent test names in modmisc.mk
 1.28 25-Jul-2020  rillig make(1): add test for brk_string with more than 50 words
 1.27 23-Jul-2020  rillig make(1): fix wrong warning about missing delimiter
 1.26 23-Jul-2020  rillig make(1): demonstrate wrong error message about missing delimiter

The current practice of setting st->delim at the beginning of each
modifier and resetting it again at the end produces too many error
messages. In this case, there is no missing delimiter.
 1.25 21-Jul-2020  rillig make(1): add test for :S,,sep

The empty string does not match anywhere. In other implementations of
string replacement, an empty string matches at every position of the
source string.

This only works for the :S modifier. The :C modifier does not allow an
empty search pattern.
 1.24 21-Jul-2020  rillig make(1): add test for :Q and .newline
 1.23 20-Jul-2020  rillig make(1): fix edge cases with $ at the end of the :@ modifier

In both parts of the :@ modifier, by passing &pflags to
ParseModifierPart, a final $ was interpreted as an anchor, which only
makes sense in the :S and :C modifiers.

This edge case is neither used by src nor by pkgsrc, except for the unit
tests that have been adjusted.
 1.22 20-Jul-2020  rillig make(1): add test for nested assignments

This test demonstrates that in ApplyModifier_Assign, the call to
ParseModifierPart must get its pflags.
 1.21 20-Jul-2020  rillig make(1): add test for :tu modifier with spaces
 1.20 20-Jul-2020  rillig make(1): make modifier handling simpler

Implementing a modifier such as :S or :M should not be concerned with
separating the words of the resulting string. Ideally this should be
done in the same way by all modifiers.

Before, the :R (filename root) modifier added a separator even if the
resulting filename root was an empty string. The chances that this
change in behavior breaks anything are epsilon.

The :@ modifier, if it appeared after a :ts modifier, did not use the
word separator from the :ts modifier (which all other modifiers do) but
always added a space. This behavior has been preserved for now. It's an
unnecessary inconsistency though.

In contrast to Buffer, the newly added SepBuf uses size_t for memory
sizes and also uses the conventional parameter order (mem, memsize)
instead of the unusual (memsize, mem).
 1.19 19-Jul-2020  rillig make(1): add tests for the ::= modifiers
 1.18 19-Jul-2020  rillig make(1): add tests for maximum number of capturing groups in :C
 1.17 19-Jul-2020  rillig make(1): fix off-by-one error in :C modifier

Previously this off-by-one error had invoked undefined behavior.
Until today there was no corresponding unit test though.
 1.16 19-Jul-2020  rillig make(1): demonstrate off-by-one bug in :C modifier
 1.15 19-Jul-2020  rillig make(1): add test for stray dollar signs in :@ modifier
 1.14 04-Jul-2020  rillig make(1): ignore system-specific error message from regcomp in test

NetBSD 8 has: repetition-operator operand invalid
Ubuntu has: Invalid preceding regular expression
 1.13 04-Jul-2020  rillig make(1): add tests for dollar characters in modifiers
 1.12 04-Jul-2020  rillig make(1): expand the test for variable expansion in the :@ modifier
 1.11 04-Jul-2020  rillig make(1): add debugging output for :@ modifier

The inner working of the :@ modifier is quite tricky. To understand what
really happens, it helps to look at each word as it is being modified.
 1.10 04-Jul-2020  rillig make(1): add test for an obscure edge case of using the :@ modifier
 1.9 04-Jul-2020  rillig make(1): add tests for the :S and :C modifiers
 1.8 03-Jul-2020  rillig make(1): clean up documentation, small refactorings for variables

- document the callback for VarModify
- clearly mark the callbacks
- shorten the documentation for some callback functions
- fix the documentation of VarSYSVMatch
- remove unnecessary null check from VarLoopExpand
- add test for applying modifiers to empty strings
 1.7 03-Jul-2020  rillig make(1): add expected test result for modmisc
 1.6 03-Jul-2020  rillig make(1): fix bug in :E modifier, introduced in r1.239 today

That case was not covered by the tests before.
 1.5 03-Jul-2020  rillig make(1): add test for :R modifier
 1.4 03-Jul-2020  rillig make(1): add more tests for :H, :T and :E modifiers
 1.3 03-Jul-2020  rillig make(1): add test for :H and :T modifiers with several words
 1.2 03-Jul-2020  rillig make(1): add missing test for the :H and :T modifiers
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.53 16-Jun-2023  rillig tests/make: clean up tests for the ':M' and ':S' modifiers
 1.52 20-Dec-2020  rillig make(1): move tests for indirect modifiers around

The next commit will error out on unknown modifiers and influence the
exit status. The test modmisc.mk contains both parse time tests and run
time tests. To prevent the latter from being run, the parse error is
moved to varmod-indirect.mk, which only contains parse time tests.
 1.51 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.50 03-Nov-2020  rillig make(1): clean up unit tests
 1.49 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.48 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.47 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.46 23-Aug-2020  rillig make(1): move tests for the :tu and :_ modifiers into separate files
 1.45 23-Aug-2020  rillig make(1): move tests for :hash :range :localtime into separate files
 1.44 23-Aug-2020  rillig make(1): move tests for :H :E :R :T into separate files
 1.43 16-Aug-2020  rillig make(1): move tests for the :gmtime and ::= modifiers to separate files
 1.42 16-Aug-2020  rillig make(1): move tests for :S, :C, :@ from modmisc to their separate tests
 1.41 09-Aug-2020  rillig make(1): add more tests for Cmd_Exec
 1.40 09-Aug-2020  rillig make(1): add test for null byte in the output of a command
 1.39 09-Aug-2020  rillig make(1): add test that demonstrates possible delimiters for :S
 1.38 09-Aug-2020  rillig make(1): explain the mod-subst-dollar test
 1.37 09-Aug-2020  rillig make(1): add another test case for mod-subst-dollar

Having only 8 dollar signs does not prove anything. It might still be
the result of 3 substitutions in a row. Having 5 substitutions in a row
is less likely though.
 1.36 08-Aug-2020  rillig make(1): add test for the :gmtime modifier with indirect time
 1.35 08-Aug-2020  rillig make(1): add test for unknown sub-modifier of the :S modifier
 1.34 07-Aug-2020  rillig make(1): add tests for creative variable names in the :@ modifier
 1.33 03-Aug-2020  rillig make(1): in lint mode, disallow dynamic variable names in :@ modifier

This is an extremely obscure feature that hopefully nobody ever
considered using.
 1.32 01-Aug-2020  rillig make(1): add test for empty indirect modifier
 1.31 01-Aug-2020  rillig make(1): add tests for indirect modifiers
 1.30 31-Jul-2020  rillig make(1): add test for chaining the :S modifier without colon
 1.29 29-Jul-2020  rillig make(1): remove unnecessary assignments to st->next

No change in the size of the resulting binary. Apparently GCC already
knew these assignments were redundant.
 1.28 29-Jul-2020  rillig make(1): add unit tests for parse errors in modifiers
 1.27 27-Jul-2020  rillig make(1): replace macros with functions

Having the hidden parameter st->endc in the macro made it unnecessarily
difficult to understand the code.
 1.26 26-Jul-2020  rillig make(1): add basic tests for the :S modifier
 1.25 26-Jul-2020  rillig make(1): fix bug in :S modifier from 2020-07-19
 1.24 26-Jul-2020  rillig make(1): demonstrate bug in the :S modifier with the 1 modifier

The bug has been introduced in var.c r1.268 on 2020-07-19.
 1.23 26-Jul-2020  rillig make(1): use consistent test names in modmisc.mk
 1.22 25-Jul-2020  rillig make(1): add test for brk_string with more than 50 words
 1.21 23-Jul-2020  rillig make(1): demonstrate wrong error message about missing delimiter

The current practice of setting st->delim at the beginning of each
modifier and resetting it again at the end produces too many error
messages. In this case, there is no missing delimiter.
 1.20 21-Jul-2020  rillig make(1): add test for :S,,sep

The empty string does not match anywhere. In other implementations of
string replacement, an empty string matches at every position of the
source string.

This only works for the :S modifier. The :C modifier does not allow an
empty search pattern.
 1.19 21-Jul-2020  rillig make(1): add test for :Q and .newline
 1.18 20-Jul-2020  rillig make(1): add test for nested assignments

This test demonstrates that in ApplyModifier_Assign, the call to
ParseModifierPart must get its pflags.
 1.17 20-Jul-2020  rillig make(1): add test for :tu modifier with spaces
 1.16 19-Jul-2020  rillig make(1): add tests for the ::= modifiers
 1.15 19-Jul-2020  rillig make(1): add tests for maximum number of capturing groups in :C
 1.14 19-Jul-2020  rillig make(1): demonstrate off-by-one bug in :C modifier
 1.13 19-Jul-2020  rillig make(1): add test for stray dollar signs in :@ modifier
 1.12 04-Jul-2020  rillig make(1): add tests for dollar characters in modifiers
 1.11 04-Jul-2020  rillig make(1): expand the test for variable expansion in the :@ modifier
 1.10 04-Jul-2020  rillig make(1): add debugging output for :@ modifier

The inner working of the :@ modifier is quite tricky. To understand what
really happens, it helps to look at each word as it is being modified.
 1.9 04-Jul-2020  rillig make(1): add test for an obscure edge case of using the :@ modifier
 1.8 04-Jul-2020  rillig make(1): add tests for the :S and :C modifiers
 1.7 03-Jul-2020  rillig make(1): clean up documentation, small refactorings for variables

- document the callback for VarModify
- clearly mark the callbacks
- shorten the documentation for some callback functions
- fix the documentation of VarSYSVMatch
- remove unnecessary null check from VarLoopExpand
- add test for applying modifiers to empty strings
 1.6 03-Jul-2020  rillig make(1): fix bug in :E modifier, introduced in r1.239 today

That case was not covered by the tests before.
 1.5 03-Jul-2020  rillig make(1): add test for :R modifier
 1.4 03-Jul-2020  rillig make(1): add more tests for :H, :T and :E modifiers
 1.3 03-Jul-2020  rillig make(1): add test for :H and :T modifiers with several words
 1.2 03-Jul-2020  rillig make(1): add missing test for the :H and :T modifiers
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 05-Oct-2007  sjg Add the ability to .export variables to the environment.
 1.1 01-Jun-2005  sjg branches: 1.1.12;
Add :Ox for random ordering, based on patch from
Mike M. Volokhov <mishka@apk.od.ua>
 1.1.12.1 06-Nov-2007  matt sync with HEAD
 1.4 16-Aug-2020  rillig make(1): move tests for the :Ox modifier into separate file

The test has been extended by ensuring that the shuffled words are still
the same. Comparing two shuffled lists is probabilistic, but comparing
their sorted results is not, therefore that's completely sensible to do.

When writing this test, by coincidence I discovered how to generate the
"Undefined variable" error message. Unfortunately, the error message is
wrong since the variable NUMBERS is defined at that point. In summary,
that error message is shown when it shouldn't, and when it should it is
not shown. Still, I'm glad that I finally found it.
 1.3 16-Aug-2020  rillig make(1): move tests for the :O and :Or modifiers into separate files
 1.2 09-Jun-2020  sjg Add test case for :Or
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.5 16-Aug-2020  rillig make(1): move tests for the :Ox modifier into separate file

The test has been extended by ensuring that the shuffled words are still
the same. Comparing two shuffled lists is probabilistic, but comparing
their sorted results is not, therefore that's completely sensible to do.

When writing this test, by coincidence I discovered how to generate the
"Undefined variable" error message. Unfortunately, the error message is
wrong since the variable NUMBERS is defined at that point. In summary,
that error message is shown when it shouldn't, and when it should it is
not shown. Still, I'm glad that I finally found it.
 1.4 16-Aug-2020  rillig make(1): move tests for the :O and :Or modifiers into separate files
 1.3 09-Jun-2020  sjg Add test case for :Or
 1.2 07-Jan-2020  rillig usr.bin/make: document probabilities for random test failures

Side node: this test will never fail between 2024-04-15 and 2024-07-06.
 1.1 21-Aug-2014  apb branches: 1.1.16;
Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 07-Jun-2011  sjg Some systems (eg. MirBSD) use a ksh, with an echo which cannot
be used for things containing \x: etc.
Check for print or printf as builtin and use if available.
Note that a builtin will fail, if make decides a shell is not needed.
 1.1 20-Feb-2004  sjg branches: 1.1.54;
Fix :M so that modifiers in nested variables don't terminate parsing
early. Add a unit-test to verify it works and keeps working.
Re-jig the unit-tests so that all are sub makefiles.
 1.1.54.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.7 23-Jan-2022  rillig tests/make: migrate modts to varmod-to-separator and explain
 1.6 23-Feb-2021  rillig make: improve error message for bad modifier in variable expression

The improvement is especially noteable for variable expressions based on
the empty variable, see moderrs.exp:103.
 1.5 31-Aug-2020  rillig make(1): move some of the :ts tests into a separate file

The successful cases can be easily tested in the .if conditions. Around
these conditions, there is enough space for explaining the test cases
and their purpose.

The failure cases have been left in the file for now since they still
produce unwanted characters in the output. These characters are not
produced when the parse error occurs in a conditional.
 1.4 19-Jul-2020  rillig make(1): add more tests for :ts modifier
 1.3 19-Jul-2020  rillig make(1): demonstrate inconsistent :ts behavior among modifiers
 1.2 07-Mar-2016  sjg For :ts numeric escapes \x* is hex, anything else is octal.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.9 23-Jan-2022  rillig tests/make: migrate modts to varmod-to-separator and explain
 1.8 03-Nov-2020  rillig make(1): clean up unit tests
 1.7 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.6 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.5 31-Aug-2020  rillig make(1): move some of the :ts tests into a separate file

The successful cases can be easily tested in the .if conditions. Around
these conditions, there is enough space for explaining the test cases
and their purpose.

The failure cases have been left in the file for now since they still
produce unwanted characters in the output. These characters are not
produced when the parse error occurs in a conditional.
 1.4 19-Jul-2020  rillig make(1): add more tests for :ts modifier
 1.3 19-Jul-2020  rillig make(1): demonstrate inconsistent :ts behavior among modifiers
 1.2 07-Mar-2016  sjg For :ts numeric escapes \x* is hex, anything else is octal.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 27-Sep-2003  sjg Implement :[] modifier to allow picking a range of words out of a variable.
Also :tW and a W flag to :C and :S to allow treating value as a single word.
Add unit tests for the above, and fix some corner cases.
Based on patches supplied by Alan Barrett <apb@cequrux.com>
 1.5 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.4 14-Mar-2021  rillig make: add test for edge case in modifier ':[...]'

TryParseIntBase0 wrongly returns successful for a string that does not
start with a number at all. Its only caller, ApplyModifier_Words,
already handles all error cases properly.

No functional change.
 1.3 23-Feb-2021  rillig make: improve error message for bad modifier in variable expression

The improvement is especially noteable for variable expressions based on
the empty variable, see moderrs.exp:103.
 1.2 01-Nov-2020  rillig make(1): add tests for the variable modifiers :[words] and :range
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.7 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.6 14-Mar-2021  rillig make: add test for edge case in modifier ':[...]'

TryParseIntBase0 wrongly returns successful for a string that does not
start with a number at all. Its only caller, ApplyModifier_Words,
already handles all error cases properly.

No functional change.
 1.5 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.4 01-Nov-2020  rillig make(1): add tests for the variable modifiers :[words] and :range
 1.3 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.2 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.6 12-Jun-2025  rillig make: use a common style for unexpected error messages

In enomem, report the actual error instead of a fixed ENOMEM.
 1.5 09-Feb-2022  rillig branches: 1.5.4;
make: prefix the warning about read-only .OBJDIR with a colon

For consistency with the other warnings.
 1.4 09-Feb-2022  rillig tests/make: use more distinctive placeholder for TMPDIR
 1.3 04-Jul-2021  sjg Do not assume /tmp is safe to use if TMPDIR is set
 1.2 06-Feb-2021  sjg Avoid test failures when more than one user run them.

Use a private TMPDIR
a subdir of .OBJDIR if using it
otherwise /tmp/uid${.MAKE.UID}
 1.1 12-Nov-2020  sjg Pass a writable flag to Main_SetObjdir to control writable check

For curdir and an explicit .OBJDIR target, we allow for
the directory to be read-only.
During InitObjdir we otherwise default to requiring objdir to be
writable - this can be controlled by env variable
MAKE_OBJDIR_CHECK_WRITABLE

Add unit-tests/objdir-writable

Reviewed by: christos rillig
 1.5.4.1 02-Aug-2025  perseant Sync with HEAD
 1.7 09-Feb-2022  rillig tests/make: remove redundant 'echo' from variable assignments

Before main.c 1.231 from 2014-09-09, a variable assignment using the
operator '!=' generated a warning "Couldn't read shell's output" if the
output of the command was empty. The simplest way to suppress this
wrong warning was to add an empty 'echo' to the command. This hack is
no longer needed.
 1.6 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.5 04-Jul-2021  sjg Do not assume /tmp is safe to use if TMPDIR is set
 1.4 14-Nov-2020  sjg Remove RO_OBJDIR when done
 1.3 13-Nov-2020  rillig make(1): in lint mode, check for ".else <cond>"
 1.2 12-Nov-2020  sjg Use explicit MAKEOBJDIR to avoid tripping over /usr/obj
 1.1 12-Nov-2020  sjg Pass a writable flag to Main_SetObjdir to control writable check

For curdir and an explicit .OBJDIR target, we allow for
the directory to be read-only.
During InitObjdir we otherwise default to requiring objdir to be
writable - this can be controlled by env variable
MAKE_OBJDIR_CHECK_WRITABLE

Add unit-tests/objdir-writable

Reviewed by: christos rillig
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 02-Apr-2024  rillig tests/make: remove test for overly long chdir argument

On Cygwin, the path '/././..././' is normalized before being passed to
the child 'make' process. Since overly long pathnames are not required
to be supported on all platforms, remove the test.
 1.3 27-Dec-2020  rillig make(1): exit 2 on technical errors

This allows the -q option to distinguish errors from out-of-date
targets. Granted, it's an edge case but it should be solved
consistently anyway.

The majority of cases in which make exits with exit status 1, even in -q
mode, is when there are parse errors. These have been kept as-is for
now as they affect many of the unit tests.

The technical errors, on the other hand, occur so rarely that it's hard
to write reliable tests for them that fail consistently on all platforms
supported by make.
 1.2 14-Nov-2020  rillig make(1): add tests for the command line option -C
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7 02-Apr-2024  rillig tests/make: remove test for overly long chdir argument

On Cygwin, the path '/././..././' is normalized before being passed to
the child 'make' process. Since overly long pathnames are not required
to be supported on all platforms, remove the test.
 1.6 18-May-2021  sjg Do not trust that /nonexistent does not exist

Use /nonexistent.${.MAKE.PID} to avoid failure when
/nonexistent actually exists.
 1.5 15-Nov-2020  sjg branches: 1.5.2;
Avoid problem with /usr/obj
 1.4 14-Nov-2020  rillig make(1): add tests for the command line option -C
 1.3 14-Nov-2020  rillig make(1): document since when the -C option is available
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.2.1 31-May-2021  cjep sync with head
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.3 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.3 15-Apr-2022  rillig tests/make: adjust expectations to actual behavior

The bug in deptgt-silent-jobs.mk has been fixed, the debug logging for
comparing conditions and for deleting global variables has changed
intentionally.
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.6 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.5 26-Apr-2024  rillig branches: 1.5.2;
make: in parallel mode, print the directory in which a job failed

When multiple targets run in parallel, the "stopped in" line may be
several lines away from the "Failed target" line, making them hard to
correlate.
 1.4 28-Nov-2021  rillig make: with the option -de in jobs mode, output expanded commands

This helps tracking down the actual cause of build failures in build
systems like NetBSD's build.sh that use highly abstracted commands that
are mainly defined in terms of variables.
 1.3 27-Nov-2021  rillig tests/make: demonstrate unhelpful debug log in case of errors

The releng build job that runs lint fails. It outputs the usage message
of lint, which doesn't include the failing option. After that, make
outputs:

*** Failed target: lint-cgdconfig
*** Failed commands:
${LINT} ${LINTFLAGS} \
${_LDFLAGS.${:Ucgdconfig}:C/-L[ ]*/-L/Wg:M-L*} \
${LOBJS.${:Ucgdconfig}} ${_LDADD.${:Ucgdconfig}}

Make doesn't output the expanded command, therefore the log doesn't show
the offending option '-pthread' that leads to the usage message.
 1.2 27-Apr-2021  rillig make: remove stray space in -de output in jobs mode

In compat mode, having a space in this place makes sense to align the
target name with the command. In jobs mode, since each command is
listed in a separate line, there is no need for the double space.
 1.1 27-Apr-2021  rillig tests/make: test the combination of -de with -j1

The test cases are the same as in opt-debug-errors.mk. The output
differs in several details though.

Even though the option '-k' is given (which is the default for any tests
that don't override it in unit-tests/Makefile), there is no message
"(continuing)" anywhere.

The failed target is printed twice. Once before the failed commands,
once after. This redundancy is not necessary and may be removed in a
follow-up commit.

The printed commands are in their unexpanded form, which may or may not
be more helpful than the expanded and space-normalized form of compat
mode. Either way, this is an unnecessary inconsistency between compat
mode and jobs mode.

In jobs mode, the message "make: stopped in $dir" is printed for each
failure, which is helpful since each of the jobs may have started in a
separate directory.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 27-Nov-2021  rillig tests/make: demonstrate unhelpful debug log in case of errors

The releng build job that runs lint fails. It outputs the usage message
of lint, which doesn't include the failing option. After that, make
outputs:

*** Failed target: lint-cgdconfig
*** Failed commands:
${LINT} ${LINTFLAGS} \
${_LDFLAGS.${:Ucgdconfig}:C/-L[ ]*/-L/Wg:M-L*} \
${LOBJS.${:Ucgdconfig}} ${_LDADD.${:Ucgdconfig}}

Make doesn't output the expanded command, therefore the log doesn't show
the offending option '-pthread' that leads to the usage message.
 1.1 27-Apr-2021  rillig tests/make: test the combination of -de with -j1

The test cases are the same as in opt-debug-errors.mk. The output
differs in several details though.

Even though the option '-k' is given (which is the default for any tests
that don't override it in unit-tests/Makefile), there is no message
"(continuing)" anywhere.

The failed target is printed twice. Once before the failed commands,
once after. This redundancy is not necessary and may be removed in a
follow-up commit.

The printed commands are in their unexpanded form, which may or may not
be more helpful than the expanded and space-normalized form of compat
mode. Either way, this is an unnecessary inconsistency between compat
mode and jobs mode.

In jobs mode, the message "make: stopped in $dir" is printed for each
failure, which is helpful since each of the jobs may have started in a
separate directory.
 1.4 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.3 07-Dec-2020  rillig branches: 1.3.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.2 06-Sep-2020  rillig make(1): add test for the -de option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.3.8.1 02-Aug-2025  perseant Sync with HEAD
 1.2 06-Sep-2020  rillig make(1): add test for the -de option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.11 09-Aug-2025  rillig tests/make: fix typo
 1.10 06-Jul-2025  rillig tests/make: describe how to read a file into a variable
 1.9 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.8 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.7 01-Jun-2023  rillig branches: 1.7.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.5 11-Jan-2022  rillig tests/make: clean up after test for option '-dF'

When the file for the debug log cannot be opened, make exits
immediately. This doesn't give the test a chance to clean up the
temporary log file.

Instead of trying to treat a regular file as a directory and create a
file in it, assume that the directory /nonexistent-$uuid is actually
nonexistent. This leads to the same kind of error message, independent
of strerror(3).
 1.4 09-Jan-2022  rillig tests/make: test output channels for parse errors and other errors
 1.3 27-Dec-2021  rillig make: remove usage message if the debug file cannot be opened

Since a non-writable file is not a syntax error, there is no point in
showing the usage in this situation. Showing the usage may have been a
copy-and-paste mistake from a few lines below, when this option was
added back in main.c 1.133 from 2006-10-15.
 1.2 27-Dec-2021  rillig tests/make: cover a debug log file that cannot be opened
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.7.2.2 02-Aug-2025  perseant Sync with HEAD
 1.7.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.13 09-Aug-2025  rillig tests/make: fix typo
 1.12 06-Jul-2025  rillig tests/make: describe how to read a file into a variable
 1.11 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.10 19-Nov-2023  rillig branches: 1.10.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.9 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.8 11-Jan-2022  rillig tests/make: clean up after test for option '-dF'

When the file for the debug log cannot be opened, make exits
immediately. This doesn't give the test a chance to clean up the
temporary log file.

Instead of trying to treat a regular file as a directory and create a
file in it, assume that the directory /nonexistent-$uuid is actually
nonexistent. This leads to the same kind of error message, independent
of strerror(3).
 1.7 09-Jan-2022  rillig tests/make: test output channels for parse errors and other errors
 1.6 28-Dec-2021  rillig tests/make: clean up after test 'opt-debug-file'
 1.5 27-Dec-2021  rillig tests/make: cover a debug log file that cannot be opened
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 03-Oct-2020  rillig make(1): add test for the -dF option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.10.2.2 02-Aug-2025  perseant Sync with HEAD
 1.10.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.5 01-Jun-2023  rillig make: add more details to debug logging of .for loops
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 03-Oct-2020  rillig make(1): add test for the -df debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 03-Oct-2020  rillig make(1): add test for the -df debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.3 05-Sep-2020  rillig make(1): move test for -dg1 from opt-debug-g1 to opt-debug-graph1
 1.2 29-Aug-2020  rillig make(1): fix test opt-debug-g1

Including the directory cache made the test output fragile.
 1.1 27-Aug-2020  rillig make(1): add test for the -dg1 option
 1.2 05-Sep-2020  rillig make(1): move test for -dg1 from opt-debug-g1 to opt-debug-graph1
 1.1 27-Aug-2020  rillig make(1): add test for the -dg1 option
 1.14 07-May-2025  rillig make: add end marker for -dg1, -dg2 and -dg3 debug log

The marker helps distinguish the output from sub-makes from the output
of the primary make.
 1.13 07-May-2024  sjg branches: 1.13.2;
make: all command line overrides go in .MAKEOVERRIDES

Not all variables that start with '.' are internals,
and unless they are explicitly flagged as internal should go
into .MAKEOVERRIDES

Update varname-dot-makeoverrides to check this.

Also avoid using SCOPE_CMDLINE when ReadOnly will do.
 1.12 09-Sep-2023  sjg Add .MAKE.JOBS.C to indicate wether -jC is supported
 1.11 24-Jan-2023  sjg make: .SYSPATH: to add dirs to sysIncPath

.SYSPATH: with no sources will clear sysIncPath
otherwise sources are added

Reviewed by: rillig
 1.10 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.9 02-Feb-2021  rillig make: remove overengineered Enum_ValueToString

For printing the status of a GNode, there was already made_name (now
renamed to GNodeMade_Name), which prints user-friendly text instead of
the bare enum constant names.

To do this change confidently, I first had to demonstrate that the
output really affects something other than just the word "UNMADE". There
had not been a test for that case before, and the test immediately
discovered a bug in the -dg2 and -dg3 options. This bug is one of the
oldest in make, dating back to at least 1993.
 1.8 04-Dec-2020  rillig make(1): use fixed format for debug output of the directory cache

The previous output format had a %-20s conversion specifier. This
produced different output depending on the length of the pathname, which
was too difficult to normalize. By moving the directory name to the
end, it is no longer necessary to fill up any space, and the numbers are
always aligned properly.

As a result, 3 of the unit tests no longer need any special
postprocessing of their output.
 1.7 25-Nov-2020  sjg Add .MAKE.UID and .MAKE.GID
 1.6 23-Nov-2020  rillig make(1): make output of test opt-debug-graph1 consistent

The output from the directory cache made the regular NetBSD build fail
because the pathname to the working directory differs, thus affecting
the spacing.

This time, document why the directory cache needs to be excluded from
the output.
 1.5 22-Nov-2020  rillig make(1): add more output to test for -dg1

Previously, the variables section had been omitted. This was because
the variables had been output in hashcode order until 2020-10-18, and
because some of the variable values are specific to the test environment
or the individual run (MACHINE_ARCH, MAKE.PPID).
 1.4 25-Sep-2020  rillig make(1): fix missing check for duplicate commands in Parse_File
 1.3 05-Sep-2020  rillig make(1): remove trailing whitespace in -dg1 debug output
 1.2 05-Sep-2020  rillig make(1): move test for -dg1 from opt-debug-g1 to opt-debug-graph1
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 05-Sep-2020  rillig make(1): remove trailing whitespace in -dg1 debug output
 1.2 05-Sep-2020  rillig make(1): move test for -dg1 from opt-debug-g1 to opt-debug-graph1
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.10 07-May-2025  rillig make: add end marker for -dg1, -dg2 and -dg3 debug log

The marker helps distinguish the output from sub-makes from the output
of the primary make.
 1.9 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.8 07-May-2024  sjg branches: 1.8.2;
make: all command line overrides go in .MAKEOVERRIDES

Not all variables that start with '.' are internals,
and unless they are explicitly flagged as internal should go
into .MAKEOVERRIDES

Update varname-dot-makeoverrides to check this.

Also avoid using SCOPE_CMDLINE when ReadOnly will do.
 1.7 09-Sep-2023  sjg Add .MAKE.JOBS.C to indicate wether -jC is supported
 1.6 24-Jan-2023  sjg make: .SYSPATH: to add dirs to sysIncPath

.SYSPATH: with no sources will clear sysIncPath
otherwise sources are added

Reviewed by: rillig
 1.5 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.4 02-Feb-2021  rillig make: remove overengineered Enum_ValueToString

For printing the status of a GNode, there was already made_name (now
renamed to GNodeMade_Name), which prints user-friendly text instead of
the bare enum constant names.

To do this change confidently, I first had to demonstrate that the
output really affects something other than just the word "UNMADE". There
had not been a test for that case before, and the test immediately
discovered a bug in the -dg2 and -dg3 options. This bug is one of the
oldest in make, dating back to at least 1993.
 1.3 02-Feb-2021  rillig make: when exiting due to an error, print graph information

The code now does what the manual page has been promising since at least
1993.
 1.2 02-Feb-2021  rillig make: demonstrate that neither -dg2 nor -dg3 produces debug output
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 02-Feb-2021  rillig make: when exiting due to an error, print graph information

The code now does what the manual page has been promising since at least
1993.
 1.2 02-Feb-2021  rillig make: demonstrate that neither -dg2 nor -dg3 produces debug output
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.10 07-May-2025  rillig make: add end marker for -dg1, -dg2 and -dg3 debug log

The marker helps distinguish the output from sub-makes from the output
of the primary make.
 1.9 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.8 07-May-2024  sjg branches: 1.8.2;
make: all command line overrides go in .MAKEOVERRIDES

Not all variables that start with '.' are internals,
and unless they are explicitly flagged as internal should go
into .MAKEOVERRIDES

Update varname-dot-makeoverrides to check this.

Also avoid using SCOPE_CMDLINE when ReadOnly will do.
 1.7 09-Sep-2023  sjg Add .MAKE.JOBS.C to indicate wether -jC is supported
 1.6 24-Jan-2023  sjg make: .SYSPATH: to add dirs to sysIncPath

.SYSPATH: with no sources will clear sysIncPath
otherwise sources are added

Reviewed by: rillig
 1.5 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.4 02-Feb-2021  rillig make: remove overengineered Enum_ValueToString

For printing the status of a GNode, there was already made_name (now
renamed to GNodeMade_Name), which prints user-friendly text instead of
the bare enum constant names.

To do this change confidently, I first had to demonstrate that the
output really affects something other than just the word "UNMADE". There
had not been a test for that case before, and the test immediately
discovered a bug in the -dg2 and -dg3 options. This bug is one of the
oldest in make, dating back to at least 1993.
 1.3 02-Feb-2021  rillig make: when exiting due to an error, print graph information

The code now does what the manual page has been promising since at least
1993.
 1.2 02-Feb-2021  rillig make: demonstrate that neither -dg2 nor -dg3 produces debug output
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 02-Feb-2021  rillig make: when exiting due to an error, print graph information

The code now does what the manual page has been promising since at least
1993.
 1.2 02-Feb-2021  rillig make: demonstrate that neither -dg2 nor -dg3 produces debug output
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 07-Jul-2024  rillig make: don't track hash table chain lengths during lookup

The chain lengths are only used for debugging purposes, so avoid the
extra cost at each lookup. Instead, calculate the maximum chain length
only when it is actually requested in -dh mode.

The reported number changes slightly: Before, it was the length of the
chain that was actually traversed to find an entry, up to that entry,
now it is the length of the largest chain in the table, no matter if it
was actually accessed or not.
 1.6 31-May-2024  rillig branches: 1.6.2;
tests/make: replace or document .error in tests

The text 'Missing argument for ".error"' in an .exp file may be a hint
for an accidentally broken test, so eliminate them as far as possible.
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 27-Jan-2022  sjg numEntries can vary
 1.3 22-Jan-2022  rillig make: add missing newline after "cannot continue" message

It was wrong of Parse_File to output an unfinished line and hope for
some other code to finish it. As demonstrated in the test, PrintOnError
did not do that in the case of additional debug output.

To keep the overall behavior as close as possible to before, the other
callers of PrintOnError now have to pass the newline themselves. Passing
strings that start with newlines but don't end with them looked
suspicious anyway.
 1.2 22-Jan-2022  rillig tests/make: add a few more tests
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 31-May-2024  rillig tests/make: replace or document .error in tests

The text 'Missing argument for ".error"' in an .exp file may be a hint
for an accidentally broken test, so eliminate them as far as possible.
 1.4 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 22-Jan-2022  rillig make: add missing newline after "cannot continue" message

It was wrong of Parse_File to output an unfinished line and hope for
some other code to finish it. As demonstrated in the test, PrintOnError
did not do that in the case of additional debug output.

To keep the overall behavior as close as possible to before, the other
callers of PrintOnError now have to pass the newline themselves. Passing
strings that start with newlines but don't end with them looked
suspicious anyway.
 1.2 22-Jan-2022  rillig tests/make: add a few more tests
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.15 09-May-2025  rillig make: unify debug messages for parallel mode

Always print the process status in hex, with a leading "0x", to avoid
confusion for status 127f, which looks suspiciously decimal.

Prefix all process IDs with "pid", to be able to filter them easily.

Omit trailing whitespace when printing a command.
 1.14 09-May-2025  rillig make: replace magic numbers in job debug log with descriptive names
 1.13 03-May-2025  rillig make: use uniform debug log messages for the token pool
 1.12 02-May-2025  rillig make: in the debug log, replace magic numbers with identifiers
 1.11 22-Apr-2025  rillig make: group the code for handling the job token pool
 1.10 12-Dec-2020  rillig branches: 1.10.8;
make(1): move Job.xtraced to ShellWriter

This flag was placed wrong in the Job since it is only necessary as long
as the shell commands are written to the shell file.

Resetting it in JobStart and JobExec was completely misguided since that
is far away from writing the shell commands; this should have been done
in JobPrintCommands instead.

The status of this flag doesn't need to be printed in debugging mode
since it is controlled by a single command line option (-dx) and does
not interact with all the other switches.
 1.9 10-Dec-2020  rillig make(1): split JobFlags into separate fields

Having all these flags in a single bitmask makes it harder to see where
exactly they can possibly be used since their state could also be
modified using the unsuspicious job->flags = 0. Using individual names
just leaves the single memset, and that is only used during
initialization.
 1.8 19-Nov-2020  rillig make(1): fix test opt-debug-jobs when compiled with dash as shell

make USER_CPPFLAGS=-DDEFSHELL_CUSTOM='\"/usr/pkg/bin/dash\"'
 1.7 12-Nov-2020  rillig make(1): avoid race condition in test opt-debug-jobs

Thanks sjg for finding this and suggesting the fix.
 1.6 08-Nov-2020  rillig make(1): clean up debug output for running jobs

There is no remote anymore, therefore mentioning locally is redundant.
It was a bad idea anyway to build format strings that work with parts of
words.
 1.5 08-Oct-2020  rillig make(1): fix test opt-debug-jobs on non-native platforms
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 03-Oct-2020  rillig make(1): add test for the -dj debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.10.8.1 02-Aug-2025  perseant Sync with HEAD
 1.6 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.5 12-Nov-2020  rillig make(1): avoid race condition in test opt-debug-jobs

Thanks sjg for finding this and suggesting the fix.
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 03-Oct-2020  rillig make(1): add test for the -dj debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.26 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.25 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.24 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.23 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.22 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.21 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.20 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.19 20-Apr-2024  rillig branches: 1.19.2;
make: provide more context information for parse/evaluate errors
 1.18 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.17 14-Feb-2023  rillig make: don't interpret the return value of Var_Parse

The return value of Var_Parse is largely redundant to the returned
string. The idea behind the type VarParseResult was to migrate all call
sites to checking this return value instead of the returned string, but
that hasn't happened. Instead, the additional type only added more
complexity.

There was a single place where that return value was actually used, when
parsing conditions. And even in that case, ignoring the VarParseResult
added back an error message that previously hid bugs, in the test
cond-token-plain.mk.

Even though these error messages are redundant in the other tests, they
don't hurt as they don't happen often.
 1.16 14-Mar-2021  rillig make: fix wrong expression evaluation in -dL mode

The modifier ':C' now only compiles the regular expression if the result
of the expression is actually needed.

Several other modifiers have the same bug of evaluating the expression
in cases where this is not needed. It just doesn't show up because they
don't have any noticeable side effects, other than wasting CPU time.
This affects irrelevant conditions as well.
 1.15 14-Mar-2021  rillig make: demonstrate wrong expression evaluation in -dL mode
 1.14 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.13 20-Dec-2020  rillig make(1): error out on unknown variable modifiers at parse time

Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such. This "error message"
also did not influence the exit status in the default mode but only in
-dL mode. The error message also didn't include any line number
information and was thus rude.
 1.12 20-Dec-2020  rillig make(1): remove wrong error message for indirect modifier in lint mode
 1.11 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.10 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.9 03-Oct-2020  rillig make(1): in lint mode, reject modifiers without delimiter

The expression ${VAR:LPL} must now be written as ${VAR:L:P:L}. The
manual page has never documented that some modifiers don't need to be
delimited by ':' and others need to. That would have been unnecessarily
confusing anyway.
 1.8 03-Oct-2020  rillig make(1): add test for variable modifiers without delimiter
 1.7 14-Sep-2020  rillig make(1): fix wrong error for undefined variables in lint mode
 1.6 14-Sep-2020  rillig make(1): add test for wrong error in lint mode for undefined variable
 1.5 14-Sep-2020  rillig make(1): remove obsolete comments from tests
 1.4 13-Sep-2020  rillig make(1): in lint mode, report undefined variables in conditions
 1.3 13-Sep-2020  rillig make(1): suppress wrong "Malformed conditional" for undefined variables

This only has an effect in lint mode right now.
 1.2 13-Sep-2020  rillig make(1): in lint mode, improve error handling for undefined variables

It's a first step for improving the error message that make prints.
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.19.2.1 02-Aug-2025  perseant Sync with HEAD
 1.25 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.24 04-Apr-2025  rillig make: fix error message for undefined variable in conditional

Previously, only ${UNDEF} had the proper error message, while
${UNDEF:M*} still produced the wrong "Malformed conditional".
 1.23 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.22 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.21 11-Jan-2025  rillig tests/make: force correct order of expected messages
 1.20 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.19 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.18 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.17 20-Apr-2024  rillig branches: 1.17.2;
make: provide more context information for parse/evaluate errors
 1.16 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.15 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.14 14-Mar-2021  rillig make: fix wrong expression evaluation in -dL mode

The modifier ':C' now only compiles the regular expression if the result
of the expression is actually needed.

Several other modifiers have the same bug of evaluating the expression
in cases where this is not needed. It just doesn't show up because they
don't have any noticeable side effects, other than wasting CPU time.
This affects irrelevant conditions as well.
 1.13 14-Mar-2021  rillig make: demonstrate wrong expression evaluation in -dL mode
 1.12 20-Dec-2020  rillig make(1): remove wrong error message for indirect modifier in lint mode
 1.11 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.10 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.9 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.8 03-Oct-2020  rillig make(1): add test for variable modifiers without delimiter
 1.7 14-Sep-2020  rillig make(1): fix wrong error for undefined variables in lint mode
 1.6 14-Sep-2020  rillig make(1): add test for wrong error in lint mode for undefined variable
 1.5 14-Sep-2020  rillig make(1): in lint mode, allow undefined variables in dependency lines

This is needed to get past the first few seconds in a src/build.sh run.

The nest obstacle is src/tools/Makefile.gnuhost:30, where the variable
MODULE is undefined even though that file says in line 3 that MODULE is
expected to be set. It has been saying this since 2001, but since make
didn't have the corresponding check enabled, this didn't break the
build.
 1.4 14-Sep-2020  rillig make(1): remove obsolete comments from tests
 1.3 13-Sep-2020  rillig make(1): in lint mode, report undefined variables in conditions
 1.2 13-Sep-2020  rillig make(1): in lint mode, improve error handling for undefined variables

It's a first step for improving the error message that make prints.
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.17.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 03-Oct-2020  rillig make(1): add test for the -dl command line option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.5 19-Dec-2023  rillig make: clean up comments

No binary change, except for line numbers in assertions.
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 03-Oct-2020  rillig make(1): add test for the -dl command line option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.14 11-Apr-2025  rillig make: convert more messages to the "file:123" format
 1.13 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.12 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.11 14-Apr-2024  rillig branches: 1.11.2;
make: add debug logging for .if and .for lines in -dp mode

This helps track down in which line a condition is evaluated.
 1.10 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.9 09-Jan-2022  rillig tests/make: add placeholders for .PARSEDIR and .INCLUDEDFROMDIR

When run via 'cd usr.bin/make/unit-tests && make test', the tests are in
the current directory. When run via ATF, the tests are in
/usr/tests/usr.bin/make/unit-tests, while the current directory is a
temporary directory. Allow both variants, plus others that may occur in
the bmake distribution.
 1.8 09-Jan-2022  rillig make: remove redundant lines from stack traces

These lines repeated the information from the .for loop line above them.
 1.7 08-Jan-2022  rillig make: add details about .for loop variables to stack traces

The stack traces are enabled with the debug logging option '-dp'.
 1.6 08-Jan-2022  rillig make: fix stack traces in -dp mode (since 2021-01-26)

Previously, the stack traces omitted some lines that seemed to be
redundant. As a result, the stack traces contained confusing line
numbers.
 1.5 08-Jan-2022  rillig make: fix line number in debug log after returning from a file

The parser returns to the next line, not to the current line.
 1.4 08-Jan-2022  rillig tests/make: test line numbers in debug output for parsing files
 1.3 08-Jan-2022  rillig make: fix reported line numbers of continuation lines (since 2002)

Previously, multi-line directives like '.info' or '.error' reported the
line number of their last line instead of their first line, which is
more usual. This also affected the debug log from '-dp'.
 1.2 02-Jan-2022  rillig tests/make: demonstrate bugs in PrintStackTrace
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.11.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.6 08-Jan-2022  rillig make: add details about .for loop variables to stack traces

The stack traces are enabled with the debug logging option '-dp'.
 1.5 08-Jan-2022  rillig make: fix stack traces in -dp mode (since 2021-01-26)

Previously, the stack traces omitted some lines that seemed to be
redundant. As a result, the stack traces contained confusing line
numbers.
 1.4 08-Jan-2022  rillig make: fix line number in debug log after returning from a file

The parser returns to the next line, not to the current line.
 1.3 08-Jan-2022  rillig tests/make: test line numbers in debug output for parsing files
 1.2 02-Jan-2022  rillig tests/make: demonstrate bugs in PrintStackTrace
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.4 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.3 26-Mar-2022  rillig branches: 1.3.4;
make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.3.4.1 02-Aug-2025  perseant Sync with HEAD
 1.5 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.4 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.3 19-Nov-2023  rillig branches: 1.3.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 05-Sep-2020  rillig make(1): add tests for each debug option
 1.5 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.4 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.3 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.2 03-Oct-2020  rillig make(1): allow to disable debug logging options

This is only intended for the unit tests, to selectively enable and
disable debug logging as needed. Previously the tests for debug logging
required complicated postprocessing that was not obvious when looking at
the test .mk file alone, but was specified externally in
unit-tests/Makefile.

This is the simplest possible implementation. Another variant would
have been to selectively disable individual debug logging options, but
that would have made the code more complicated.

The -dL option is not affected by -d0 since that is not really a debug
option, even if it is implemented as one.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.4 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.3 03-Oct-2020  rillig make(1): allow to disable debug logging options

This is only intended for the unit tests, to selectively enable and
disable debug logging as needed. Previously the tests for debug logging
required complicated postprocessing that was not obvious when looking at
the test .mk file alone, but was specified externally in
unit-tests/Makefile.

This is the simplest possible implementation. Another variant would
have been to selectively disable individual debug logging options, but
that would have made the code more complicated.

The -dL option is not affected by -d0 since that is not really a debug
option, even if it is implemented as one.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 12-Jun-2022  rillig tests/make: demonstrate what happens for 'make -DVAR=value'
 1.3 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 25-Sep-2022  rillig tests/make: fix test for option '-e' (broken since 2022-01-23)
 1.3 26-Mar-2022  rillig make: clean up comments
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 26-Mar-2022  rillig make: clean up comments
 1.3 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.13 12-Jun-2025  rillig make: add program name to stack traces from sub-makes
 1.12 12-Jun-2025  rillig make: add quotes to "in directory" line in stack traces

The other lines in stack traces use quotes as well.
 1.11 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.10 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.9 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.8 01-Apr-2024  rillig branches: 1.8.2;
make: exit immediately after reading a null byte from a makefile

The chance of other garbage bytes in such a file is just too high.
 1.7 22-Dec-2020  rillig make(1): re-add improved assertion in ParseGetLine
 1.6 22-Dec-2020  rillig make(1): fix assertion failure for files without trailing newline

Previously, mmapped files didn't always have the final newline added.
Only those that ended at a page boundary did.

This confused ParseRawLine, which assumed (and since parse.c 1.510 from
moments ago also asserted) that every line ends with a newline, which
allows the code to assume that after a backslash, there is at least one
other character in the buffer, thereby preventing an out-of-bounds read.

This bug had been there at least since parse.c 1.170 from 2010-12-25
04:57:07, maybe even earlier, I didn't check.

Now line_end always points to the trailing newline, which allows
ParseGetLine to overwrite that character to end the string.
 1.5 07-Dec-2020  rillig make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.4 06-Dec-2020  rillig make(1): error out on null bytes in makefiles

Makefiles are text files, they must not contain null bytes.

The previous code in this area was rotten anyway. It assumed that
buf_end could be NULL even if buf_ptr was a valid pointer, which is no
longer true, probably since a few years already.

Continuing parsing after a null byte does not make sense. If there's a
null byte in a text file, that file is corrupted, and parsing it leads
to unintended effects easily. Therefore the only sensible action is to
stop parsing immediately.

The check whether cf->readMore could be null was outdated as well, which
previously made the fatal error impossible to reach. Because of the
missing unit tests, nobody noticed this though.

The "exit status 0" in opt-file.exp is worring but that's due to another
bug and will be fixed in a follow-up commit.
 1.3 06-Dec-2020  rillig make(1): add test for makefile containing null bytes
 1.2 06-Dec-2020  rillig make(1): test parsing a makefile that ends in a backslash
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.16 01-Apr-2024  rillig make: exit immediately after reading a null byte from a makefile

The chance of other garbage bytes in such a file is just too high.
 1.15 26-Mar-2022  rillig make: clean up comments
 1.14 09-Dec-2021  rillig make: add back support for jemalloc 100

The ports sun2 and vax default to jemalloc 100, as opposed to the rest
of the ports, which use jemalloc 510. Some developers choose to use
jemalloc 100, so let them run the tests with memory debugging as well.

Suggested by mrg on source-changes-d.
 1.13 05-Dec-2021  rillig tests/make: migrate to jemalloc > 100

When I started working on usr.bin/make in 2020, I used NetBSD 8, which
used jemalloc 100.

After updating to NetBSD 8 to 9.99.x, the debugging options for jemalloc
stopped working since MALLOC_OPTIONS had been replaced with MALLOC_CONF
in 2019.

Enable malloc debugging again, to reliably reproduce the use-after-free
for the variable modifier ':@'.
 1.12 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.11 22-Dec-2020  rillig make(1): fix comment in test about null bytes in makefiles
 1.10 22-Dec-2020  rillig make(1): re-add improved assertion in ParseGetLine
 1.9 22-Dec-2020  rillig make(1): clean up after test opt-file
 1.8 22-Dec-2020  rillig make(1): fix assertion failure for files without trailing newline

Previously, mmapped files didn't always have the final newline added.
Only those that ended at a page boundary did.

This confused ParseRawLine, which assumed (and since parse.c 1.510 from
moments ago also asserted) that every line ends with a newline, which
allows the code to assume that after a backslash, there is at least one
other character in the buffer, thereby preventing an out-of-bounds read.

This bug had been there at least since parse.c 1.170 from 2010-12-25
04:57:07, maybe even earlier, I didn't check.

Now line_end always points to the trailing newline, which allows
ParseGetLine to overwrite that character to end the string.
 1.7 06-Dec-2020  rillig make(1): document undefined behavior from 2014

Earlier versions of make didn't know the -v option to print the expanded
value of a variable. To make the test runnable by older makes as well,
switch to -V instead, which has been available much longer.
 1.6 06-Dec-2020  rillig make(1): error out on null bytes in makefiles

Makefiles are text files, they must not contain null bytes.

The previous code in this area was rotten anyway. It assumed that
buf_end could be NULL even if buf_ptr was a valid pointer, which is no
longer true, probably since a few years already.

Continuing parsing after a null byte does not make sense. If there's a
null byte in a text file, that file is corrupted, and parsing it leads
to unintended effects easily. Therefore the only sensible action is to
stop parsing immediately.

The check whether cf->readMore could be null was outdated as well, which
previously made the fatal error impossible to reach. Because of the
missing unit tests, nobody noticed this though.

The "exit status 0" in opt-file.exp is worring but that's due to another
bug and will be fixed in a follow-up commit.
 1.5 06-Dec-2020  rillig make(1): document how make behaved for null bytes in the makefile
 1.4 06-Dec-2020  rillig make(1): add test for makefile containing null bytes
 1.3 06-Dec-2020  rillig make(1): test parsing a makefile that ends in a backslash
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 18-Oct-2020  rillig make(1): switch some tests to line-buffered stdout

On Alpine Linux, the output was not in the same order as on NetBSD,
at least since bmake-20200902.

The mixture of block-buffered output from child processes and make
itself was hard to predict anyway. Switching to line-buffered stdout
improves the stability of the tests.
 1.2 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.4 18-Oct-2020  rillig make(1): switch some tests to line-buffered stdout

On Alpine Linux, the output was not in the same order as on NetBSD,
at least since bmake-20200902.

The mixture of block-buffered output from child processes and make
itself was hard to predict anyway. Switching to line-buffered stdout
improves the stability of the tests.
 1.3 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.12 02-Jul-2025  rillig make: shorten diagnostic for invalid -J option

In the manual page, there's more space to properly explain the
complexity behind the warning.
 1.11 16-Jun-2025  rillig make: in a warning without location information, print the stack trace

Without further context, a warning like the following is hard to track
back:

> nbmake[4]: warning: Invalid character " " in variable name
> "if ,"LSAN_OPTIONS=""
 1.10 13-Jun-2025  rillig make: new sentence, new line
 1.9 05-Jun-2025  rillig make: remove empty line from diagnostic, add tests for output handling

The warning for the invalid internal option "-J" does not need a
trailing newline, as that is provided by Parse_Error already.

Having this newline in the output demonstrated a previously unknown bug
in handling the output of child commands in parallel mode. There, empty
lines are randomly discarded, depending on the chunks in which the
output from the child process is copied to make's stdout. See
job-output.mk for a demonstration.

The test for the Korn shell did not run the Korn shell in error handling
mode, as the error handling mode only affects the parallel mode but the
test didn't switch to that mode.

After fixing the shell-ksh.mk test, the single '"' in the output looked
suspicious, and indeed, the shell-csh.mk test had the same problem of
filtering more characters from the output than intended.
 1.8 28-May-2025  sjg make: delay warning about bogus -J flag

In MainParseArgJobsInternal just set bogusJflag to indicate
that the descriptors passed were invalid.

By the time we get to InitMaxJobs the command line and indeed
the makefile have had a chance to put us in compat mode,
in which case the warning is unnecessary.
Add suggestion of -B if compat mode is desired in the sub-make.

Reviewed by: rillig
 1.7 26-May-2025  rillig make: show contents of MAKEFLAGS in the stack trace

When the internal -J option refers to a closed file descriptor, it's
helpful to know what the MAKEFLAGS environment variable contains, in
addition to the executed command line. Same for parse errors in
variable assignments from the command line.
 1.6 23-May-2025  rillig make: add current directory to error messages from MAKEFLAGS

While parsing the additional command line arguments from the MAKEFLAGS
environment variable, the current directory was not initialized yet, so
swap the order.

As a side effect, this change would allow a "-m .../share/mk" option,
with a literal magic "...", thus looking up the system directory in any
ancestor directory of the current directory. This idea sounds unreliable
enough that probably nobody will try this in practice.
 1.5 23-May-2025  rillig make: warn when falling from parallel mode back to compat mode

Falling back may run fewer jobs than intended, thus increasing the build's
wall time.

Falling back may run more jobs than intended, when a sub-make creates
its own and independent token pool, thus overloading the system.

Warn in both cases. Since the -J option is internal, it is not obvious
how to fix the situation, so provide detailed instructions on the
possible fixes and their effects.
 1.4 11-May-2025  rillig make: clean up error message for malformed internal -J option

There's no point printing the usage, as the problem is typically
somewhere else. Reword the message to be easier to parse.
 1.3 11-May-2025  rillig tests/make: document internal option for parallel mode

In several places in the NetBSD build, a subdir target invokes
${MAKEDIRTARGET}, assuming that this sub-make would coordinate the
number of parallel jobs with its parent make. But since that command
neither contains the plain word "make" nor the expression "${MAKE}", the
sub-make falls back to compat mode.
 1.2 23-Jan-2022  rillig branches: 1.2.4;
tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2.4.1 02-Aug-2025  perseant Sync with HEAD
 1.6 23-May-2025  rillig make: warn when falling from parallel mode back to compat mode

Falling back may run fewer jobs than intended, thus increasing the build's
wall time.

Falling back may run more jobs than intended, when a sub-make creates
its own and independent token pool, thus overloading the system.

Warn in both cases. Since the -J option is internal, it is not obvious
how to fix the situation, so provide detailed instructions on the
possible fixes and their effects.
 1.5 11-May-2025  rillig make: clean up error message for malformed internal -J option

There's no point printing the usage, as the problem is typically
somewhere else. Reword the message to be easier to parse.
 1.4 11-May-2025  rillig tests/make: document internal option for parallel mode

In several places in the NetBSD build, a subdir target invokes
${MAKEDIRTARGET}, assuming that this sub-make would coordinate the
number of parallel jobs with its parent make. But since that command
neither contains the plain word "make" nor the expression "${MAKE}", the
sub-make falls back to compat mode.
 1.3 23-Jan-2022  rillig branches: 1.3.4;
tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3.4.1 02-Aug-2025  perseant Sync with HEAD
 1.6 10-Dec-2020  rillig make(1): name Shell fields consistently

They are all templates with a single %s placeholder, so embed this
unambiguously in the variable name. The previous variable names didn't
provide any clue that echoCmd, execIgnore and errExit had a lot in
common.
 1.5 09-Dec-2020  rillig make(1): clean up test output of opt-jobs-no-action
 1.4 09-Dec-2020  rillig make(1): remove noise from test output of opt-jobs-no-action
 1.3 09-Dec-2020  rillig make(1): refine test for combining -j1 and -n
 1.2 09-Dec-2020  rillig make(1): add more tests for combining -j1 and -n
 1.1 09-Dec-2020  rillig make(1): add test for combining -j1 with -n
 1.10 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.9 04-Apr-2021  rillig make: rename ambiguous functions

These two functions have counterparts that include the word 'Do' in
their name, which is confusing.

No functional change.
 1.8 10-Dec-2020  rillig make(1): name Shell fields consistently

They are all templates with a single %s placeholder, so embed this
unambiguously in the variable name. The previous variable names didn't
provide any clue that echoCmd, execIgnore and errExit had a lot in
common.
 1.7 09-Dec-2020  rillig make(1): clean up test output of opt-jobs-no-action
 1.6 09-Dec-2020  rillig make(1): remove noise from test output of opt-jobs-no-action
 1.5 09-Dec-2020  rillig make(1): split the -j -n test into separate targets

The manual page says that in -j mode when the shell does not have ErrCtl
(and none of the default shells has that), the command prefix '-'
"affects the entire job", but this seems to be wrong. At least, there
is no change in the output from before, when all commands had been in
the same target.
 1.4 09-Dec-2020  rillig make(1): add test for the -n option combined with RunFlags
 1.3 09-Dec-2020  rillig make(1): refine test for combining -j1 and -n
 1.2 09-Dec-2020  rillig make(1): add more tests for combining -j1 and -n
 1.1 09-Dec-2020  rillig make(1): add test for combining -j1 with -n
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7 20-May-2025  sjg Revert export of MAKEFLAGS from Cmd_Exec

Until we work out what the issue is.
Revert related unit-test changes as well
 1.6 18-May-2025  rillig tests/make: test exporting of MAKEFLAGS in compat and parallel mode
 1.5 10-Sep-2023  sjg branches: 1.5.2;
make: skip -jC tests unless .MAKE.JOBS.C is yes
 1.4 10-Sep-2023  rillig make: add more details to usage message of -j option
 1.3 10-Sep-2023  rillig tests/make: add tests for parsing the -j option
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.1 12-Feb-2022  rillig branches: 1.1.4;
tests/make: document the history of bugs in '-k' mode

Reported in PR#49720 in 2015, fixed independently in compat.c 1.199 from
2020-12-07.
 1.1.4.1 02-Aug-2025  perseant Sync with HEAD
 1.3 02-Apr-2024  rillig tests/make: pass PATH onto child processes

This fixes the tests on some Cygwin variant where the shell does not
initialize the PATH environment variable when it's missing.
 1.2 12-Feb-2022  rillig tests/make: clean up comments in test for indirect -k failures

See PR#49720.
 1.1 12-Feb-2022  rillig tests/make: document the history of bugs in '-k' mode

Reported in PR#49720 in 2015, fixed independently in compat.c 1.199 from
2020-12-07.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Dec-2020  rillig branches: 1.2.8;
make(1): fix wrong exit status for multiple failed main targets
 1.1 07-Dec-2020  rillig make(1): add test for wrong exit status 0 after failed targets with -k
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 07-Dec-2020  rillig make(1): add test for wrong exit status 0 after failed targets with -k
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 07-Dec-2020  rillig branches: 1.4.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.3 18-Oct-2020  rillig make(1): switch some tests to line-buffered stdout

On Alpine Linux, the output was not in the same order as on NetBSD,
at least since bmake-20200902.

The mixture of block-buffered output from child processes and make
itself was hard to predict anyway. Switching to line-buffered stdout
improves the stability of the tests.
 1.2 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.8.1 02-Aug-2025  perseant Sync with HEAD
 1.6 07-Dec-2020  rillig make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.5 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.4 18-Oct-2020  rillig make(1): switch some tests to line-buffered stdout

On Alpine Linux, the output was not in the same order as on NetBSD,
at least since bmake-20200902.

The mixture of block-buffered output from child processes and make
itself was hard to predict anyway. Switching to line-buffered stdout
improves the stability of the tests.
 1.3 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 01-Sep-2020  rillig make(1): add test for the -m option, the special .../ path
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 30-Apr-2024  sjg make: ensure '.include <makefile>' respects MAKESYSPATH

Since Dir_FindFile is used by '.include' and its variants,
and will first search .CURDIR unless the give path starts with
".DOTLAST".

Update unit-tests/opt-m-include-dir to test this.
 1.4 01-Sep-2020  rillig make(1): add test for the -m option, the special .../ path
 1.3 01-Sep-2020  rillig make(1): add test for -m option with special argument .../
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 09-Dec-2020  rillig make(1): add test for the -n option combined with RunFlags
 1.1 09-Dec-2020  rillig make(1): add test for the -n option combined with RunFlags
 1.1 30-Jan-2021  rillig make(1): add test for combining the options -j, -n, -t

This is a preparation for refactoring the complicated condition in
JobStart.
 1.1 30-Jan-2021  rillig make(1): add test for combining the options -j, -n, -t

This is a preparation for refactoring the complicated condition in
JobStart.
 1.2 19-Aug-2020  rillig make(1): add test for the -n option
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.3 19-Aug-2020  rillig make(1): add test for the -n option
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 17-Aug-2022  rillig make: fix exit status for '-q' (since 1994)
 1.3 17-Aug-2022  rillig tests/make: demonstrate wrong exit status for '-q' (since 1994)

Reported by Jeroen Ruigrok van der Werven via private mail.
 1.2 19-Aug-2020  rillig make(1): add test for the -q option
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7 18-Aug-2022  rillig tests/make: fix test for option '-q' in ATF mode

When running 'make test' in usr.bin/make, MAKE is set to '$PWD/make',
and when that file is used as a dependency, everything works as
expected.

When running the tests via ATF, MAKE is set to simply 'make', based on
argv[0]. Using 'make' as a dependency searches in the current directory
but not in /usr/bin, so the file is not found, which makes the
"up-to-date" target out of date.

Switch the dependeny from ${MAKE} to ${MAKEFILE}, as that file does not
involve any $PATH magic and is also guaranteed to be older than the
'up-to-date' file that is created while running the test.
 1.6 17-Aug-2022  rillig make: fix exit status for '-q' (since 1994)
 1.5 17-Aug-2022  rillig tests/make: demonstrate wrong exit status for '-q' (since 1994)

Reported by Jeroen Ruigrok van der Werven via private mail.
 1.4 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.3 19-Aug-2020  rillig make(1): add test for the -q option
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 14-Nov-2020  rillig make(1): add test for the -t option in jobs mode
 1.3 18-May-2025  rillig make: rename variables, remove now-redundant comments
 1.2 30-Jan-2021  rillig branches: 1.2.8;
make(1): explain test opt-touch-jobs
 1.1 14-Nov-2020  rillig make(1): add test for the -t option in jobs mode
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.3 14-Nov-2020  rillig make(1): add test for touching a .MAKE target
 1.2 14-Nov-2020  rillig make(1): add test for the command line option -t
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 14-Nov-2020  rillig make(1): add test for touching a .MAKE target
 1.3 14-Nov-2020  rillig make(1): add test for the command line option -t
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 09-May-2025  rillig make: replace bitset in trace output with descriptive node attributes
 1.3 09-May-2025  rillig tests/make: add more details to trace output file
 1.2 03-Dec-2021  rillig branches: 1.2.4;
tests/make: test option '-T' for tracing job events
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2.4.1 02-Aug-2025  perseant Sync with HEAD
 1.6 09-May-2025  rillig tests/make: add more details to trace output file
 1.5 06-Dec-2021  rillig branches: 1.5.4;
tests/make: clean up after testing the option '-T'
 1.4 04-Dec-2021  rillig tests/make: fix test for option '-T'

When run via ATF, the test makefile is not in the current directory.
 1.3 03-Dec-2021  rillig tests/make: test option '-T' for tracing job events
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.4.1 02-Aug-2025  perseant Sync with HEAD
 1.2 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.3 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.3 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 23-Dec-2021  rillig tests/make: explain the current behavior of the option '--version'
 1.2 08-May-2022  rillig tests/make: add test for option '-X', clean up comments
 1.1 23-Dec-2021  rillig tests/make: explain the current behavior of the option '--version'
 1.7 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.6 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.5 01-Jun-2023  rillig branches: 1.5.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 27-Jan-2021  rillig make(1): fix irrelevant message in -W mode
 1.3 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.2 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 27-Jan-2021  rillig make(1): fix irrelevant message in -W mode
 1.4 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.3 23-Aug-2020  rillig make(1): add tests for the -i -k -v -V -W options
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 22-Jan-2022  rillig tests/make: add a few more tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 27-Jan-2022  sjg Do not allow /usr/obj to cause failure.
 1.3 22-Jan-2022  rillig tests/make: add a few more tests
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 08-May-2022  rillig tests/make: add test for option '-X', clean up comments
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 08-May-2022  rillig tests/make: add test for option '-X', clean up comments
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.8 07-Dec-2020  rillig branches: 1.8.8;
make(1): fix wrong exit status for multiple failed main targets
 1.7 18-Nov-2020  sjg Always use -r -f /dev/null when not intending to read a makefile
 1.6 15-Nov-2020  rillig make(1): add test for passing MAKEFLAGS to sub-makes
 1.5 15-Nov-2020  sjg Avoid reading unexpected makefiles
 1.4 14-Nov-2020  rillig make(1): document the -S option

This option has been available at least since 1993-03-21, and for the
same time it has been undocumented.
 1.3 14-Nov-2020  rillig make(1): fix trailing whitespace in usage (since 2009-08-27)
 1.2 14-Nov-2020  rillig make(1): add tests for edge cases in parsing the command line
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8.8.1 02-Aug-2025  perseant Sync with HEAD
 1.7 25-Feb-2023  rillig make: rename function for parsing command line options

No binary change.
 1.6 18-Nov-2020  sjg Always use -r -f /dev/null when not intending to read a makefile
 1.5 15-Nov-2020  rillig make(1): add test for passing MAKEFLAGS to sub-makes
 1.4 15-Nov-2020  sjg Avoid reading unexpected makefiles
 1.3 14-Nov-2020  rillig make(1): add tests for edge cases in parsing the command line
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 09-Nov-2012  sjg branches: 1.1.2; 1.1.4;
Add a unit-test for .ORDER
 1.1.4.2 16-Jan-2013  yamt sync with (a bit old) head
 1.1.4.1 09-Nov-2012  yamt file order was added on branch yamt-pagecache on 2013-01-16 05:34:06 +0000
 1.1.2.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.1.2.1 09-Nov-2012  tls file order was added on branch tls-maxphys on 2012-11-20 03:02:58 +0000
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.7 18-Feb-2023  rillig make: fix parsing of unevaluated subexpressions with unbalanced '{}'

Since var.c 1.323 from 2020-07-26, modifiers containing unbalanced
braces or parentheses were parsed differently, depending on whether they
were relevant or not.

For example, the expression '${VAR:...}' is enclosed with braces. When
this expression has a modifier ':S,},}},g' that would double each '}' in
that expression, the parser got confused:

If the expression was relevant, the modifier was parsed as usual, taking
into account that the 3 '}' in the modifier are ordinary characters.

If the expression was irrelevant, the parser only counted the '{' and
the '}', without taking into account that a '}' might be escaped by a
'\' or be an ordinary character. Parsing therefore stopped at the first
'}', assuming it would finish the expression '${VAR:S,}'.

This parsing mode of only counting balanced '{' and '}' makes sense for
the modifier ':@var@...@', which expands each word of the expression
using the template from the '...'. These templates tend to be simple
enough that counting the '{' and '}' suffices.
 1.6 14-Feb-2023  rillig make: remove redundant type VarParseResult

No functional change.
 1.5 25-Sep-2022  rillig tests/make: document how variable evaluation needs to be tested

It's about 100_000 combinations to cover the basic edge cases.
 1.4 23-Aug-2022  rillig make: revert parsing of modifier parts (since 2022-08-08)

The modifier ':@var@body@' parses the body in parse-only mode and later
uses Var_Subst on it, in which each literal '$' must be written as '$$'.

Trying to parse the loop body using Var_Parse treated the text
'$${var:-0}' as a single '$' followed by the expression '${var:-0}',
wrongly complaining about the 'Unknown modifier "-0"'.

Found by sjg.
 1.3 08-Aug-2022  rillig make: fix parsing of modifiers containing unbalanced subexpressions
 1.2 06-Aug-2022  rillig tests/make: demonstrate bug in parsing of modifier parts

In the modifier ':S,from,to,', parsing the two parts 'from' and 'to' of
the modifier differs depending on whether the expression is actually
evaluated or merely parsed. This not only applies to the ':S' modifier,
but also to ':C', ':@var@body@', ':!cmd!', ':[...]', ':?:', '::=' and
':from=to'.
 1.1 04-Oct-2020  rillig make(1): add tests for parsing assignments, especially :sh

Luckily nobody uses the :sh variable assignment modifier since its
syntactical variant != is simpler.
 1.10 02-Jun-2024  rillig make: sync VarEvalMode constant names with their debug log names
 1.9 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.8 18-Feb-2023  rillig make: fix parsing of unevaluated subexpressions with unbalanced '{}'

Since var.c 1.323 from 2020-07-26, modifiers containing unbalanced
braces or parentheses were parsed differently, depending on whether they
were relevant or not.

For example, the expression '${VAR:...}' is enclosed with braces. When
this expression has a modifier ':S,},}},g' that would double each '}' in
that expression, the parser got confused:

If the expression was relevant, the modifier was parsed as usual, taking
into account that the 3 '}' in the modifier are ordinary characters.

If the expression was irrelevant, the parser only counted the '{' and
the '}', without taking into account that a '}' might be escaped by a
'\' or be an ordinary character. Parsing therefore stopped at the first
'}', assuming it would finish the expression '${VAR:S,}'.

This parsing mode of only counting balanced '{' and '}' makes sense for
the modifier ':@var@...@', which expands each word of the expression
using the template from the '...'. These templates tend to be simple
enough that counting the '{' and '}' suffices.
 1.7 14-Feb-2023  rillig make: remove redundant type VarParseResult

No functional change.
 1.6 25-Sep-2022  rillig tests/make: document how variable evaluation needs to be tested

It's about 100_000 combinations to cover the basic edge cases.
 1.5 23-Aug-2022  rillig make: revert parsing of modifier parts (since 2022-08-08)

The modifier ':@var@body@' parses the body in parse-only mode and later
uses Var_Subst on it, in which each literal '$' must be written as '$$'.

Trying to parse the loop body using Var_Parse treated the text
'$${var:-0}' as a single '$' followed by the expression '${var:-0}',
wrongly complaining about the 'Unknown modifier "-0"'.

Found by sjg.
 1.4 08-Aug-2022  rillig tests/make: document history of bug in parsing unbalanced expressions

The bug was introduced in var.c 1.323, which merged two flags that
sounded as if they had been exact opposites: VAR_NOSUBST (later named
VARE_NOSUBST) and VARE_WANTRES.

Before that commit, the branch where make only counted braces instead of
properly parsing the nested expression was only taken in the modifiers
':@var@body@' and '::=', but not in ':S' and ':C'.

After merging the two flags, the modifier parts of ':S' and ':C' had to
be balanced as well, otherwise parsing would fail in cases where the
expression was only parsed, not evaluated.
 1.3 08-Aug-2022  rillig make: fix parsing of modifiers containing unbalanced subexpressions
 1.2 06-Aug-2022  rillig tests/make: demonstrate bug in parsing of modifier parts

In the modifier ':S,from,to,', parsing the two parts 'from' and 'to' of
the modifier differs depending on whether the expression is actually
evaluated or merely parsed. This not only applies to the ':S' modifier,
but also to ':C', ':@var@body@', ':!cmd!', ':[...]', ':?:', '::=' and
':from=to'.
 1.1 04-Oct-2020  rillig make(1): add tests for parsing assignments, especially :sh

Luckily nobody uses the :sh variable assignment modifier since its
syntactical variant != is simpler.
 1.9 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.6 19-Aug-2023  rillig branches: 1.6.2;
make: show realistic invalid line in error message

Previously, the error message 'Invalid line' showed only the expanded
line, which might or might not show the actual problem. To be more
helpful, add the unexpanded line to the error message in case they
differ.

Remove the special handling of invalid lines that result from merge
conflicts. RCS is not commonly used anymore, and mentioning CVS was too
specific. By echoing the whole line, the patterns '<<<<<<' and '>>>>>>'
are clear enough to hint at the problem.
 1.5 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.4 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 24-Jul-2022  rillig make: fix out-of-bounds read when parsing an invalid line

Reported by Robert Morris in https://bugs.freebsd.org/265119.

Since 2021-12-14.
 1.2 22-Jan-2022  rillig tests/make: add a few more tests
 1.1 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.7 19-Aug-2023  rillig branches: 1.7.2;
make: show realistic invalid line in error message

Previously, the error message 'Invalid line' showed only the expanded
line, which might or might not show the actual problem. To be more
helpful, add the unexpanded line to the error message in case they
differ.

Remove the special handling of invalid lines that result from merge
conflicts. RCS is not commonly used anymore, and mentioning CVS was too
specific. By echoing the whole line, the patterns '<<<<<<' and '>>>>>>'
are clear enough to hint at the problem.
 1.6 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 28-Apr-2023  rillig tests/make: add tests for target-local variables

While here, move a test from var-scope-local.mk to parse.mk since that
test is not related to variables.
 1.3 24-Jul-2022  rillig make: fix out-of-bounds read when parsing an invalid line

Reported by Robert Morris in https://bugs.freebsd.org/265119.

Since 2021-12-14.
 1.2 22-Jan-2022  rillig tests/make: add a few more tests
 1.1 13-Dec-2021  rillig tests/make: extend tests for parsing makefiles
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 29-Sep-2011  sjg Make sure .PHONY targets get .TARGET set.
This wasn't happening when a dependency of .END.
Set .PREFIX too and add a unit-test.

PR: 43534
 1.3 07-Aug-2020  rillig make(1): enable test phony-end

This at least documents the actual behavior. Not sure what the expected
behavior is and why.
 1.2 23-Aug-2014  christos fix output based on new sources
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 07-May-2004  sjg branches: 1.1.2;
Remove use of sh -e when running in compat mode.
Its not posix compliant and serves very little purpose.
With this change compat and jobs modes are consistent wrt how
they treat each line of a script.

Add support for the '+' command line prefix as required by posix.
Lines prefixed with '+' are executed even when -n is given.
[Actually posix says they should also be done for -q and -t]

PR:
Reviewed by: jmc
 1.1.2.2 10-May-2004  tron Pull up revision 1.1 (requested by sjg in ticket #282):
Remove use of sh -e when running in compat mode.
Its not posix compliant and serves very little purpose.
With this change compat and jobs modes are consistent wrt how
they treat each line of a script.
Add support for the '+' command line prefix as required by posix.
Lines prefixed with '+' are executed even when -n is given.
[Actually posix says they should also be done for -q and -t]
PR:
Reviewed by: jmc
 1.1.2.1 07-May-2004  tron file posix was added on branch netbsd-2-0 on 2004-05-10 15:52:24 +0000
 1.1 13-Apr-2025  rillig branches: 1.1.4;
tests/make: add tests for POSIX mode
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 13-Apr-2025  perseant file posix-execution.exp was added on branch perseant-exfatfs on 2025-08-02 05:58:36 +0000
 1.1 13-Apr-2025  rillig branches: 1.1.4;
tests/make: add tests for POSIX mode
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 13-Apr-2025  perseant file posix-execution.mk was added on branch perseant-exfatfs on 2025-08-02 05:58:36 +0000
 1.2 13-Apr-2025  rillig branches: 1.2.4;
make: after entering POSIX mode, don't leave it again
 1.1 13-Apr-2025  rillig tests/make: add tests for POSIX mode
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 13-Apr-2025  perseant file posix-expansion.exp was added on branch perseant-exfatfs on 2025-08-02 05:58:36 +0000
 1.2 13-Apr-2025  rillig branches: 1.2.4;
make: after entering POSIX mode, don't leave it again
 1.1 13-Apr-2025  rillig tests/make: add tests for POSIX mode
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 13-Apr-2025  perseant file posix-expansion.mk was added on branch perseant-exfatfs on 2025-08-02 05:58:36 +0000
 1.1 13-Apr-2025  rillig branches: 1.1.4;
tests/make: add tests for POSIX mode
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 13-Apr-2025  perseant file posix-varassign.exp was added on branch perseant-exfatfs on 2025-08-02 05:58:37 +0000
 1.1 13-Apr-2025  rillig branches: 1.1.4;
tests/make: add tests for POSIX mode
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 13-Apr-2025  perseant file posix-varassign.mk was added on branch perseant-exfatfs on 2025-08-02 05:58:37 +0000
 1.4 13-Apr-2025  rillig tests/make: add tests for POSIX mode
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Dec-2020  rillig branches: 1.2.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.5 13-Apr-2025  rillig tests/make: duplicate ".POSIX:" lines don't hurt anymore

Fixed in parse.c 1.743 from a few minutes ago.
 1.4 13-Apr-2025  rillig tests/make: add tests for POSIX mode
 1.3 23-Jan-2022  rillig branches: 1.3.4;
tests/make: run nested makes with -r to reduce side effects
 1.2 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3.4.1 02-Aug-2025  perseant Sync with HEAD
 1.4 30-Aug-2014  sjg Replace use of $() with ${}
$() means something special to the shell, so ${} reduces confusion
and is used almost exclusively in the rest of the makefiles.

Discussed with: christos
 1.3 29-Aug-2014  sjg posix1.mk and suffixes.mk need to cleanup in order to achieve
repeatable results.
posix1.mk's lib.a target still looks dubious.
 1.2 23-Aug-2014  christos fix output based on new sources
 1.1 23-Aug-2014  christos Convert test in PR/49085
 1.6 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.5 27-Sep-2020  rillig make(1): normalize whitespace in source code

There is no more space tab. Either only tabs or only spaces or tabs
followed by spaces, but not spaces followed by tabs.
 1.4 10-Aug-2020  rillig make(1): clean up temporary files after posix1.mk test
 1.3 30-Aug-2014  sjg Replace use of $() with ${}
$() means something special to the shell, so ${} reduces confusion
and is used almost exclusively in the rest of the makefiles.

Discussed with: christos
 1.2 29-Aug-2014  sjg posix1.mk and suffixes.mk need to cleanup in order to achieve
repeatable results.
posix1.mk's lib.a target still looks dubious.
 1.1 23-Aug-2014  christos Convert test in PR/49085
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 31-Mar-2008  sjg If the name passed to Var_Exists contains '$' run it through Var_Subst.
 1.2 07-Dec-2020  rillig make(1): add tests and tutorial for the ?= assignment operator
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.4 07-Dec-2020  rillig make(1): add tests and tutorial for the ?= assignment operator
 1.3 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.2 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 19-Oct-2023  rillig branches: 1.5.2;
tests/make: clean up, explain and reorganize several tests
 1.4 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.2 06-Aug-2020  sjg Update test result
 1.1 06-Aug-2020  rillig make(1): add test for unintended "recursive variable" in -dL mode
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 02-Jun-2024  rillig make: sync VarEvalMode constant names with their debug log names
 1.7 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 15-Mar-2021  rillig make: replace enum bit-field with struct bit-field for VarEvalFlags

This makes the code easier to read, especially in var.c. It also makes
debugging sessions easier since some debuggers don't show enum
bit-fields symbolically as soon as more than one bit is set.

The code outside var.c is basically unchanged, except that instead of
passing the individual flags, there are 4 predefined evaluation modes.
These suffice for all practical use cases. Only in the implementation
deep inside var.c, the value of the flags keepDollar and keepUndef
differs.

There is no way of passing the struct to EnumFlags_ToString, which means
the ToString function has to be spelled out explicitly. This allows for
fine-tuning the representation in the debug log, to reduce the amount of
uppercae letters.

No functional change.
 1.4 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.3 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.2 06-Aug-2020  rillig make(1): add rationale and expected behavior to "recursive" test
 1.1 06-Aug-2020  rillig make(1): add test for unintended "recursive variable" in -dL mode
 1.5 07-Dec-2020  rillig make(1): normalize output of test sh-dots for non-native mode
 1.4 25-Oct-2020  rillig make(1): add tests for generating the ... command indirectly
 1.3 18-Oct-2020  rillig make(1): switch some tests to line-buffered stdout

On Alpine Linux, the output was not in the same order as on NetBSD,
at least since bmake-20200902.

The mixture of block-buffered output from child processes and make
itself was hard to predict anyway. Switching to line-buffered stdout
improves the stability of the tests.
 1.2 29-Aug-2020  rillig make(1): fix sh-dots test

The exact output depends on the shell. Some shells prefix the error
message with their name, some don't.
 1.1 22-Aug-2020  rillig make(1): add test for the special "..." in shell commands
 1.4 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.3 25-Oct-2020  rillig make(1): add tests for generating the ... command indirectly
 1.2 18-Oct-2020  rillig make(1): switch some tests to line-buffered stdout

On Alpine Linux, the output was not in the same order as on NetBSD,
at least since bmake-20200902.

The mixture of block-buffered output from child processes and make
itself was hard to predict anyway. Switching to line-buffered stdout
improves the stability of the tests.
 1.1 22-Aug-2020  rillig make(1): add test for the special "..." in shell commands
 1.8 13-Jun-2025  rillig tests/make: fix race condition in debug output in parallel mode

Discovered in ATF run on evbearmv7hf.
 1.7 09-May-2025  rillig make: unify debug messages for parallel mode

Always print the process status in hex, with a leading "0x", to avoid
confusion for status 127f, which looks suspiciously decimal.

Prefix all process IDs with "pid", to be able to filter them easily.

Omit trailing whitespace when printing a command.
 1.6 09-May-2025  rillig make: replace magic numbers in job debug log with descriptive names
 1.5 03-May-2025  rillig make: use uniform debug log messages for the token pool
 1.4 02-May-2025  rillig make: in the debug log, replace magic numbers with identifiers
 1.3 22-Apr-2025  rillig make: group the code for handling the job token pool
 1.2 13-Dec-2020  sjg branches: 1.2.8;
Prune job debug output that may appear out of order.

A race between child and parent means that we cannot
guarantee whether all child output is seen before we call
JobClosePipes, thus intervening debug output can appear
before or after the last child output.
 1.1 12-Dec-2020  rillig make(1): add test for a shell with error control

None of the predefined shells has error control, and the corresponding
code had not been covered by the existing unit tests.
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 12-Dec-2020  rillig make(1): add test for a shell with error control

None of the predefined shells has error control, and the corresponding
code had not been covered by the existing unit tests.
 1.4 12-Feb-2022  rillig make: fix echoing of command with '-' in silent target in jobs mode

Since job.c 1.83 from 2003-12-20, the command had been echoed even if
the target had the attribute '.SILENT'.

In sh-flags.exp, each removed 'echo' command is below a target name
matching the pattern 'opt-?j????-tgt-??s-cmd-?i?', which means that the
target was marked as silent, either through a global '.SILENT'
declaration or the command line option '-s' or the attribute '.SILENT'
on the target.

Reported by Alan Barrett in PR#45356.
 1.3 12-Dec-2020  rillig make(1): reduce number of test cases in sh-flags.mk

The field job->echo is initialized in JobStart (and in JobOpenTmpFile).
After that, it is not modified anymore. Therefore it is not necessary
to run these test cases redundantly.

The field job->ignerr, on the other hand, is modified later on. For
these cases, the many remaining test cases are still needed.
 1.2 10-Dec-2020  rillig make(1): fix test for command flags

The "false" is supposed to be run not only if the command has the '-'
flag, but also if the target is marked as .IGNORE or if the command line
option -i is given.

After the failed command, the remaining commands are skipped, therefore
the final echo for the empty line had to be moved up, at the beginning
of the target.
 1.1 10-Dec-2020  rillig make(1): test all combinations of switches for running commands

The code in JobPrintSpecials is rather complicated and contains
surprising interaction between some of the switches.

To see the exact effects of the switches, record the current state and
its output, to prevent accidental breakage during the upcoming
refactorings.
 1.4 12-Dec-2020  rillig make(1): reduce number of test cases in sh-flags.mk

The field job->echo is initialized in JobStart (and in JobOpenTmpFile).
After that, it is not modified anymore. Therefore it is not necessary
to run these test cases redundantly.

The field job->ignerr, on the other hand, is modified later on. For
these cases, the many remaining test cases are still needed.
 1.3 12-Dec-2020  rillig make(1): demonstrate that -s and .SILENT have the same effect
 1.2 10-Dec-2020  rillig make(1): fix test for command flags

The "false" is supposed to be run not only if the command has the '-'
flag, but also if the target is marked as .IGNORE or if the command line
option -i is given.

After the failed command, the remaining commands are skipped, therefore
the final echo for the empty line had to be moved up, at the beginning
of the target.
 1.1 10-Dec-2020  rillig make(1): test all combinations of switches for running commands

The code in JobPrintSpecials is rather complicated and contains
surprising interaction between some of the switches.

To see the exact effects of the switches, record the current state and
its output, to prevent accidental breakage during the upcoming
refactorings.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 11-Dec-2020  rillig branches: 1.2.8;
make(1): add tests for comments and non-comments in jobs mode
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.4 16-Apr-2021  rillig make: use distinct wording for writing to the shell commands file

The word 'write' now means to write to the file that holds the shell
commands to be run later.

The word 'print' is now used exclusively for handling the output of the
child commands and printing them to make's stdout.

No functional change.
 1.3 11-Dec-2020  rillig make(1): add tests for comments and non-comments in jobs mode
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 19-Jan-2023  rillig tests/make: add tests for whitespace in leading '@+-'
 1.3 09-Nov-2020  rillig make(1): add test for repeating the leading '@' in shell commands
 1.2 22-Aug-2020  rillig make(1): add test for suppressing the output of the command using @
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 19-Jan-2023  rillig tests/make: add tests for whitespace in leading '@+-'
 1.5 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.4 09-Nov-2020  rillig make(1): add test for repeating the leading '@' in shell commands
 1.3 22-Aug-2020  rillig make(1): add test for suppressing the output of the command using @
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 26-Dec-2023  sjg make: fix order of output in compat mode

Ensure that make's output is correctly ordered with the output of the
target's commands, even when the output does not go to a terminal.

Reviewed by: rillig
 1.2 19-Jan-2023  rillig tests/make: add tests for whitespace in leading '@+-'
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 19-Jan-2023  rillig tests/make: add tests for whitespace in leading '@+-'
 1.3 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 19-Jan-2023  rillig tests/make: add tests for whitespace in leading '@+-'
 1.2 23-Aug-2020  rillig make(1): add test for + commands with the -n command line option
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 19-Jan-2023  rillig tests/make: add tests for whitespace in leading '@+-'
 1.4 09-Nov-2020  rillig make(1): in tests, move command line arguments into the test proper
 1.3 23-Aug-2020  rillig make(1): add test for + commands with the -n command line option
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 07-Dec-2020  rillig make(1): normalize output of test sh-dots for non-native mode
 1.3 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 03-Oct-2020  rillig make(1): demonstrate naive output filtering with csh in parallel mode
 1.4 03-Oct-2020  rillig make(1): fix shell definition for csh

The bug has been there since at least 1993-03-21. This is strong
evidence that nobody has ever used the csh in parallel mode.
 1.3 03-Oct-2020  rillig make(1): demonstrate wrong output when using csh in parallel mode
 1.2 03-Oct-2020  rillig make(1): refine test for printing commands using csh
 1.1 03-Oct-2020  rillig make(1): add tests for the various supported shells
 1.10 05-Jun-2025  rillig make: remove empty line from diagnostic, add tests for output handling

The warning for the invalid internal option "-J" does not need a
trailing newline, as that is provided by Parse_Error already.

Having this newline in the output demonstrated a previously unknown bug
in handling the output of child commands in parallel mode. There, empty
lines are randomly discarded, depending on the chunks in which the
output from the child process is copied to make's stdout. See
job-output.mk for a demonstration.

The test for the Korn shell did not run the Korn shell in error handling
mode, as the error handling mode only affects the parallel mode but the
test didn't switch to that mode.

After fixing the shell-ksh.mk test, the single '"' in the output looked
suspicious, and indeed, the shell-csh.mk test had the same problem of
filtering more characters from the output than intended.
 1.9 25-May-2024  rillig branches: 1.9.2;
make: minimize local variables around a vfork call

Passing all relevant values as arguments allows to remove the 'volatile'
qualifiers.
 1.8 04-Apr-2021  rillig make: rename ambiguous functions

These two functions have counterparts that include the word 'Do' in
their name, which is confusing.

No functional change.
 1.7 13-Dec-2020  sjg Avoid noise when csh does not exist
 1.6 10-Dec-2020  rillig make(1): rename commandShell to shell

The word 'command' was not necessary for understanding the variable.
 1.5 19-Oct-2020  rillig make(1): fix test shell-csh in case no csh is available
 1.4 03-Oct-2020  rillig make(1): demonstrate naive output filtering with csh in parallel mode
 1.3 03-Oct-2020  rillig make(1): demonstrate wrong output when using csh in parallel mode
 1.2 03-Oct-2020  rillig make(1): refine test for printing commands using csh
 1.1 03-Oct-2020  rillig make(1): add tests for the various supported shells
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 03-Oct-2020  rillig make(1): add tests for the various supported shells
 1.1 03-Oct-2020  rillig make(1): add tests for the various supported shells
 1.2 05-Jun-2025  rillig make: remove empty line from diagnostic, add tests for output handling

The warning for the invalid internal option "-J" does not need a
trailing newline, as that is provided by Parse_Error already.

Having this newline in the output demonstrated a previously unknown bug
in handling the output of child commands in parallel mode. There, empty
lines are randomly discarded, depending on the chunks in which the
output from the child process is copied to make's stdout. See
job-output.mk for a demonstration.

The test for the Korn shell did not run the Korn shell in error handling
mode, as the error handling mode only affects the parallel mode but the
test didn't switch to that mode.

After fixing the shell-ksh.mk test, the single '"' in the output looked
suspicious, and indeed, the shell-csh.mk test had the same problem of
filtering more characters from the output than intended.
 1.1 03-Oct-2020  rillig branches: 1.1.8;
make(1): add tests for the various supported shells
 1.1.8.1 02-Aug-2025  perseant Sync with HEAD
 1.2 05-Jun-2025  rillig make: remove empty line from diagnostic, add tests for output handling

The warning for the invalid internal option "-J" does not need a
trailing newline, as that is provided by Parse_Error already.

Having this newline in the output demonstrated a previously unknown bug
in handling the output of child commands in parallel mode. There, empty
lines are randomly discarded, depending on the chunks in which the
output from the child process is copied to make's stdout. See
job-output.mk for a demonstration.

The test for the Korn shell did not run the Korn shell in error handling
mode, as the error handling mode only affects the parallel mode but the
test didn't switch to that mode.

After fixing the shell-ksh.mk test, the single '"' in the output looked
suspicious, and indeed, the shell-csh.mk test had the same problem of
filtering more characters from the output than intended.
 1.1 03-Oct-2020  rillig branches: 1.1.8;
make(1): add tests for the various supported shells
 1.1.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 03-Oct-2020  rillig make(1): add tests for the various supported shells
 1.2 24-Dec-2023  sjg Compat_RunCommand call Shell_Init is shellPath is NULL

Since .SHELL is potentially used in compat mode as well,
the man page description should not imply it is only used in jobs mode.

Remove path="sh" from shell-sh unit-test - and it would have detected
this bug.

Reviewed by: rillig
 1.1 03-Oct-2020  rillig make(1): add tests for the various supported shells
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 07-Dec-2020  rillig branches: 1.4.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.3 21-Nov-2020  rillig make(1): add debug logging when adding a suffix to the global list
 1.2 21-Oct-2020  rillig make(1): enable suffix log for test suff-add-later.mk

The log shows that only some of the transformations are actually
defined.
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.4.8.1 02-Aug-2025  perseant Sync with HEAD
 1.2 21-Oct-2020  rillig make(1): enable suffix log for test suff-add-later.mk

The log shows that only some of the transformations are actually
defined.
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Dec-2020  rillig branches: 1.2.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.2 07-Dec-2020  rillig make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Dec-2020  rillig branches: 1.2.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.8 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.7 25-May-2024  rillig branches: 1.7.2;
make: use fewer technical terms in debug message for dependency
 1.6 28-Dec-2021  rillig make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.5 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.4 02-Feb-2021  rillig make: remove overengineered Enum_ValueToString

For printing the status of a GNode, there was already made_name (now
renamed to GNodeMade_Name), which prints user-friendly text instead of
the bare enum constant names.

To do this change confidently, I first had to demonstrate that the
output really affects something other than just the word "UNMADE". There
had not been a test for that case before, and the test immediately
discovered a bug in the -dg2 and -dg3 options. This bug is one of the
oldest in make, dating back to at least 1993.
 1.3 22-Nov-2020  rillig make(1): add more debugging for searching transformation rules
 1.2 21-Nov-2020  rillig make(1): add more debug logging for suffixes

The "Removing suffix" is not covered by the current tests. It would be
best if that code were unreachable at all, since a reference count of -1
doesn't make sense.
 1.1 21-Nov-2020  rillig make(1): add test for incomplete transformation rule
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 22-Nov-2020  rillig make(1): document the type of the .DEFAULT node

It is marked intentionally as a transformation node, even though this
seems counterintuitive at first.
 1.1 21-Nov-2020  rillig make(1): add test for incomplete transformation rule
 1.6 22-Nov-2020  rillig make(1): add more debugging for searching transformation rules
 1.5 21-Nov-2020  rillig make(1): add more debug logging for suffixes

The "Removing suffix" is not covered by the current tests. It would be
best if that code were unreachable at all, since a reference count of -1
doesn't make sense.
 1.4 21-Nov-2020  rillig make(1): add debug logging when adding a suffix to the global list
 1.3 25-Oct-2020  rillig make(1): properly terminate debug output with newline

Without this, NetBSD's sed adds the missing newline at the end of the
file, while other sed implementations don't do that.
 1.2 24-Oct-2020  rillig make(1): extend test suff-lookup.mk

This test ensures that FindSuffByName behaves correctly.

In order to convert some char pointers to const char pointers, there
needs to be FindSuffByNameLen, and to make sure that this function
actually uses the given length, this test has the suffixes ".sho" and
".short". Without the proper string comparison in FindSuffByNameLen,
the suffix ".short" might be found when searching for ".sho".
 1.1 24-Oct-2020  rillig make(1): add test for looking up suffixes
 1.2 24-Oct-2020  rillig make(1): extend test suff-lookup.mk

This test ensures that FindSuffByName behaves correctly.

In order to convert some char pointers to const char pointers, there
needs to be FindSuffByNameLen, and to make sure that this function
actually uses the given length, this test has the suffixes ".sho" and
".short". Without the proper string comparison in FindSuffByNameLen,
the suffix ".short" might be found when searching for ".sho".
 1.1 24-Oct-2020  rillig make(1): add test for looking up suffixes
 1.15 07-May-2025  rillig make: add end marker for -dg1, -dg2 and -dg3 debug log

The marker helps distinguish the output from sub-makes from the output
of the primary make.
 1.14 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.13 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.12 25-May-2024  rillig branches: 1.12.2;
make: use fewer technical terms in debug message for dependency
 1.11 07-May-2024  sjg make: all command line overrides go in .MAKEOVERRIDES

Not all variables that start with '.' are internals,
and unless they are explicitly flagged as internal should go
into .MAKEOVERRIDES

Update varname-dot-makeoverrides to check this.

Also avoid using SCOPE_CMDLINE when ReadOnly will do.
 1.10 09-Sep-2023  sjg Add .MAKE.JOBS.C to indicate wether -jC is supported
 1.9 24-Jan-2023  sjg make: .SYSPATH: to add dirs to sysIncPath

.SYSPATH: with no sources will clear sysIncPath
otherwise sources are added

Reviewed by: rillig
 1.8 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.7 28-Dec-2021  rillig make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.6 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.5 02-Feb-2021  rillig make: remove overengineered Enum_ValueToString

For printing the status of a GNode, there was already made_name (now
renamed to GNodeMade_Name), which prints user-friendly text instead of
the bare enum constant names.

To do this change confidently, I first had to demonstrate that the
output really affects something other than just the word "UNMADE". There
had not been a test for that case before, and the test immediately
discovered a bug in the -dg2 and -dg3 options. This bug is one of the
oldest in make, dating back to at least 1993.
 1.4 07-Dec-2020  rillig make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.3 04-Dec-2020  rillig make(1): use fixed format for debug output of the directory cache

The previous output format had a %-20s conversion specifier. This
produced different output depending on the length of the pathname, which
was too difficult to normalize. By moving the directory name to the
end, it is no longer necessary to fill up any space, and the numbers are
always aligned properly.

As a result, 3 of the unit tests no longer need any special
postprocessing of their output.
 1.2 25-Nov-2020  sjg Add .MAKE.UID and .MAKE.GID
 1.1 22-Nov-2020  rillig make(1): add another unit test for suffix handling
 1.12.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 22-Nov-2020  rillig make(1): add another unit test for suffix handling
 1.1 18-Oct-2020  rillig make(1): add test for turning a target into a transformation
 1.1 18-Oct-2020  rillig make(1): add test for turning a target into a transformation
 1.1 23-Nov-2020  rillig make(1): test that .PHONY targets are not resolved using suffix rules
 1.1 23-Nov-2020  rillig make(1): test that .PHONY targets are not resolved using suffix rules
 1.9 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.8 28-Dec-2021  rillig branches: 1.8.4;
make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.7 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.6 22-Nov-2020  rillig make(1): add more debugging for searching transformation rules
 1.5 21-Nov-2020  rillig make(1): add explanation for test suff-rebuild
 1.4 21-Nov-2020  rillig make(1): add more debug logging for suffix handling

One notable thing is that there is no debug output when adding a
transformation rule like ".c.o", which means that these rules don't end
up in the global allTargets variable.

This may or may not be intentional. It seems not intentional since this
is one of the causes for the suff-rebuild test to behave unexpectedly.
 1.3 21-Nov-2020  rillig make(1): enable debug logging for test suff-rebuild

As long as it is not clear why this test fails, it's better to have the
debug log available, both for reading it and for getting notified if
any behavior in this area changes.
 1.2 21-Nov-2020  rillig make(1): make output of test suff-rebuild more verbose
 1.1 25-Sep-2020  rillig make(1): add test for deleting the suffixes during parsing
 1.8.4.1 02-Aug-2025  perseant Sync with HEAD
 1.6 21-Nov-2020  rillig make(1): add explanation for test suff-rebuild
 1.5 21-Nov-2020  rillig make(1): enable debug logging for test suff-rebuild

As long as it is not clear why this test fails, it's better to have the
debug log available, both for reading it and for getting notified if
any behavior in this area changes.
 1.4 21-Nov-2020  rillig make(1): make output of test suff-rebuild more verbose
 1.3 21-Nov-2020  rillig make(1): rename SuffScanTargets to SuffUpdateTarget

The word "scan" no longer applies to this function since that is done by
SuffUpdateTargets instead.
 1.2 18-Oct-2020  rillig make(1): fix typo in test suff-rebuild.mk
 1.1 25-Sep-2020  rillig make(1): add test for deleting the suffixes during parsing
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Dec-2020  rillig branches: 1.2.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.1 16-Nov-2020  rillig make(1): add test for self-referencing suffix rule

Just to ensure that make doesn't run into an endless loop.
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 16-Nov-2020  rillig make(1): add test for self-referencing suffix rule

Just to ensure that make doesn't run into an endless loop.
 1.9 07-May-2025  rillig make: add end marker for -dg1, -dg2 and -dg3 debug log

The marker helps distinguish the output from sub-makes from the output
of the primary make.
 1.8 07-May-2024  sjg branches: 1.8.2;
make: all command line overrides go in .MAKEOVERRIDES

Not all variables that start with '.' are internals,
and unless they are explicitly flagged as internal should go
into .MAKEOVERRIDES

Update varname-dot-makeoverrides to check this.

Also avoid using SCOPE_CMDLINE when ReadOnly will do.
 1.7 09-Sep-2023  sjg Add .MAKE.JOBS.C to indicate wether -jC is supported
 1.6 24-Jan-2023  sjg make: .SYSPATH: to add dirs to sysIncPath

.SYSPATH: with no sources will clear sysIncPath
otherwise sources are added

Reviewed by: rillig
 1.5 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.4 02-Feb-2021  rillig make: remove overengineered Enum_ValueToString

For printing the status of a GNode, there was already made_name (now
renamed to GNodeMade_Name), which prints user-friendly text instead of
the bare enum constant names.

To do this change confidently, I first had to demonstrate that the
output really affects something other than just the word "UNMADE". There
had not been a test for that case before, and the test immediately
discovered a bug in the -dg2 and -dg3 options. This bug is one of the
oldest in make, dating back to at least 1993.
 1.3 04-Dec-2020  rillig make(1): use fixed format for debug output of the directory cache

The previous output format had a %-20s conversion specifier. This
produced different output depending on the length of the pathname, which
was too difficult to normalize. By moving the directory name to the
end, it is no longer necessary to fill up any space, and the numbers are
always aligned properly.

As a result, 3 of the unit tests no longer need any special
postprocessing of their output.
 1.2 25-Nov-2020  sjg Add .MAKE.UID and .MAKE.GID
 1.1 22-Nov-2020  rillig make(1): add test for debug output from transformation rules
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 22-Nov-2020  rillig make(1): add test for debug output from transformation rules
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 07-Dec-2020  rillig branches: 1.4.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.3 23-Nov-2020  rillig make(1): fix endless loop when resolving circular suffix rules
 1.2 23-Nov-2020  rillig make(1): add debug logging for suffix tests
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.4.8.1 02-Aug-2025  perseant Sync with HEAD
 1.4 23-Nov-2020  rillig make(1): fix endless loop when resolving circular suffix rules
 1.3 23-Nov-2020  rillig make(1): add debug logging for suffix tests
 1.2 22-Nov-2020  rillig make(1): fix confusing command output in test suff-transform-endless
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Dec-2020  rillig branches: 1.2.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.5 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.4 07-Dec-2020  rillig branches: 1.4.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.3 23-Nov-2020  rillig make(1): fix endless loop when resolving circular suffix rules
 1.2 23-Nov-2020  rillig make(1): add debug logging for suffix tests
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.4.8.1 02-Aug-2025  perseant Sync with HEAD
 1.3 23-Nov-2020  rillig make(1): fix endless loop when resolving circular suffix rules
 1.2 23-Nov-2020  rillig make(1): add debug logging for suffix tests
 1.1 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.2 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.1 07-Feb-2022  rillig branches: 1.1.4;
tests/make: demonstrate combination of .USE with transformation rule

Reported in 2003 in PR toolchain/20993. Linking a transformation rule
with .USE or .USEBEFORE node makes the transformation rule fail.
 1.1.4.1 02-Aug-2025  perseant Sync with HEAD
 1.2 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.1 07-Feb-2022  rillig tests/make: demonstrate combination of .USE with transformation rule

Reported in 2003 in PR toolchain/20993. Linking a transformation rule
with .USE or .USEBEFORE node makes the transformation rule fail.
 1.4 14-Jan-2025  rillig branches: 1.4.4;
make: clarify that undefined expressions are allowed in dependencies
 1.3 14-Jan-2025  rillig make: simplify parsing of dependency lines

The evaluation modes that allow or deny undefined variables have the same
effect in this case, as Var_Subst does not return an error marker.
 1.2 12-Jan-2025  rillig tests/make: fix suffix rule test in ATF mode
 1.1 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.4.4.2 02-Aug-2025  perseant Sync with HEAD
 1.4.4.1 14-Jan-2025  perseant file suff.exp was added on branch perseant-exfatfs on 2025-08-02 05:58:37 +0000
 1.3 14-Jan-2025  rillig branches: 1.3.4;
make: clarify that undefined expressions are allowed in dependencies
 1.2 12-Jan-2025  rillig tests/make: fix suffix rule test in ATF mode
 1.1 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.3.4.2 02-Aug-2025  perseant Sync with HEAD
 1.3.4.1 14-Jan-2025  perseant file suff.mk was added on branch perseant-exfatfs on 2025-08-02 05:58:37 +0000
 1.2 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.1 23-Aug-2014  christos PR/46096: Jarmo Jaakkola: fix many problems with dependencies (PR 49086)

Quite extensive rewrite of the Suff module. Some ripple effects into
Parse and Targ modules too.

Dependency searches in general were made to honor explicit rules so
implicit and explicit sources are no longer applied on targets that
do not invoke a transformation rule.

Archive member dependency search was rewritten. Explicit rules now
work properly and $(.TARGET) is set correctly. POSIX semantics for
lib(member.o) and .s1.a rules are supported.

.SUFFIXES list maintenance was rewritten so that scanning of existing
rules works when suffixes are added and that clearing the suffix list
removes single suffix rules too. Transformation rule nodes are now
mixed with regular nodes so they are available as regular targets too
if needed (especially after the known suffixes are cleared).

The .NULL target was documented in the manual page, especially to
warn against using it when a single suffix rule would work.
A deprecation warning was also added to the manual and make also
warns the user if it encounters .NULL.

Search for suffix rules no longer allows the explicit dependencies
to override the selected transformation rule. A check is made in
the search that the transformation that would be tried does not
already exist in the chain. This prevents getting stuck in an infinite
loop under specific circumstances. Local variables are now set
before node's children are expanded so dynamic sources work in
multi-stage transformations. Make_HandleUse() no longer expands
the added children for transformation nodes, preventing triple
expansion and allowing the Suff module to properly postpone their
expansion until proper values are set for the local variables.

Directory prefix is no longer removed from $(.PREFIX) if the target
is found via directory search.

The last rule defined is now used instead of the first one (POSIX
requirement) in case a rule is defined multiple times. Everything
defined in the first instance is undone, but things added "globally"
are honored. To implement this, each node tracks attribute bits
which have been set by special targets (global) instead of special
sources (local). They also track dependencies that were added by
a rule with commands (local) instead of rule with no commands (global).

New attribute, OP_FROM_SYS_MK is introduced. It is set on all targets
found in system makefiles so that they are not eligible to become
the main target. We cannot just set OP_NOTMAIN because it is one of
the attributes inherited from transformation and .USE rules and would
make any eligible target that uses a built-in inference rule ineligible.

The $(.IMPSRC) local variable now works like in gmake: it is set to
the first prerequisite for explicit rules. For implicit rules it
is still the implied source.

The manual page is improved regarding the fixed features. Test cases
for the fixed problems are added.

Other improvements in the Suff module include:
- better debug messages for transformation rule search (length of
the chain is now visualized by indentation)
- Suff structures are created, destroyed and moved around by a set
of maintenance functions so their reference counts are easier
to track (this also gets rid of a lot of code duplication)
- some unreasonably long functions were split into smaller ones
- many local variables had their names changed to describe their
purpose instead of their type
 1.4 20-Oct-2020  rillig make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail. That's complicated
enough already.

PR bin/49086
 1.3 30-Aug-2014  sjg Replace use of $() with ${}
$() means something special to the shell, so ${} reduces confusion
and is used almost exclusively in the rest of the makefiles.

Discussed with: christos
 1.2 29-Aug-2014  sjg posix1.mk and suffixes.mk need to cleanup in order to achieve
repeatable results.
posix1.mk's lib.a target still looks dubious.
 1.1 23-Aug-2014  christos PR/46096: Jarmo Jaakkola: fix many problems with dependencies (PR 49086)

Quite extensive rewrite of the Suff module. Some ripple effects into
Parse and Targ modules too.

Dependency searches in general were made to honor explicit rules so
implicit and explicit sources are no longer applied on targets that
do not invoke a transformation rule.

Archive member dependency search was rewritten. Explicit rules now
work properly and $(.TARGET) is set correctly. POSIX semantics for
lib(member.o) and .s1.a rules are supported.

.SUFFIXES list maintenance was rewritten so that scanning of existing
rules works when suffixes are added and that clearing the suffix list
removes single suffix rules too. Transformation rule nodes are now
mixed with regular nodes so they are available as regular targets too
if needed (especially after the known suffixes are cleared).

The .NULL target was documented in the manual page, especially to
warn against using it when a single suffix rule would work.
A deprecation warning was also added to the manual and make also
warns the user if it encounters .NULL.

Search for suffix rules no longer allows the explicit dependencies
to override the selected transformation rule. A check is made in
the search that the transformation that would be tried does not
already exist in the chain. This prevents getting stuck in an infinite
loop under specific circumstances. Local variables are now set
before node's children are expanded so dynamic sources work in
multi-stage transformations. Make_HandleUse() no longer expands
the added children for transformation nodes, preventing triple
expansion and allowing the Suff module to properly postpone their
expansion until proper values are set for the local variables.

Directory prefix is no longer removed from $(.PREFIX) if the target
is found via directory search.

The last rule defined is now used instead of the first one (POSIX
requirement) in case a rule is defined multiple times. Everything
defined in the first instance is undone, but things added "globally"
are honored. To implement this, each node tracks attribute bits
which have been set by special targets (global) instead of special
sources (local). They also track dependencies that were added by
a rule with commands (local) instead of rule with no commands (global).

New attribute, OP_FROM_SYS_MK is introduced. It is set on all targets
found in system makefiles so that they are not eligible to become
the main target. We cannot just set OP_NOTMAIN because it is one of
the attributes inherited from transformation and .USE rules and would
make any eligible target that uses a built-in inference rule ineligible.

The $(.IMPSRC) local variable now works like in gmake: it is set to
the first prerequisite for explicit rules. For implicit rules it
is still the implied source.

The manual page is improved regarding the fixed features. Test cases
for the fixed problems are added.

Other improvements in the Suff module include:
- better debug messages for transformation rule search (length of
the chain is now visualized by indentation)
- Suff structures are created, destroyed and moved around by a set
of maintenance functions so their reference counts are easier
to track (this also gets rid of a lot of code duplication)
- some unreasonably long functions were split into smaller ones
- many local variables had their names changed to describe their
purpose instead of their type
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 28-Aug-2013  sjg branches: 1.1.4; 1.1.8;
Fix parsing of SUNSHCMD style :sh = assigments.

Submitted by: Will Andrews at freebsd.org
 1.1.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.1 28-Aug-2013  tls file sunshcmd was added on branch tls-maxphys on 2014-08-20 00:05:00 +0000
 1.1.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.4.1 28-Aug-2013  yamt file sunshcmd was added on branch yamt-pagecache on 2014-05-22 11:42:46 +0000
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.2 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 03-Jun-2011  sjg ApplyModifiers: if we parse a variable in the modifier list,
do not consider it a nested modifier set, unless it is followed by
endc, a ':' or end of string.
 1.1 06-Mar-2011  sjg branches: 1.1.2;
Add unit tests to check that exists(some/dir/) works

Also fix handling of sysV substitutions when lhs and variable are empty.

Also that modifiers do not cause errors during conditional tests
when undefined variables should otherwise be ok.
Ie. .if defined(nosuch) && ${nosuch:Mx} != ""
 1.1.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.11 31-Oct-2020  rillig make(1): merge the SysV modifier tests into varmod-sysv
 1.10 23-Aug-2020  rillig make(1): move some of the SysV modifier tests into another file
 1.9 26-Jul-2020  rillig make(1): add test for prefix mismatch in SysV substitution
 1.8 20-Jul-2020  rillig make(1): fix obscure edge case for ${VAR:e$=x}

The characters "$=" do not occur in either src or pkgsrc, therefore this
case is unlikely to occur in practice.
 1.7 20-Jul-2020  rillig make(1): demonstrate obscure edge case in SysV modifier
 1.6 19-Jul-2020  rillig make(1): make ampersand in ${VAR:from=to&} an ordinary character

In SysV substitutions, wildcards are expressed with % instead of &. The
& is not mentioned in the manual page, and having another wildcard for
the whole word would be such an obscure feature that not even pkgsrc uses
it. The easiest way to discover this feature had been to read the source
code of make(1) or to use a fuzzer and accidentally stumble upon this
edge case.
 1.5 19-Jul-2020  rillig make(1): add test for ampersand in SysV substitution modifier
 1.4 03-Jul-2020  rillig make(1): add another test for the SysV :%=% modifier
 1.3 06-May-2020  christos Behave like gmake: empty string does not match % pattern
 1.2 25-Apr-2020  christos - Percent on the rhs is special only if the lhs has one too.
- If the rhs does not have percent, but the lhs has, the result is the rhs
This behavior matches gmake
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.16 31-Oct-2020  rillig make(1): merge the SysV modifier tests into varmod-sysv
 1.15 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.14 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.13 23-Aug-2020  rillig make(1): move some of the SysV modifier tests into another file
 1.12 01-Aug-2020  rillig make(1): reduce the number of string comparisons in ${VAR:%.c=%.o}

There is only a single position in the word where the tail ".c" can
match, since it is implicitly anchored at the end. Therefore there's no
need to do several string comparisons.
 1.11 01-Aug-2020  rillig make(1): fix typo in newly added SysV modifier test case

I should have been more suspicious when all my test cases succeeded at
the first try.
 1.10 01-Aug-2020  rillig make(1): add more tests for the SysV modifier
 1.9 26-Jul-2020  rillig make(1): add test for prefix mismatch in SysV substitution
 1.8 20-Jul-2020  rillig make(1): demonstrate obscure edge case in SysV modifier
 1.7 19-Jul-2020  rillig make(1): make ampersand in ${VAR:from=to&} an ordinary character

In SysV substitutions, wildcards are expressed with % instead of &. The
& is not mentioned in the manual page, and having another wildcard for
the whole word would be such an obscure feature that not even pkgsrc uses
it. The easiest way to discover this feature had been to read the source
code of make(1) or to use a fuzzer and accidentally stumble upon this
edge case.
 1.6 19-Jul-2020  rillig make(1): add test for ampersand in SysV substitution modifier
 1.5 03-Jul-2020  rillig make(1): add another test for the SysV :%=% modifier
 1.4 06-May-2020  christos Behave like gmake: empty string does not match % pattern
 1.3 25-Apr-2020  christos - Percent on the rhs is special only if the lhs has one too.
- If the rhs does not have percent, but the lhs has, the result is the rhs
This behavior matches gmake
 1.2 30-Aug-2014  sjg Replace use of $() with ${}
$() means something special to the shell, so ${} reduces confusion
and is used almost exclusively in the rest of the makefiles.

Discussed with: christos
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 20-Feb-2004  sjg Fix :M so that modifiers in nested variables don't terminate parsing
early. Add a unit-test to verify it works and keeps working.
Re-jig the unit-tests so that all are sub makefiles.
 1.1 09-Jan-2004  sjg Add unit test for ternary modifier
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.2 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.45 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.44 20-Aug-2014  apb Add tests for VAR != command.
 1.43 28-Aug-2013  sjg Fix parsing of SUNSHCMD style :sh = assigments.

Submitted by: Will Andrews at freebsd.org
 1.42 22-Mar-2013  sjg Add unit-test for export-env and gmake export
 1.41 09-Nov-2012  sjg Add a unit-test for .ORDER
 1.40 19-Jun-2012  sjg branches: 1.40.2;
Add unit-tests for .for
 1.39 29-Sep-2011  sjg branches: 1.39.2;
Make sure .PHONY targets get .TARGET set.
This wasn't happening when a dependency of .END.
Set .PREFIX too and add a unit-test.

PR: 43534
 1.38 03-Jun-2011  sjg ApplyModifiers: if we parse a variable in the modifier list,
do not consider it a nested modifier set, unless it is followed by
endc, a ':' or end of string.
 1.37 11-Apr-2011  sjg branches: 1.37.2;
Add a test case for sysV modifier subst
 1.36 07-Apr-2011  joerg Add the :hash modifier to compute a 32bit hash of an variable.
This uses MurmurHash3 to get a reasonable collission-free hash with
small code. The result is endian neutral.
 1.35 06-Mar-2011  sjg Add unit tests to check that exists(some/dir/) works

Also fix handling of sysV substitutions when lhs and variable are empty.

Also that modifiers do not cause errors during conditional tests
when undefined variables should otherwise be ok.
Ie. .if defined(nosuch) && ${nosuch:Mx} != ""
 1.34 23-Apr-2010  sjg PR: 42850
Reviewed by:

Reduced the "expected to exist" dirs in path to just
/ /bin and /tmp
and change the "not expected to exist" dir to something
even less likely.
Add a comment to suggest why.
 1.33 22-Apr-2010  sjg PR: 42850
Reviewed by:

modmisc: since we apply an exists() test to $paths, be conservative
in what we expect.

Run the unit tests with -r -m / so that we do not fail if there
is no sys.mk present.
 1.32 21-Apr-2010  sjg If we do .export (all) and have any variables that involve :sh
we will hit an error (var is recursive) while trying to evaluate that.
Fix, and add a unit test for this.
 1.31 08-Apr-2010  sjg Process .ERROR the same as .BEGIN, .END etc
so that it cannot be the default target.
Add unit-tests for .info - .error, and .ERROR.
 1.30 19-Nov-2009  sjg PR: make.unexport
Reviewed by:
 1.29 07-Oct-2009  sjg The parser used to break dependency lines at ';' without regard
for substitution patterns. This (perhaps coupled with the
new handling of .for variables in ${:U<value>...) caused interesting
results for lines like:

.for file in ${LIST}
for-subst: ${file:S;^;${here}/;g}

add a unit-test to keep an eye on this.
 1.28 07-Sep-2009  sjg PR: 41998

:Ufu\:goo

should expand to fu:goo even when it appears in :M${:Ufu\:goo}
When scanning for :M do not compress \: if we know we have
to call Var_Subst.
 1.27 03-Feb-2009  sjg Update expected results to match recent changes!
 1.26 29-Oct-2008  sjg If Parse_Error is called after curFile is invalid, set it to a dummy
to avoid seg-fault. Also the NULL filename will cause ParseVErrorInternal
to skip trying to report file and line number info.

If CondToken is called outside the context of a .if etc, variables in
the expression being parsed will already be expanded, so allow for
an unqouted number to jump us back into the compare logic.
This allows ${${SomeNumber:U42} > 0:?True:False} to work anywhere.

Job_Finish should process postCommands if it has commands or children.
 1.25 15-May-2008  sjg VAR_CMD context is used by conditionals and other purposes, so
actually set VAR_FROM_CMD when appropriate and only skip setting in
VAR_GLOBAL when that flag is set.
 1.24 15-May-2008  sjg Disable this for now, VAR_CMD is abused for other purposes...
 1.23 14-May-2008  sjg Do not set vars in VAR_GLOBAL context, if they have been set on the
command line.
Add a suitable unit-test.
 1.22 31-Mar-2008  sjg branches: 1.22.2; 1.22.4;
If the name passed to Var_Exists contains '$' run it through Var_Subst.
 1.21 09-Oct-2007  sjg Fix an off-by-one error in handing mal-formed modifiers.
The issue seems to have been present for some time, only showed up
when running unit-tests on SunOS.
Make sure we get an error message, but otherwise behave as before.
 1.20 05-Oct-2007  sjg Add the ability to .export variables to the environment.
 1.19 11-May-2006  sjg branches: 1.19.12;
Remove the modterm case from moderrs, the syntax errors
generated by /bin/sh on other systems are not consistent.
 1.18 11-May-2006  sjg Extract the variable modifier logic to a separate function.
This cuts Var_Parse in half! and allows the modifier logic to
be used recursively - when getting modifiers via variables.

Add new unit-test, to check that certain error cases are handled
correctly.
 1.17 26-Feb-2006  apb Make ".WAIT" apply recursively to all children of nodes on the right
hand side of the .WAIT, except when the recursive interpretation would
cause a cycle in the dependency graph.

Discussed in tech-toolchain. Reviewed by christos, sjg.
 1.16 26-Feb-2006  sjg Using ./bin in the test case, causes problems when 'make test' is
run from 'unit-tests' rather than the parent dir.
 1.15 26-Feb-2006  sjg Update man page and add test case for specifying modifiers via variable.
Also allow said variable to appear anywhere in the modifier list.
 1.14 11-Jul-2005  sjg Expected results were not updated for comment testing.
 1.13 01-Jun-2005  sjg Add :Ox for random ordering, based on patch from
Mike M. Volokhov <mishka@apk.od.ua>
 1.12 07-May-2004  sjg branches: 1.12.2;
Remove use of sh -e when running in compat mode.
Its not posix compliant and serves very little purpose.
With this change compat and jobs modes are consistent wrt how
they treat each line of a script.

Add support for the '+' command line prefix as required by posix.
Lines prefixed with '+' are executed even when -n is given.
[Actually posix says they should also be done for -q and -t]

PR:
Reviewed by: jmc
 1.11 13-Apr-2004  sjg Allow "string" and "${varspec}" on lhs of conditionals.
This makes it possible to use expressions like
${("${LIST:Msomething"}):?present:absent}
it also makes treatment of lhs and rhs more consistent, and
makes CondToken easier to read.

Update unit-test/cond1 to test new features.
 1.10 08-Apr-2004  sjg Revised patch for catching extraneous .else's
We actually need to tack condTop and skipIfLevel.
Bump MAXIF while here.
Enhance the unit-test for conditionals to exercise more code.

PR: 24420
 1.9 08-Apr-2004  sjg Add check for extraneous .else's - based on patch from Arne H. Juul
in PR/24420.
Add a unit-test for conditionals.
Also in the unit-test makefile strip any .CURDIR in output.

PR: 24420
 1.8 20-Feb-2004  sjg branches: 1.8.2;
Fix :M so that modifiers in nested variables don't terminate parsing
early. Add a unit-test to verify it works and keeps working.
Re-jig the unit-tests so that all are sub makefiles.
 1.7 09-Jan-2004  sjg Add unit test for ternary modifier
 1.6 27-Sep-2003  sjg Implement :[] modifier to allow picking a range of words out of a variable.
Also :tW and a W flag to :C and :S to allow treating value as a single word.
Add unit tests for the above, and fix some corner cases.
Based on patches supplied by Alan Barrett <apb@cequrux.com>
 1.5 01-Aug-2003  sjg Avoid \a as a test of invalid separator, since if we make ksh the default
shell, we get different results. \x seems safe.
 1.4 31-Jul-2003  sjg Test behavior of commandline variable assignments.
 1.3 29-Jul-2003  sjg First bug picked up by the unit tests - delim wasn't always initialized.
Avoid putting '\' in test case script lines since shell's like that on
SunOS insist on interpreting them.
 1.2 29-Jul-2003  sjg Use single quotes to protect everything from shell's that might
alter the results.
 1.1 28-Jul-2003  sjg Fix parsing bug for :ts - patch from Alan Barrett <apb@cequrux.com>
Also add simple unit-test jig (regress/usr.bin/make will use it too)
but having it local here makes inclusion in bmake simpler.
 1.8.2.4 10-May-2004  tron Pull up revision 1.12 (requested by sjg in ticket #282):
Remove use of sh -e when running in compat mode.
Its not posix compliant and serves very little purpose.
With this change compat and jobs modes are consistent wrt how
they treat each line of a script.
Add support for the '+' command line prefix as required by posix.
Lines prefixed with '+' are executed even when -n is given.
[Actually posix says they should also be done for -q and -t]
PR:
Reviewed by: jmc
 1.8.2.3 10-May-2004  tron Pull up revision 1.11 (requested by sjg in ticket #282):
Allow "string" and "${varspec}" on lhs of conditionals.
This makes it possible to use expressions like
${("${LIST:Msomething"}):?present:absent}
it also makes treatment of lhs and rhs more consistent, and
makes CondToken easier to read.
Update unit-test/cond1 to test new features.
 1.8.2.2 10-May-2004  tron Pull up revision 1.10 (requested by sjg in ticket #282):
Revised patch for catching extraneous .else's
We actually need to tack condTop and skipIfLevel.
Bump MAXIF while here.
Enhance the unit-test for conditionals to exercise more code.
PR: 24420
 1.8.2.1 10-May-2004  tron Pull up revision 1.9 (requested by sjg in ticket #282):
Add check for extraneous .else's - based on patch from Arne H. Juul
in PR/24420.
Add a unit-test for conditionals.
Also in the unit-test makefile strip any .CURDIR in output.
PR: 24420
 1.12.2.1 24-Jul-2005  tron Pull up revision 1.14 (requested by rpaulo in ticket #608):
Expected results were not updated for comment testing.
 1.19.12.1 06-Nov-2007  matt sync with HEAD
 1.22.4.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.22.2.1 18-May-2008  yamt sync with head.
 1.37.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.39.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.39.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.39.2.1 30-Oct-2012  yamt sync with head
 1.40.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.40.2.2 23-Jun-2013  tls resync from head
 1.40.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 19-Nov-2009  sjg Add .unexport - the exact opposite of .export
and .unexport-env which unexport's all previously .export'd globals
as well as clearing environ[].
Allow's sys.mk near total controll.

Reviewed by: apb
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 19-Nov-2009  sjg Add .unexport - the exact opposite of .export
and .unexport-env which unexport's all previously .export'd globals
as well as clearing environ[].
Allow's sys.mk near total controll.

Reviewed by: apb
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.4 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.3 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.2 27-Jul-2020  rillig make(1): prepare test for .export to show all exported variables

Currently the unit tests don't cover exporting of local variables like
.TARGET or @. To see the effects, all exported variables must be listed
by the tests.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.6 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.5 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.4 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.3 08-Aug-2020  rillig make(1): clean up Var_UnExport

Mark the parameter as constant since it is not modified.

Remove tests for '\n' since these can never succeed.

newenv can never be NULL since neither of bmake_malloc or bmake_realloc
returns NULL.

Improve variable names: vlist was too unexpressive.

Add debug logging since unexporting variables is an uncommon operation
that directly affects the observable environment of the child processes.

Fix CRLF line endings in a few unit tests.
 1.2 27-Jul-2020  rillig make(1): prepare test for .export to show all exported variables

Currently the unit tests don't cover exporting of local variables like
.TARGET or @. To see the effects, all exported variables must be listed
by the tests.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 07-Dec-2020  rillig branches: 1.2.8;
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.1 09-Aug-2020  rillig make(1): add test for .USE combined with inference rule without commands

Discovered by christos.
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.3 07-Dec-2020  rillig make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
 1.2 05-Nov-2020  rillig make(1): add remark for exit status 0 despite error
 1.1 09-Aug-2020  rillig make(1): add test for .USE combined with inference rule without commands

Discovered by christos.
 1.5 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.4 23-Feb-2021  rillig make: document the history of bugs in "cmdline overrides global"

For performance reasons, the implementation of the simple rule "cmdline
overrides global" grew into code that is much more complicated than a
straight-forward implementation. This added complexity made it easy for
bugs to sneak in.
 1.3 23-Feb-2021  rillig make: demonstrate how to undefine variables during evaluation

For a very long time now, I had thought that it would be impossible to
undefine global variables during the evaluation of variable expressions.
This is something that the memory management in Var_Parse relies upon,
see the comment 'the value of the variable must not change'.

After several unsuccessful attempts at referring to an already freed
previous value of a variable, today I discovered how to unset a global
variable while evaluating an expression, which has the same effect. To
demonstrate that this use-after-free can reliably crash make, it would
need a memory allocator with a debug mode that never re-allocates the
same memory block after it has been used once. This is something that
jemalloc cannot do at the moment. Valgrind would be another idea, but
that has not been ported to NetBSD.

Undefining a global variable while evaluating an expression is made
possible by an implementation detail of the modifier ':@'. That
modifier undefines the loop variable, without restoring its previous
value, see ApplyModifier_Loop.

By the very old conventions of ODE Make, these loop variables are named
'.V.' and thus do not conflict with variables from other naming
conventions. In NetBSD and pkgsrc, these loop variables are typically
called 'var', sometimes '_var' with a leading underscore, which also
doesn't conflict with the typical form 'VAR' of variables in the global
namespace. Therefore, in practice these loop variables don't interfere
with other variables.

One case that can practically arise is when an outer variable has a
modifier ':@word@${VAR.${word}}@' and one of the referenced variables
uses the same variable name in the modifier, see varmod-loop.mk 1.10
line 91 for a detailed explanation.

By using the ${:@VAR@@} modifier in a place that is evaluated with
cmdline scope, it is not only possible to undefine global variables, it
is possible to undefine cmdline variables as well. When evaluated in a
specific make target, the expression ${:@\@@@} can even be used to
undefine the variable '.TARGET', which will probably crash make with an
assertion failure.
 1.2 22-Feb-2021  rillig make: add test for cmdline variables overriding global variables
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.5 23-Feb-2021  rillig make: document the history of bugs in "cmdline overrides global"

For performance reasons, the implementation of the simple rule "cmdline
overrides global" grew into code that is much more complicated than a
straight-forward implementation. This added complexity made it easy for
bugs to sneak in.
 1.4 23-Feb-2021  rillig make: demonstrate how to undefine variables during evaluation

For a very long time now, I had thought that it would be impossible to
undefine global variables during the evaluation of variable expressions.
This is something that the memory management in Var_Parse relies upon,
see the comment 'the value of the variable must not change'.

After several unsuccessful attempts at referring to an already freed
previous value of a variable, today I discovered how to unset a global
variable while evaluating an expression, which has the same effect. To
demonstrate that this use-after-free can reliably crash make, it would
need a memory allocator with a debug mode that never re-allocates the
same memory block after it has been used once. This is something that
jemalloc cannot do at the moment. Valgrind would be another idea, but
that has not been ported to NetBSD.

Undefining a global variable while evaluating an expression is made
possible by an implementation detail of the modifier ':@'. That
modifier undefines the loop variable, without restoring its previous
value, see ApplyModifier_Loop.

By the very old conventions of ODE Make, these loop variables are named
'.V.' and thus do not conflict with variables from other naming
conventions. In NetBSD and pkgsrc, these loop variables are typically
called 'var', sometimes '_var' with a leading underscore, which also
doesn't conflict with the typical form 'VAR' of variables in the global
namespace. Therefore, in practice these loop variables don't interfere
with other variables.

One case that can practically arise is when an outer variable has a
modifier ':@word@${VAR.${word}}@' and one of the referenced variables
uses the same variable name in the modifier, see varmod-loop.mk 1.10
line 91 for a detailed explanation.

By using the ${:@VAR@@} modifier in a place that is evaluated with
cmdline scope, it is not only possible to undefine global variables, it
is possible to undefine cmdline variables as well. When evaluated in a
specific make target, the expression ${:@\@@@} can even be used to
undefine the variable '.TARGET', which will probably crash make with an
assertion failure.
 1.3 22-Feb-2021  rillig make: add test for cmdline variables overriding global variables
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.3 23-Jan-2022  rillig tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.3 05-Nov-2020  rillig make(1): add test for legacy local variables @F, @D
 1.2 25-Oct-2020  rillig make(1): add test for setting a variable in a GNode context

This edge case is probably not used widely. The local variables of a
GNode should only ever be the predefined variables.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.5 05-Nov-2020  rillig make(1): add test for legacy local variables @F, @D
 1.4 25-Oct-2020  rillig make(1): add test for setting a variable in a GNode context

This edge case is probably not used widely. The local variables of a
GNode should only ever be the predefined variables.
 1.3 23-Oct-2020  rillig make(1): add test for variable name aliasing
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.34 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.33 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.32 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.31 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.30 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.29 05-Jul-2024  rillig make: in error messages, distinguish parsing from evaluating
 1.28 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.27 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.26 02-Jun-2024  rillig branches: 1.26.2;
make: sync VarEvalMode constant names with their debug log names
 1.25 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.24 14-Apr-2024  rillig make: add debug logging for .if and .for lines in -dp mode

This helps track down in which line a condition is evaluated.
 1.23 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.22 09-May-2023  rillig make: allow ':gmtime' and ':localtime' with dynamic argument

This allows ${%Y:L:gmtime=${mtime}} instead of the indirect
${%Y:L:${:Ugmtime=${mtime}}}.

The direct form also prevents any ':' from the nested expression to be
interpreted as a separator, which doesn't matter for the ':gmtime' and
':localtime' modifiers but will prove useful for other modifiers that
follow the same pattern.
 1.21 18-Feb-2023  rillig make: fix parsing of unevaluated subexpressions with unbalanced '{}'

Since var.c 1.323 from 2020-07-26, modifiers containing unbalanced
braces or parentheses were parsed differently, depending on whether they
were relevant or not.

For example, the expression '${VAR:...}' is enclosed with braces. When
this expression has a modifier ':S,},}},g' that would double each '}' in
that expression, the parser got confused:

If the expression was relevant, the modifier was parsed as usual, taking
into account that the 3 '}' in the modifier are ordinary characters.

If the expression was irrelevant, the parser only counted the '{' and
the '}', without taking into account that a '}' might be escaped by a
'\' or be an ordinary character. Parsing therefore stopped at the first
'}', assuming it would finish the expression '${VAR:S,}'.

This parsing mode of only counting balanced '{' and '}' makes sense for
the modifier ':@var@...@', which expands each word of the expression
using the template from the '...'. These templates tend to be simple
enough that counting the '{' and '}' suffices.
 1.20 23-Aug-2022  rillig make: revert parsing of modifier parts (since 2022-08-08)

The modifier ':@var@body@' parses the body in parse-only mode and later
uses Var_Subst on it, in which each literal '$' must be written as '$$'.

Trying to parse the loop body using Var_Parse treated the text
'$${var:-0}' as a single '$' followed by the expression '${var:-0}',
wrongly complaining about the 'Unknown modifier "-0"'.

Found by sjg.
 1.19 08-Aug-2022  rillig make: fix parsing of modifiers containing unbalanced subexpressions
 1.18 28-Dec-2021  rillig make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.17 27-Dec-2021  rillig make: clean up comments
 1.16 09-Dec-2021  rillig make: in parse errors, mark whitespace more clearly

This prevents any trailing whitespace from going unnoticed. It also
marks leading whitespace more clearly, as in the examples with the time
value " 1".
 1.15 09-Dec-2021  rillig make: remove period from end of error messages and warnings

The majority of the existing error messages and warnings does not
include a period at the end. Follow this style consistently.
 1.14 07-Sep-2021  rillig tests/make: expand on the history of unnecessary evaluation
 1.13 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.12 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.11 04-Apr-2021  rillig make: disallow '$' in the variable name of the modifier ':@'

If this restriction should break any existing makefile, the author of
that makefile was probably heading for the IOMCC.
 1.10 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.9 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.8 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.7 14-Mar-2021  rillig tests/make: document today's bug fixes in the test
 1.6 14-Mar-2021  rillig make: do not evaluate modifier ':[...]' in parse-only mode

In parse-only mode, variable expressions in the argument to that
modifier are not resolved. This led to the error message about the 'Bad
modifier' in var-eval-short.mk.
 1.5 14-Mar-2021  rillig make: do not return unevaluated 'else' part from the ':?' modifier

No functional change outside debug mode.
 1.4 14-Mar-2021  rillig tests/make: add test for the ':?' modifier in parse-only mode

The debug output for this scenario will change a bit in an upcoming
commit, but that will not affect anything outside the debug log.
 1.3 14-Mar-2021  rillig make: only evaluate the ':@' modifier if the result is actually used

The test 'var-eval-short' had produced the output 'unexpected' before,
on stderr. It had been generated by '${:Uword:@${FAIL}@expr@}' by
combining the following obscure "features" of make:

1. the ':@' modifier loops over the words of the variable. This
modifier is not really obscure, it still takes some time to get used
to it.

2. the ':@' modifier allows a '$' sign in the variable name, which is
useless in practice.

3. the ':@' modifier creates a temporary loop variable in the global
namespace. Luckily there are only few collisions with other
variable names since their naming conventions differ.

4. after looping over the words of the expression, the temporary global
loop variable is deleted, and at that point the '$' is expanded,
being interpreted as the start of a variable expression.

5. The ':@' modifier deleted the global variable even when it was
called in parse-only mode (without VARE_WANTRES).

When the modifier ':@' was initially added to make in var.c 1.40 from
2000-04-29, Var_Delete didn't expand the variable name. That feature
was added in var.c 1.174 from 2013-05-18, probably without thinking of
this very edge-casey combination of features.

This commit fixes item 5 from the above list. The other obscurities
remain for now.
 1.2 14-Mar-2021  rillig make: only evaluate the ':_' modifier if the expression is needed

See var-eval-short.mk:46 for the test demonstrating this change.
Previously, the expression ${:Uword:_=VAR} was evaluated including all
its side effects even though it was in an irrelevant branch of the
condition.
 1.1 14-Mar-2021  rillig tests/make: add test for short-circuit evaluation of modifiers
 1.26.2.1 02-Aug-2025  perseant Sync with HEAD
 1.17 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.16 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.15 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.14 05-Jul-2024  rillig make: in error messages, distinguish parsing from evaluating
 1.13 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.12 20-Apr-2024  rillig branches: 1.12.2;
make: provide more context information for parse/evaluate errors
 1.11 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.10 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.9 09-May-2023  rillig make: allow ':gmtime' and ':localtime' with dynamic argument

This allows ${%Y:L:gmtime=${mtime}} instead of the indirect
${%Y:L:${:Ugmtime=${mtime}}}.

The direct form also prevents any ':' from the nested expression to be
interpreted as a separator, which doesn't matter for the ':gmtime' and
':localtime' modifiers but will prove useful for other modifiers that
follow the same pattern.
 1.8 27-Dec-2021  rillig make: clean up comments
 1.7 07-Sep-2021  rillig tests/make: expand on the history of unnecessary evaluation
 1.6 06-Sep-2021  rillig make: fix typos in comments
 1.5 04-Apr-2021  rillig make: disallow '$' in the variable name of the modifier ':@'

If this restriction should break any existing makefile, the author of
that makefile was probably heading for the IOMCC.
 1.4 14-Mar-2021  rillig tests/make: document today's bug fixes in the test
 1.3 14-Mar-2021  rillig make: do not return unevaluated 'else' part from the ':?' modifier

No functional change outside debug mode.
 1.2 14-Mar-2021  rillig tests/make: add test for the ':?' modifier in parse-only mode

The debug output for this scenario will change a bit in an upcoming
commit, but that will not affect anything outside the debug log.
 1.1 14-Mar-2021  rillig tests/make: add test for short-circuit evaluation of modifiers
 1.12.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.8 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.7 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.6 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.5 15-Feb-2021  rillig make: rename ExprDefined constants for debug logging
 1.4 03-Feb-2021  rillig make: fix double expansion when appending to a new variable
 1.3 02-Feb-2021  rillig make: replace VarExprFlags with VarExprStatus

The combination of !VEF_UNDEF && VEF_DEF was not possible, which made it
rather strange to model this state as a bit set.

The only functional change is the renamed constants in the debug output.

Using ENUM_VALUE_RTTI_2 felt like overengineering since it's harder to
understand than a simple array of names.
 1.2 30-Oct-2020  rillig make(1): demonstrate double expansion when appending to a variable
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.12 02-Nov-2023  rillig tests/make: test appending to an environment variable
 1.11 02-Nov-2023  rillig make: sync comments with the extracted ParseModifier_Match

No functional change.
 1.10 21-Jun-2023  rillig tests/make: document a few tests
 1.9 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.8 03-Feb-2021  rillig make: fix double expansion when appending to a new variable
 1.7 30-Oct-2020  rillig make(1): demonstrate double expansion when appending to a variable
 1.6 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.5 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.4 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.3 04-Oct-2020  rillig make(1): add basic tests for the += assignment operator
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.10 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.9 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.8 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.7 19-Aug-2023  rillig branches: 1.7.2;
make: add more details to error message about invalid lines
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 01-Feb-2021  rillig make: replace parse error "Need an operator" with better message

The previous error message is not easily understandable since it is
missing a crucial detail, the column where the operator is needed.
Without this information, the author of the makefile gets no useful
hint. Furthermore, there are several types of operators in makefiles:

the dependency operators ':', '!', '::',
the variable assignment operators '=', '!=', '+=', '?=', ':=',
the conditional operators '&&', '||', '!',
the comparison operators '==', '!=', '>', '>=', '<', '<='.

This leaves too much ambiguity.

Replace this error message with "Invalid line type", which is more
generic, more accurate and thus less misleading.
 1.4 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.3 25-Aug-2020  rillig make(1): demonstrate how the parser handles spaces in variable names

Not that anyone would need this feature, or that it was ever intended to
be used at all. But it is there, and if someone ever wants to fix this
part of the parser, they should at least know about this behavior.
 1.2 25-Aug-2020  rillig make(1): add test for variable assignment using the '=' operator
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.11 19-Nov-2023  rillig branches: 1.11.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.10 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.9 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.8 15-Mar-2021  rillig make: improve documentation of ApplyModifiersState

No functional change.
 1.7 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.6 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.5 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.4 25-Aug-2020  rillig make(1): demonstrate how the parser handles spaces in variable names

Not that anyone would need this feature, or that it was ever intended to
be used at all. But it is there, and if someone ever wants to fix this
part of the parser, they should at least know about this behavior.
 1.3 25-Aug-2020  rillig make(1): add test for variable assignment using the '=' operator
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.11.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 19-Nov-2023  rillig tests/make: replace 'variable expressions' with 'expressions'
 1.4 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.3 07-Dec-2020  rillig make(1): add tests and tutorial for the ?= assignment operator
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.16 29-Jun-2025  rillig make: if a condition is erroneous, skip the whole .if/.endif
 1.15 30-Apr-2025  rillig make: fix order of error messages in the ":?" modifier

While here: In Var_Parse, EvalStack_Pop needs to be called before
freeing the short-lived variable, as its name is part of the evaluation
stack.
 1.14 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.13 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.12 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.11 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.10 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.9 20-Apr-2024  rillig branches: 1.9.2;
make: provide more context information for parse/evaluate errors
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 08-Sep-2022  rillig tests/make: extend tests for the ':=' assignment operator
 1.6 30-Nov-2021  rillig tests/make: test and document .MAKE.SAVE_DOLLARS and ':='
 1.5 20-Nov-2021  rillig tests/make: finish a previously unfinished sentence in a comment
 1.4 13-Nov-2021  rillig tests/make: test double indirection in ':=' with undefined variable

Reported by Simon J Gerraty via private mail.

This edge case has been handled in essentially the same way since at
least 2000-05-30, probably several years earlier as well. The test file
is:

---- snip ----
.undef LATER
.undef later
INDIRECT:= ${LATER:S,value,replaced,}
indirect:= ${INDIRECT:C,S,s,}
# expect+1: Unknown modifier "s,value,replaced,"
.if ${indirect} != ""
. error
.else
. warning XXX Neither branch should be taken.
.endif
LATER= uppercase-value
later= lowercase-value
# expect+1: Unknown modifier "s,value,replaced,"
.if ${indirect} != "uppercase-replaced"
. warning XXX Neither branch should be taken.
.else
. error
.endif

all:
@:;
---- snap ----

The output from 'make -r -f later.mk' is:

make-2000.05.30.02.32.21
| make: Unknown modifier 's'
|
| "later.mk", line 9: Need an operator
| make: Unknown modifier 's'
|
| "later.mk", line 15: Need an operator
| Fatal errors encountered -- cannot continue
| exit status 1
make-2000.12.30.16.38.22

The pathnames in the error message gets absolute:

make-2001.01.23.02.48.05
| make: Unknown modifier 's'
|
| ".../later.mk", line 9: Need an operator
| make: Unknown modifier 's'
|
| ".../later.mk", line 15: Need an operator
| Fatal errors encountered -- cannot continue
| exit status 1
make-2001.01.23.02.48.05

All error messages get 'make:' as a common prefix:

make-2001.02.23.21.11.38
| make: Unknown modifier 's'
|
| make: ".../later.mk" line 9: Need an operator
| make: Unknown modifier 's'
|
| make: ".../later.mk" line 15: Need an operator
| make: Fatal errors encountered -- cannot continue
| exit status 1
make-2001.05.29.17.37.52

The 'stopped in' gets added:

make-2001.06.12.23.36.18
| make: Unknown modifier 's'
|
| make: ".../later.mk" line 9: Need an operator
| make: Unknown modifier 's'
|
| make: ".../later.mk" line 15: Need an operator
| make: Fatal errors encountered -- cannot continue
|
| make: stopped in ...
| exit status 1
make-2002.02.21.22.21.34

The empty lines between the error messages get removed.

make-2002.03.21.11.42.21
| make: Unknown modifier 's'
| make: ".../later.mk" line 9: Need an operator
| make: Unknown modifier 's'
| make: ".../later.mk" line 15: Need an operator
| make: Fatal errors encountered -- cannot continue
|
| make: stopped in ...
| exit status 1
make-2009.10.15.02.27.44

The error message for unknown directives gets more helpful:

make-2009.11.19.06.48.37
| make: Unknown modifier 's'
| make: ".../later.mk" line 9: Unknown directive
| make: Unknown modifier 's'
| make: ".../later.mk" line 15: Unknown directive
| make: Fatal errors encountered -- cannot continue
|
| make: stopped in ...
| exit status 1
make-2010.02.22.19.20.33

The directives '.error', '.warning' and '.info' get added:

make-2010.04.29.23.12.21
| make: Unknown modifier 's'
| make: ".../later.mk" line 9: warning: XXX Neither branch should be taken.
| make: Unknown modifier 's'
| make: ".../later.mk" line 15: warning: XXX Neither branch should be taken.
| exit status 0
make-2020.12.20.19.37.23

The error message about an unknown variable modifier gets line number
information:

make-2020.12.20.19.47.34
| make: ".../later.mk" line 6: Unknown modifier 's'
| make: ".../later.mk" line 9: warning: XXX Neither branch should be taken.
| make: ".../later.mk" line 14: Unknown modifier 's'
| make: ".../later.mk" line 15: warning: XXX Neither branch should be taken.
| make: Fatal errors encountered -- cannot continue
| make: stopped in ...
| exit status 1
make-2021.02.23.15.07.58

The error message about an unknown variable modifier gets more context
than only a single letter:

make-2021.02.23.15.19.41
| make: ".../later.mk" line 6: Unknown modifier "s,value,replaced,"
| make: ".../later.mk" line 9: warning: XXX Neither branch should be taken.
| make: ".../later.mk" line 14: Unknown modifier "s,value,replaced,"
| make: ".../later.mk" line 15: warning: XXX Neither branch should be taken.
| make: Fatal errors encountered -- cannot continue
| make: stopped in ...
| exit status 1
 1.3 27-Dec-2020  rillig make(1): move test result of var-op-expand.mk from exp to mk

This makes it easier to run this test in older versions of make. Empty
output means success.
 1.2 08-Nov-2020  rillig make(1): add test for edge case in resolving undefined variables
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.25 29-Jun-2025  rillig make: if a condition is erroneous, skip the whole .if/.endif
 1.24 30-Apr-2025  rillig make: fix order of error messages in the ":?" modifier

While here: In Var_Parse, EvalStack_Pop needs to be called before
freeing the short-lived variable, as its name is part of the evaluation
stack.
 1.23 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.22 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.21 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.20 20-Apr-2024  rillig branches: 1.20.2;
make: provide more context information for parse/evaluate errors
 1.19 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.18 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.17 08-Sep-2022  rillig tests/make: extend tests for the ':=' assignment operator
 1.16 28-Dec-2021  rillig tests/make: use tabs instead of spaces for indentation
 1.15 30-Nov-2021  rillig tests/make: test and document .MAKE.SAVE_DOLLARS and ':='
 1.14 20-Nov-2021  rillig tests/make: finish a previously unfinished sentence in a comment
 1.13 13-Nov-2021  rillig tests/make: extend test for undefined variable in doubly indirect ':='

Just to prevent a half-baked fix to the current behavior that would
concatenate the modifiers of the two expressions, leading to
${LATER:value=sysv:tl} in this case. That expression would be
interpreted as having only a single modifier that would replace the
suffix 'value' with 'sysv:tl'. This is because the SysV modifier
':from=to' spans until the end of the expression.
 1.12 13-Nov-2021  rillig tests/make: test double indirection in ':=' with undefined variable

Reported by Simon J Gerraty via private mail.

This edge case has been handled in essentially the same way since at
least 2000-05-30, probably several years earlier as well. The test file
is:

---- snip ----
.undef LATER
.undef later
INDIRECT:= ${LATER:S,value,replaced,}
indirect:= ${INDIRECT:C,S,s,}
# expect+1: Unknown modifier "s,value,replaced,"
.if ${indirect} != ""
. error
.else
. warning XXX Neither branch should be taken.
.endif
LATER= uppercase-value
later= lowercase-value
# expect+1: Unknown modifier "s,value,replaced,"
.if ${indirect} != "uppercase-replaced"
. warning XXX Neither branch should be taken.
.else
. error
.endif

all:
@:;
---- snap ----

The output from 'make -r -f later.mk' is:

make-2000.05.30.02.32.21
| make: Unknown modifier 's'
|
| "later.mk", line 9: Need an operator
| make: Unknown modifier 's'
|
| "later.mk", line 15: Need an operator
| Fatal errors encountered -- cannot continue
| exit status 1
make-2000.12.30.16.38.22

The pathnames in the error message gets absolute:

make-2001.01.23.02.48.05
| make: Unknown modifier 's'
|
| ".../later.mk", line 9: Need an operator
| make: Unknown modifier 's'
|
| ".../later.mk", line 15: Need an operator
| Fatal errors encountered -- cannot continue
| exit status 1
make-2001.01.23.02.48.05

All error messages get 'make:' as a common prefix:

make-2001.02.23.21.11.38
| make: Unknown modifier 's'
|
| make: ".../later.mk" line 9: Need an operator
| make: Unknown modifier 's'
|
| make: ".../later.mk" line 15: Need an operator
| make: Fatal errors encountered -- cannot continue
| exit status 1
make-2001.05.29.17.37.52

The 'stopped in' gets added:

make-2001.06.12.23.36.18
| make: Unknown modifier 's'
|
| make: ".../later.mk" line 9: Need an operator
| make: Unknown modifier 's'
|
| make: ".../later.mk" line 15: Need an operator
| make: Fatal errors encountered -- cannot continue
|
| make: stopped in ...
| exit status 1
make-2002.02.21.22.21.34

The empty lines between the error messages get removed.

make-2002.03.21.11.42.21
| make: Unknown modifier 's'
| make: ".../later.mk" line 9: Need an operator
| make: Unknown modifier 's'
| make: ".../later.mk" line 15: Need an operator
| make: Fatal errors encountered -- cannot continue
|
| make: stopped in ...
| exit status 1
make-2009.10.15.02.27.44

The error message for unknown directives gets more helpful:

make-2009.11.19.06.48.37
| make: Unknown modifier 's'
| make: ".../later.mk" line 9: Unknown directive
| make: Unknown modifier 's'
| make: ".../later.mk" line 15: Unknown directive
| make: Fatal errors encountered -- cannot continue
|
| make: stopped in ...
| exit status 1
make-2010.02.22.19.20.33

The directives '.error', '.warning' and '.info' get added:

make-2010.04.29.23.12.21
| make: Unknown modifier 's'
| make: ".../later.mk" line 9: warning: XXX Neither branch should be taken.
| make: Unknown modifier 's'
| make: ".../later.mk" line 15: warning: XXX Neither branch should be taken.
| exit status 0
make-2020.12.20.19.37.23

The error message about an unknown variable modifier gets line number
information:

make-2020.12.20.19.47.34
| make: ".../later.mk" line 6: Unknown modifier 's'
| make: ".../later.mk" line 9: warning: XXX Neither branch should be taken.
| make: ".../later.mk" line 14: Unknown modifier 's'
| make: ".../later.mk" line 15: warning: XXX Neither branch should be taken.
| make: Fatal errors encountered -- cannot continue
| make: stopped in ...
| exit status 1
make-2021.02.23.15.07.58

The error message about an unknown variable modifier gets more context
than only a single letter:

make-2021.02.23.15.19.41
| make: ".../later.mk" line 6: Unknown modifier "s,value,replaced,"
| make: ".../later.mk" line 9: warning: XXX Neither branch should be taken.
| make: ".../later.mk" line 14: Unknown modifier "s,value,replaced,"
| make: ".../later.mk" line 15: warning: XXX Neither branch should be taken.
| make: Fatal errors encountered -- cannot continue
| make: stopped in ...
| exit status 1
 1.11 01-Jan-2021  sjg var-op-expand needs MAKE.SAVE_DOLLARS=yes
 1.10 28-Dec-2020  rillig make(1): extend test for modifier parts in ':=' assignments
 1.9 27-Dec-2020  rillig make(1): add test for modifier parts in ':=' assignments
 1.8 27-Dec-2020  rillig make(1): fix edge case in := with undefined in variable name

Previously, the assignment "VAR${UNDEF} := value" actually assigned to 2
variables. See var-op-expand.mk for details.
 1.7 27-Dec-2020  rillig make(1): move test result of var-op-expand.mk from exp to mk

This makes it easier to run this test in older versions of make. Empty
output means success.
 1.6 27-Dec-2020  rillig make(1): add more tests for ':=' assignments
 1.5 27-Dec-2020  rillig make(1): add tests for variable assignments using the ':=' operator
 1.4 08-Nov-2020  rillig make(1): fix bug description of using := with undefined variable

In 1993, the variable names could not refer to other variables yet.
This has been made possible on 2000-05-11, when the "cool magic" was
added that allows assigning to VAR.${param}.
 1.3 08-Nov-2020  rillig make(1): add test for edge case in resolving undefined variables
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.20.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.9 14-Jan-2025  rillig make: simplify code for evaluating the '!=' variable assignment

An undefined variable evaluates to an empty string, without an error
message.
 1.8 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.7 30-Jun-2024  rillig make: add detailed exit status to message for failed sub-commands

Several commands communicate via the exit status and not only
distinguish between zero and non-zero, so make this information
available to ease investigations.

The command "false" is not guaranteed to exit with a consistent status,
so use "(exit 13)" instead in the tests, to keep these tests portable
across different operating systems. The exit status 127 is required for
a shell that cannot find a command, so keep that one.
 1.6 01-Jun-2023  rillig branches: 1.6.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 10-Jan-2022  rillig make: add debug logging for capturing the output of external commands

This applies to all 4 situations in which the output of an external
command is used for modifying a variable or an expression:

* the assignment operator '!='
* the assignment modifier '::!='
* the SUN shell modifier ':sh'
* the other shell modifier ':!cmd!'

Previously, only the shell modifier ':!cmd!' had debug logging.

Suggested by Christoph Badura.
 1.4 09-Jan-2022  rillig tests/make: demonstrate inconsistencies in Cmd_Exec callers

The assignment 'VAR != cmd' generates a warning, the others generate an
error message. That error message is ignored for backwards
compatibility though.

The assignment via the expression ${VAR::!=cmd} only uses the output of
the command if there was no error, the other places use the output
nevertheless.
 1.3 06-Feb-2021  sjg Use plain kill to test signaled child

Recent update to Darwin18 make the test using kill -14
stop working.

Reviewed by: rillig
 1.2 09-Nov-2020  rillig make(1): move test for != assignments to var-op-shell
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6.2.2 02-Aug-2025  perseant Sync with HEAD
 1.6.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.11 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.10 11-Jul-2024  sjg Compat_RunCommand use tempfile if cmd too big

Extract the logic recently added to Cmd_Exec to handle
long commands via temp file to Cmd_Argv,
so it can also be leveraged by Compat_RunCommand

Reviewed by: christos
 1.9 30-Jun-2024  rillig make: add detailed exit status to message for failed sub-commands

Several commands communicate via the exit status and not only
distinguish between zero and non-zero, so make this information
available to ease investigations.

The command "false" is not guaranteed to exit with a consistent status,
so use "(exit 13)" instead in the tests, to keep these tests portable
across different operating systems. The exit status 127 is required for
a shell that cannot find a command, so keep that one.
 1.8 05-Jan-2024  rillig branches: 1.8.2;
tests/make: test long shell commands via Cmd_Exec
 1.7 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 10-Jan-2022  rillig make: add debug logging for capturing the output of external commands

This applies to all 4 situations in which the output of an external
command is used for modifying a variable or an expression:

* the assignment operator '!='
* the assignment modifier '::!='
* the SUN shell modifier ':sh'
* the other shell modifier ':!cmd!'

Previously, only the shell modifier ':!cmd!' had debug logging.

Suggested by Christoph Badura.
 1.5 09-Jan-2022  rillig tests/make: demonstrate inconsistencies in Cmd_Exec callers

The assignment 'VAR != cmd' generates a warning, the others generate an
error message. That error message is ignored for backwards
compatibility though.

The assignment via the expression ${VAR::!=cmd} only uses the output of
the command if there was no error, the other places use the output
nevertheless.
 1.4 06-Feb-2021  sjg Use plain kill to test signaled child

Recent update to Darwin18 make the test using kill -14
stop working.

Reviewed by: rillig
 1.3 09-Nov-2020  rillig make(1): move test for != assignments to var-op-shell
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8.2.2 02-Aug-2025  perseant Sync with HEAD
 1.8.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.2 04-Oct-2020  rillig make(1): fix parsing of the :sh assignment operator modifier
 1.1 04-Oct-2020  rillig make(1): add tests for parsing assignments, especially :sh

Luckily nobody uses the :sh variable assignment modifier since its
syntactical variant != is simpler.
 1.10 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.9 16-Jan-2022  rillig tests/make: document more edge cases for the assignment modifier ':sh'
 1.8 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.7 07-Feb-2021  rillig make: fix typo in comment in test
 1.6 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.5 04-Oct-2020  rillig make(1): add test for combining :sh with +=
 1.4 04-Oct-2020  rillig make(1): add another test for parsing :sh assignments
 1.3 04-Oct-2020  rillig make(1): test another edge case for the :sh assignment
 1.2 04-Oct-2020  rillig make(1): fix parsing of the :sh assignment operator modifier
 1.1 04-Oct-2020  rillig make(1): add tests for parsing assignments, especially :sh

Luckily nobody uses the :sh variable assignment modifier since its
syntactical variant != is simpler.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 20-Dec-2023  rillig make: fix confusing debug logging when deleting a variable

Be clear when deleting a variable is ignored and state the reason,
instead of only providing a keyword as a hint for insiders.
 1.2 20-Dec-2023  rillig tests/make: demonstrate confusing debug log for read-only variables

The message 'delete %s' that occurs above the 'readOnly' looks as if the
variable would indeed be deleted. The wording in the 'readOnly' line is
unclear.
 1.1 24-Jan-2023  sjg Add the unit tests
 1.4 20-Dec-2023  rillig tests/make: demonstrate confusing debug log for read-only variables

The message 'delete %s' that occurs above the 'readOnly' looks as if the
variable would indeed be deleted. The wording in the 'readOnly' line is
unclear.
 1.3 19-Jun-2023  sjg Test that .undef of readOnly variable fails
 1.2 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.1 24-Jan-2023  sjg Add the unit tests
 1.18 13-Jun-2025  rillig make: add on-demand inter-process stack traces

When debugging a build that heavily uses nested calls to sub-makes, the
chain of calls is useful to quickly assess the situation. If explicitly
requested, include the actions from any parent processes in the stack
traces.

Reviewed by: sjg
 1.17 12-Jun-2025  rillig make: add program name to stack traces from sub-makes
 1.16 12-Jun-2025  rillig make: add quotes to "in directory" line in stack traces

The other lines in stack traces use quotes as well.
 1.15 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.14 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.13 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.12 27-Aug-2024  rillig tests/make: add stricter checks to test for recursive variables
 1.11 27-Aug-2024  rillig make: treat recursive variables non-fatally

A recursive variable is no worse than an unknown modifier, so treat them
in the same way by continuing parsing until the end of the makefile.
 1.10 25-Aug-2024  rillig make: add more context to error message about recursive variables
 1.9 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.8 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.7 07-Jan-2024  sjg branches: 1.7.2;
make: more consistent error messages

Move %s: progname from Job_CheckCommands to Fatal
to avoid is being repeated when Job_CheckCommands is passed Error.

This means some errors from var also report progname (and level)
which is useful.

Reviewed by: rillig
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 29-Jan-2022  rillig make: for recursive variables in commands, print location

Print the approximate location based on the last command that has been
defined for the target. It would be possible to get more detailed
location information by counting the number of commands of the target,
but that would get messy due to .USEBEFORE, .USE and .DEFAULT, and
still, this is an edge case, so don't waste too much code for it now.
Having this hint about the location is more helpful than just a plain
"Variable X is recursive" without any further details.
 1.4 29-Jan-2022  rillig tests/make: demonstrate recursive variable in target
 1.3 29-Jan-2022  rillig make: print stack trace on fatal errors

The only fatal error that occurs while the makefiles are read in is the
one about recursive variables, which didn't give any hint about the
location before.

If a recursive variable is detected while evaluating the commands of a
target to be made, there is no location information, as before.
 1.2 31-Oct-2020  rillig make(1): add test for recursion detection with short variable names
 1.1 31-Oct-2020  rillig make(1): add test for recursive variable expressions
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 13-Apr-2025  rillig tests/make: add tests for POSIX mode
 1.11 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.10 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.9 27-Aug-2024  rillig tests/make: add stricter checks to test for recursive variables
 1.8 27-Aug-2024  rillig make: treat recursive variables non-fatally

A recursive variable is no worse than an unknown modifier, so treat them
in the same way by continuing parsing until the end of the makefile.
 1.7 25-Aug-2024  rillig make: add more context to error message about recursive variables
 1.6 19-Nov-2023  rillig branches: 1.6.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 29-Jan-2022  rillig tests/make: sync comment in test for recursive variable
 1.3 29-Jan-2022  rillig tests/make: demonstrate recursive variable in target
 1.2 31-Oct-2020  rillig make(1): add test for recursion detection with short variable names
 1.1 31-Oct-2020  rillig make(1): add test for recursive variable expressions
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 01-Jun-2023  rillig branches: 1.3.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 07-Apr-2023  rillig tests/make: add cross references to command line tests
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.3 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 07-Apr-2023  rillig tests/make: add cross references to command line tests
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.3 17-Dec-2023  rillig tests/make: extend tests for include guards and empty expressions
 1.2 27-Sep-2022  rillig tests/make: add tests for legacy local variables and sorting
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.3 17-Dec-2023  rillig tests/make: extend tests for include guards and empty expressions
 1.2 27-Sep-2022  rillig tests/make: add tests for legacy local variables and sorting
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.9 05-Mar-2024  rillig tests/make: clean up test for local scope variables

Use the same style of quotes for both kinds of variables. To make the
variable values more easily comparable, write them to a single line.
Add the output to the 'expect' lines.
 1.8 01-Mar-2024  sjg make: update var-scope-local test

Show what VAR value is in environment of target script.
 1.7 20-Dec-2023  rillig make: use consistent debug messages style when ignoring variables

When a variable is not modified or not deleted, clearly say so and state
the reason. Use the same style of debug messages everywhere, putting
the word 'ignoring' at the front. Previously, that word sticked out to
the right, but only in some cases.
 1.6 29-Apr-2023  rillig tests/make: extend test for target-local variables
 1.5 28-Apr-2023  rillig tests/make: add tests for target-local variables

While here, move a test from var-scope-local.mk to parse.mk since that
test is not related to variables.
 1.4 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.3 29-Jan-2022  rillig tests/make: extend and isolate tests for target-local variables

Reusing the target var-scope-local.o for several tests made the test
more difficult to understand than necessary. The test names '2' and '3'
didn't convey any meaning.

Instead, add more test targets that are named after what they test. Add
tests for each of the 5 variable assignment operators, to demonstrate an
inconsistency between '+=' and '?='.

Add tests for the built-in target-local variables as well and explain
the general concepts, in particular the exact point where target-local
expressions are expanded.

The lines in the expected output file are not generated in the same
order as they appear in the makefile, so allow the 'expect' lines in
non-linear order, in check-expect.lua.
 1.2 27-Jan-2022  sjg Unit test for local variables
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.11 05-Mar-2024  rillig tests/make: clean up test for local scope variables

Use the same style of quotes for both kinds of variables. To make the
variable values more easily comparable, write them to a single line.
Add the output to the 'expect' lines.
 1.10 01-Mar-2024  sjg make: update var-scope-local test

Show what VAR value is in environment of target script.
 1.9 20-Dec-2023  rillig make: use consistent debug messages style when ignoring variables

When a variable is not modified or not deleted, clearly say so and state
the reason. Use the same style of debug messages everywhere, putting
the word 'ignoring' at the front. Previously, that word sticked out to
the right, but only in some cases.
 1.8 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.7 29-Apr-2023  rillig tests/make: extend test for target-local variables
 1.6 28-Apr-2023  rillig tests/make: add tests for target-local variables

While here, move a test from var-scope-local.mk to parse.mk since that
test is not related to variables.
 1.5 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.4 05-Feb-2022  rillig tests/make: document and try to reproduce the crash in Parse_IsVar

Fixed in parse.c 1.662 from today. To actually crash make, the end of
the expanded dependency line must be at the end of a mapped region.
There is no guaranteed crash, as this depends on the memory allocator.
NetBSD's jemalloc allocates large contiguous regions, making it less
likely for an allocation to end up at the end of a mapped region. The
memory allocators used by FreeBSD and OpenBSD are better at detecting
such bugs.
 1.3 29-Jan-2022  rillig tests/make: extend and isolate tests for target-local variables

Reusing the target var-scope-local.o for several tests made the test
more difficult to understand than necessary. The test names '2' and '3'
didn't convey any meaning.

Instead, add more test targets that are named after what they test. Add
tests for each of the 5 variable assignment operators, to demonstrate an
inconsistency between '+=' and '?='.

Add tests for the built-in target-local variables as well and explain
the general concepts, in particular the exact point where target-local
expressions are expanded.

The lines in the expected output file are not generated in the same
order as they appear in the makefile, so allow the 'expect' lines in
non-linear order, in check-expect.lua.
 1.2 27-Jan-2022  sjg Unit test for local variables
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.1 23-Jan-2022  rillig tests/make: rename var-class to var-scope

There is no such concept as a "variable class" in make, these tests
focus on the variable scope instead.
 1.4 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.3 14-May-2008  sjg Do not set vars in VAR_GLOBAL context, if they have been set on the
command line.
Add a suitable unit-test.
 1.2 01-Jun-2005  sjg branches: 1.2.20; 1.2.22;
Add :Ox for random ordering, based on patch from
Mike M. Volokhov <mishka@apk.od.ua>
 1.1 31-Jul-2003  sjg Test behavior of commandline variable assignments.
 1.2.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.2.20.1 18-May-2008  yamt sync with head.
 1.3 08-Dec-2017  sjg Ensure VAR+=val on command line is handled correctly

If VAR is not previously set, call Var_Set to deal with
the special case of VAR_CMD.

If VAR is previously set, and ctxt is VAR_CMD we should do the update
even if VAR_FROM_CMD is set.
 1.2 18-Nov-2017  sjg Do not append to variable set on command line

POSIX requires that variables set on the command line
be immutable.
Var_Append needs to pass FIND_CMD and skip append
if found variable has VAR_FROM_CMD flag set.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.7 07-Apr-2023  rillig tests/make: add cross references to command line tests
 1.6 16-Feb-2021  rillig make: document the bad state in which the test varcmd.mk is
 1.5 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.4 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.3 08-Dec-2017  sjg Ensure VAR+=val on command line is handled correctly

If VAR is not previously set, call Var_Set to deal with
the special case of VAR_CMD.

If VAR is previously set, and ctxt is VAR_CMD we should do the update
even if VAR_FROM_CMD is set.
 1.2 18-Nov-2017  sjg Do not append to variable set on command line

POSIX requires that variables set on the command line
be immutable.
Var_Append needs to pass FIND_CMD and skip append
if found variable has VAR_FROM_CMD flag set.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.43 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.42 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.41 29-Mar-2025  rillig make: stop parsing after seeing an unknown modifier in an expression

Previously, after an expression such as ${VAR:Z::::}, make detected the
unknown modifier ":Z" and then continued parsing, which produced
unnecessary follow-up error messages. It was also necessary to
distinguish the error cases when logging the result of an applied
modifier in -dv mode.

Unify the error handling cases of a syntax error, an evaluation error
and an unknown modifier, to avoid the unnecessary follow-up error
messages.

The test in varmod-edge.mk now produces ":}" from the erroneous
expression, which may be misleading and thus will be looked at in a
follow-up commit.

The general idea of this patch was reviewed by sjg, I made a few
nonsubstantial changes after the review.
 1.40 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.39 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.38 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.37 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.36 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.35 20-Apr-2024  rillig branches: 1.35.2;
make: provide more context information for parse/evaluate errors
 1.34 20-Dec-2023  rillig tests/make: add the expected output to the test for variable debugging
 1.33 20-Dec-2023  rillig make: use consistent debug messages style when ignoring variables

When a variable is not modified or not deleted, clearly say so and state
the reason. Use the same style of debug messages everywhere, putting
the word 'ignoring' at the front. Previously, that word sticked out to
the right, but only in some cases.
 1.32 20-Dec-2023  rillig make: fix confusing debug logging when deleting a variable

Be clear when deleting a variable is ignored and state the reason,
instead of only providing a keyword as a hint for insiders.
 1.31 10-Dec-2023  rillig make: explain in the debug log why a variable assignment is ignored
 1.30 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.29 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.28 26-Mar-2022  rillig make: add space after colon in debug logging for variables

These log messages are intended for human interpretation, so don't make
them unnecessarily hard to read.
 1.27 20-Nov-2021  rillig make: use correct plural form in debug message
 1.26 10-Apr-2021  rillig make: reword debug log message for empty variable name

The function names did not match anymore, after one of the many
refactorings in the last few months.
 1.25 10-Apr-2021  rillig make: reduce debug logging and memory allocation for ${:U...}

Expressions of the form ${:U...} are often generated by .for loops.
Since these expressions are not generated knowingly by the make user, do
not fill the debug log with them since that would interrupt the normal
reading flow of the -dv log for nested expressions.
 1.24 06-Apr-2021  rillig make: reduce verbosity of the -dv debug logging for standard cases

The verbosity was already removed from LogBeforeApply, now it is
consistent between LogBeforeApply and LogAfterApply.
 1.23 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.22 05-Apr-2021  rillig make: omit unnecessary details from -dv debug log

When an expression is based on a defined variable, it does not matter
whether the evaluation mode is "eval" or "eval-defined", therefore omit
these details to reduce confusion.
 1.21 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.20 05-Apr-2021  rillig make: clean up debug logging for ':M' and ':N'

Using square brackets as quotes was confusing since patterns can contain
square brackets themselves.

The debug logging for VarMatch was a bit too detailed. Having the
"before" and "after" states is enough for all practically relevant
cases.
 1.19 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.18 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.17 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.16 15-Feb-2021  rillig make: rename ExprDefined constants for debug logging
 1.15 02-Feb-2021  rillig make: replace VarExprFlags with VarExprStatus

The combination of !VEF_UNDEF && VEF_DEF was not possible, which made it
rather strange to model this state as a bit set.

The only functional change is the renamed constants in the debug output.

Using ENUM_VALUE_RTTI_2 felt like overengineering since it's harder to
understand than a simple array of names.
 1.14 20-Dec-2020  rillig make(1): error out on unknown variable modifiers at parse time

Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such. This "error message"
also did not influence the exit status in the default mode but only in
-dL mode. The error message also didn't include any line number
information and was thus rude.
 1.13 17-Nov-2020  rillig make(1): make test vardebug independent from the shell
 1.12 31-Oct-2020  rillig make(1): remove debug logging for the :Q variable modifier

The same information is already logged in LogAfterApply.
 1.11 29-Oct-2020  rillig make(1): add test for ignoring assignment to read-only variable
 1.10 29-Oct-2020  rillig make(1): move MAKEFLAGS handling in vardebug test to the test itself
 1.9 30-Sep-2020  rillig make(1): fix bug in evaluation of indirect variable modifiers

Since 2020-09-22, when indirect variable modifiers were applied to a
variable expression based on an undefined variable, these modifiers did
not change the state of a variable expression from undefined to defined.
The modifiers that do this are :D, :U, :L, :P. Minimal example:

${VARNAME:${:UL}}

The :L modifier from the inner expression sets the value of the outer
expression to its variable name, in this case "VARNAME". The outer
expression was not marked as being defined though, which resulted in a
"Malformed conditional" error.

In the commit from 2020-09-22, vardebug.exp had changed a lot, and I had
not inspected the change closely. The important detail was in lines 56
and 60, where VAR_JUNK|VAR_KEEP changed into VEF_UNDEF, thereby losing
the VEF_DEF bit.
 1.8 22-Sep-2020  rillig make(1): move VAR_JUNK and VAR_KEEP away from VarFlags

These two flags have nothing to do with a variable. They are only used
while evaluating a variable expression.

While here, rename the flags and make their documentation more precise.
 1.7 13-Sep-2020  rillig make(1): shorten debug output of ApplyModifiers

Having the words "eflags" and "vflags" in the debug output was too
repetitive. That they are flags is made obvious by the '|' separator,
and the flags have clearly distinguishable names (VARE_* vs. VAR_*),
which lowers the chance for confusion.
 1.6 08-Aug-2020  rillig make(1): add debug logging for Var_Parse

This will hopefully help with tracking down why the "Undefined variable"
error message is not triggered.

There is some other non-obvious behavior nearby. In Parse_DoVar, the !=
assignment operator evaluates the variable using VARE_UNDEFERR, but
there is not even a warning for the following line:

!= echo err ${UNDEFINED} 1>&2
 1.5 08-Aug-2020  rillig make(1): extend debug logging to error values

The error marker var_Error is just an empty string. In the debug log
this empty string was not distinguishable from an otherwise empty
string.

Having this distinction helps in understanding the exact data flow.
 1.4 08-Aug-2020  rillig make(1): add more detailed debug logging for variable modifiers

Before a modifier is applied to a variable, it is not yet parsed,
therefore it is only possible to log a rough estimate of the modifier.
But after applying it, the parsing position has advanced, and the full
modifier can be logged.

In addition, to fully understand how the modifiers work, it's not enough
to just know the variable names and values, there are also some flags
that influence how the modifiers behave. The most influential is
VARE_WANTRES.

Thanks to sjg for the extensive review and valuable feedback on the
first drafts.
 1.3 08-Aug-2020  rillig make(1): fix debug output for indirect modifiers

The trailing part after the modifier was confusing at best. It does
make sense to log the string from p to p+rlen, but not from p+len to
p+len+len.

Consistently use double quotes for strings.
 1.2 08-Aug-2020  rillig make(1): add test for debugging message for indirect modifiers

The current output format stops in the middle of the next modifier,
which was probably not intended.
 1.1 25-Jul-2020  rillig make(1): add tests for previously uncovered code
 1.35.2.1 02-Aug-2025  perseant Sync with HEAD
 1.18 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.17 29-Mar-2025  rillig make: stop parsing after seeing an unknown modifier in an expression

Previously, after an expression such as ${VAR:Z::::}, make detected the
unknown modifier ":Z" and then continued parsing, which produced
unnecessary follow-up error messages. It was also necessary to
distinguish the error cases when logging the result of an applied
modifier in -dv mode.

Unify the error handling cases of a syntax error, an evaluation error
and an unknown modifier, to avoid the unnecessary follow-up error
messages.

The test in varmod-edge.mk now produces ":}" from the erroneous
expression, which may be misleading and thus will be looked at in a
follow-up commit.

The general idea of this patch was reviewed by sjg, I made a few
nonsubstantial changes after the review.
 1.16 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.15 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.14 11-Jan-2025  rillig tests/make: force correct order of expected messages
 1.13 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.12 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.11 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.10 20-Apr-2024  rillig branches: 1.10.2;
make: provide more context information for parse/evaluate errors
 1.9 20-Dec-2023  rillig tests/make: add the expected output to the test for variable debugging
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 04-Feb-2021  rillig make: rename context and ctxt to scope

This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.

Renaming the variable 'ctxt' was trivial since that word is used nowhere
else. In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope. It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.
 1.6 31-Oct-2020  rillig make(1): fix function names in test for variable debugging
 1.5 29-Oct-2020  rillig make(1): add test for ignoring assignment to read-only variable
 1.4 29-Oct-2020  rillig make(1): move MAKEFLAGS handling in vardebug test to the test itself
 1.3 08-Aug-2020  rillig make(1): extend debug logging to error values

The error marker var_Error is just an empty string. In the debug log
this empty string was not distinguishable from an otherwise empty
string.

Having this distinction helps in understanding the exact data flow.
 1.2 08-Aug-2020  rillig make(1): add test for debugging message for indirect modifiers

The current output format stops in the middle of the next modifier,
which was probably not intended.
 1.1 25-Jul-2020  rillig make(1): add tests for previously uncovered code
 1.10.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 25-Jul-2020  rillig make(1): add tests for previously uncovered code
 1.1 25-Jul-2020  rillig make(1): add tests for previously uncovered code
 1.27 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.26 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.25 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.24 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.23 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.22 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.21 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.20 20-Apr-2024  rillig branches: 1.20.2;
make: provide more context information for parse/evaluate errors
 1.19 19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.18 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.17 23-Feb-2021  rillig make: improve error message for unclosed modifier

Replace "variable specification" with the more modern "variable
expression", reduce the number of parentheses, output more than a single
character for modifiers, make it obvious that in expressions such as
${:Serror}, the "" means a variable name.
 1.16 31-Aug-2020  sjg Add test case for FLAGS dependent on .TARGET
 1.15 30-Jul-2020  rillig make(1): add test for indirect unclosed variable

The error message mentions only the original variable name right now.
It's left to the Makefile author to see where the actual unclosed
variable value comes from. From a usability standpoint that's not
optimal, but everything else would need additional cycles even in the
good cases, or it might have side-effects when evaluating a variable
twice (once to detect the error, and a second time to find out the
details of the error).
 1.14 28-Jul-2020  rillig make(1): issue a parse error on unclosed variables

These errors had not been detected before by make.
In pkgsrc, this task as been done by pkglint since 2019-04-07.
 1.13 26-Jul-2020  rillig make(1): add coverage test for dynamic = TRUE in Var_Parse
 1.12 26-Jul-2020  rillig make(1): add test for unclosed variables
 1.11 26-Jul-2020  rillig make(1): add test for expanding dynamic variables
 1.10 26-Jul-2020  rillig make(1): add test for appending and exporting a variable
 1.9 26-Jul-2020  rillig make(1): add test for .MAKE.SAVE_DOLLARS
 1.8 01-Jul-2020  sjg Fix parsing of nested variables during .for loop

Recent change to cond.c to avoid eval of unnecessary
terms had side effect on constructs like:

.for s in 1 2
.if defined(MAN$s) && !empty(MAN$s)
MAN+= ${MAN$s}
.endif
.endfor

resulting in MAN being flagged as recursive.

When Var_Parse encounters a variable within a variable name
we want to force it to be expanded.
But given the way get_mpt_arg calls Var_Parse we need to check
whether we actually started parsing a variable yet.
 1.7 31-Jan-2017  sjg Add check to cmpv test to ensure that target specific vars with
modifiers work as expected.
 1.6 30-Jan-2017  sjg Add :range and :_

:range replaces var value with an integer sequence one per word
in the current var value.

:_ stores the current var value in $_ so that it can be referred to
later in the modifier series.

Reviewed by: christos
 1.5 14-Jan-2017  sjg branches: 1.5.2;
Allow providing a utc value to :{gm,local}time

Reviewed by: christos
 1.4 12-Oct-2015  sjg branches: 1.4.2;
Add unit-test for discarded :?
 1.3 11-Oct-2015  sjg Avoid echo -n in unit-tests
 1.2 11-Oct-2015  sjg Add Boolean wantit to Var_Parse and Var_Subst

wantit will be FALSE when we are just consuming to discard
in which case we skip "expensive" things like Cmd_Exec.

Reviewed by: christos
 1.1 21-Aug-2014  apb Add varmisc.mk, for miscellaneous variable tests.

For now, the only test is copied from
src/tests/usr.bin/make/d_unmatchedvarparen.mk. This was
the only test in src/tests/usr.bin/make that was not also in
src/usr.bin/make/unit-tests.

XXX: src/tests/usr.bin/mk should be changed to reach over to
src/usr.bin/make/unit-tests, instead of keeping out of date copies
of the tests.
 1.4.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.5.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.20.2.1 02-Aug-2025  perseant Sync with HEAD
 1.38 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.37 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.36 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.35 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.34 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.33 19-Oct-2023  rillig branches: 1.33.2;
tests/make: clean up, explain and reorganize several tests
 1.32 05-Dec-2021  rillig tests/make: fix documentation of .MAKE.SAVE_DOLLARS
 1.31 30-Nov-2021  rillig tests/make: test and document .MAKE.SAVE_DOLLARS and ':='
 1.30 04-Feb-2021  rillig make: rename context and ctxt to scope

This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.

Renaming the variable 'ctxt' was trivial since that word is used nowhere
else. In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope. It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.
 1.29 28-Nov-2020  rillig make(1): move test for recursive variable to cond-func-empty

Previously, the documentation of that test was much too short to explain
all the effects that happened in the bug situation from 2020-06-28 until
2020-07-02.
 1.28 07-Nov-2020  rillig make(1): fix references to Var_SetWithFlags in tests
 1.27 06-Nov-2020  rillig make(1): rename getBoolean and s2Boolean
 1.26 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.25 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.24 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.23 31-Aug-2020  sjg Add test case for FLAGS dependent on .TARGET
 1.22 23-Aug-2020  rillig make(1): move test for .undef into separate file
 1.21 08-Aug-2020  rillig make(1): fix typo in test
 1.20 30-Jul-2020  rillig make(1): add test for indirect unclosed variable

The error message mentions only the original variable name right now.
It's left to the Makefile author to see where the actual unclosed
variable value comes from. From a usability standpoint that's not
optimal, but everything else would need additional cycles even in the
good cases, or it might have side-effects when evaluating a variable
twice (once to detect the error, and a second time to find out the
details of the error).
 1.19 28-Jul-2020  rillig make(1): add test for missing argument validation in .undef
 1.18 28-Jul-2020  rillig make(1): issue a parse error on unclosed variables

These errors had not been detected before by make.
In pkgsrc, this task as been done by pkglint since 2019-04-07.
 1.17 26-Jul-2020  rillig make(1): add coverage test for dynamic = TRUE in Var_Parse
 1.16 26-Jul-2020  rillig make(1): add test for unclosed variables
 1.15 26-Jul-2020  rillig make(1): add test for expanding dynamic variables
 1.14 26-Jul-2020  rillig make(1): add test for appending and exporting a variable
 1.13 26-Jul-2020  rillig make(1): add tests for appending to a variable
 1.12 26-Jul-2020  rillig make(1): add test for .MAKE.SAVE_DOLLARS
 1.11 19-Jul-2020  rillig make(1): fix date in comment in unit test
 1.10 02-Jul-2020  rillig make(1): document the actual cause for "recursive variable"

That wrong error message had nothing to do with the .for loop, it was
only caused because the .for loop uses the :U modifier internally.
 1.9 01-Jul-2020  sjg Fix parsing of nested variables during .for loop

Recent change to cond.c to avoid eval of unnecessary
terms had side effect on constructs like:

.for s in 1 2
.if defined(MAN$s) && !empty(MAN$s)
MAN+= ${MAN$s}
.endif
.endfor

resulting in MAN being flagged as recursive.

When Var_Parse encounters a variable within a variable name
we want to force it to be expanded.
But given the way get_mpt_arg calls Var_Parse we need to check
whether we actually started parsing a variable yet.
 1.8 31-Jan-2017  sjg Add check to cmpv test to ensure that target specific vars with
modifiers work as expected.
 1.7 30-Jan-2017  sjg Add :range and :_

:range replaces var value with an integer sequence one per word
in the current var value.

:_ stores the current var value in $_ so that it can be referred to
later in the modifier series.

Reviewed by: christos
 1.6 14-Jan-2017  sjg branches: 1.6.2;
Allow providing a utc value to :{gm,local}time

Reviewed by: christos
 1.5 12-Oct-2015  sjg branches: 1.5.2;
Add unit-test for discarded :?
 1.4 11-Oct-2015  sjg Avoid echo -n in unit-tests
 1.3 11-Oct-2015  sjg Add Boolean wantit to Var_Parse and Var_Subst

wantit will be FALSE when we are just consuming to discard
in which case we skip "expensive" things like Cmd_Exec.

Reviewed by: christos
 1.2 30-Aug-2014  sjg Replace use of $() with ${}
$() means something special to the shell, so ${} reduces confusion
and is used almost exclusively in the rest of the makefiles.

Discussed with: christos
 1.1 21-Aug-2014  apb Add varmisc.mk, for miscellaneous variable tests.

For now, the only test is copied from
src/tests/usr.bin/make/d_unmatchedvarparen.mk. This was
the only test in src/tests/usr.bin/make that was not also in
src/usr.bin/make/unit-tests.

XXX: src/tests/usr.bin/mk should be changed to reach over to
src/usr.bin/make/unit-tests, instead of keeping out of date copies
of the tests.
 1.5.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.6.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.33.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.11 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.10 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.9 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.8 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.7 30-Jun-2024  rillig make: sync error handling between '!=' assignment and '::!=' modifier
 1.6 30-Jun-2024  rillig make: add detailed exit status to message for failed sub-commands

Several commands communicate via the exit status and not only
distinguish between zero and non-zero, so make this information
available to ease investigations.

The command "false" is not guaranteed to exit with a consistent status,
so use "(exit 13)" instead in the tests, to keep these tests portable
across different operating systems. The exit status 127 is required for
a shell that cannot find a command, so keep that one.
 1.5 01-Jun-2023  rillig branches: 1.5.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.3 10-Jan-2022  rillig make: add debug logging for capturing the output of external commands

This applies to all 4 situations in which the output of an external
command is used for modifying a variable or an expression:

* the assignment operator '!='
* the assignment modifier '::!='
* the SUN shell modifier ':sh'
* the other shell modifier ':!cmd!'

Previously, only the shell modifier ':!cmd!' had debug logging.

Suggested by Christoph Badura.
 1.2 09-Jan-2022  rillig tests/make: demonstrate inconsistencies in Cmd_Exec callers

The assignment 'VAR != cmd' generates a warning, the others generate an
error message. That error message is ignored for backwards
compatibility though.

The assignment via the expression ${VAR::!=cmd} only uses the output of
the command if there was no error, the other places use the output
nevertheless.
 1.1 28-Dec-2021  rillig tests/make: document inconsistencies between '!=' and '::!='

Found while trying to make the error messages from Cmd_Exec more
detailed.
 1.5.2.2 02-Aug-2025  perseant Sync with HEAD
 1.5.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.11 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.10 10-Jan-2025  rillig tests/make: test expressions based on undefined variables

When an undefined variable is used in a conditional, make complains about
"Malformed conditional", which is wrong since the conditional is
well-formed but errors out during evaluation.

In order to fix this wrong error message and preserve the remaining
behavior, cover the places in which an expression is evaluated with
undefined expressions being an error (VARE_EVAL_DEFINED), but with
neither producing an error message nor handling errors. This combination
results in the same behavior as evaluating the expressions in the mode
that allows undefined variables to be used in expressions.
 1.9 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.8 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.7 30-Jun-2024  rillig make: sync error handling between '!=' assignment and '::!=' modifier
 1.6 30-Jun-2024  rillig make: add detailed exit status to message for failed sub-commands

Several commands communicate via the exit status and not only
distinguish between zero and non-zero, so make this information
available to ease investigations.

The command "false" is not guaranteed to exit with a consistent status,
so use "(exit 13)" instead in the tests, to keep these tests portable
across different operating systems. The exit status 127 is required for
a shell that cannot find a command, so keep that one.
 1.5 01-Jun-2023  rillig branches: 1.5.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 10-Jan-2022  rillig make: add debug logging for capturing the output of external commands

This applies to all 4 situations in which the output of an external
command is used for modifying a variable or an expression:

* the assignment operator '!='
* the assignment modifier '::!='
* the SUN shell modifier ':sh'
* the other shell modifier ':!cmd!'

Previously, only the shell modifier ':!cmd!' had debug logging.

Suggested by Christoph Badura.
 1.3 09-Jan-2022  rillig tests/make: demonstrate inconsistencies in Cmd_Exec callers

The assignment 'VAR != cmd' generates a warning, the others generate an
error message. That error message is ignored for backwards
compatibility though.

The assignment via the expression ${VAR::!=cmd} only uses the output of
the command if there was no error, the other places use the output
nevertheless.
 1.2 28-Dec-2021  rillig tests/make: use tabs instead of spaces for indentation
 1.1 28-Dec-2021  rillig tests/make: document inconsistencies between '!=' and '::!='

Found while trying to make the error messages from Cmd_Exec more
detailed.
 1.5.2.2 02-Aug-2025  perseant Sync with HEAD
 1.5.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.35 16-Jun-2025  rillig make: in a warning without location information, print the stack trace

Without further context, a warning like the following is hard to track
back:

> nbmake[4]: warning: Invalid character " " in variable name
> "if ,"LSAN_OPTIONS=""
 1.34 30-Mar-2025  rillig make: add details to error message for the "::=" modifier

The previous error message about a bad modifier ":" was not helpful, as
the strcspn call stopped immediately due to the modifier starting with
the separater character ":". The previous error message also didn't
reveal that the "parse error" was due to the expression name being
empty.
 1.33 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.32 29-Mar-2025  rillig make: add more details to error message about unfinished modifier

These details allow to quickly see the place where the syntax error is,
based on the surrounding lines from the stack trace.
 1.31 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.30 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.29 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.28 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.27 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.26 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.25 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.24 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.23 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.22 30-Jun-2024  rillig make: sync error handling between '!=' assignment and '::!=' modifier
 1.21 30-Jun-2024  rillig make: add detailed exit status to message for failed sub-commands

Several commands communicate via the exit status and not only
distinguish between zero and non-zero, so make this information
available to ease investigations.

The command "false" is not guaranteed to exit with a consistent status,
so use "(exit 13)" instead in the tests, to keep these tests portable
across different operating systems. The exit status 127 is required for
a shell that cannot find a command, so keep that one.
 1.20 20-Apr-2024  rillig branches: 1.20.2;
make: provide more context information for parse/evaluate errors
 1.19 07-Jan-2024  rillig tests/make: test the '::=' modifier in target scope
 1.18 29-Dec-2023  rillig tests/make: test the '::=' assignment modifier
 1.17 30-Nov-2021  rillig tests/make: convert tests for modifier '::=' to parse time

This puts the expected result of the expressions closer to the
expressions, making the tests self-contained.

The error messages that used to produce trailing spaces have been fixed
in var.c 1.853 from 2021-02-23. The error message now encloses the
variable name in quotes.
 1.16 06-Apr-2021  rillig make: reduce verbosity of the -dv debug logging for standard cases

The verbosity was already removed from LogBeforeApply, now it is
consistent between LogBeforeApply and LogAfterApply.
 1.15 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.14 05-Apr-2021  rillig make: omit unnecessary details from -dv debug log

When an expression is based on a defined variable, it does not matter
whether the evaluation mode is "eval" or "eval-defined", therefore omit
these details to reduce confusion.
 1.13 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.12 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.11 15-Mar-2021  rillig make: fix double varname expansion in the variable modifier '::='

This is an edge case that doesn't occur in practice since pretty much
nobody dares to use variable names that contain an actual '$' in their
name. This is not about the fairly common VAR.${param} (as written in
the makefile), but instead about the variable whose name is literally
'VAR.${param}'.

The test demonstrates that after the fix, the variable name is taken
exactly as-is for the simple assignment modifier '::='. There are no
such tests for the modifiers '::+=', '::!=' and '::?=', but that's ok.
The code in ApplyModifier_Assign would look assymetrical and suspicious
enough if one of these modifiers would expand its variable name and the
others wouldn't.
 1.10 15-Mar-2021  rillig tests/make: demonstrate that the modifier '::=' expands the varname
 1.9 23-Feb-2021  rillig make: improve error message for bad modifier in variable expression

The improvement is especially noteable for variable expressions based on
the empty variable, see moderrs.exp:103.
 1.8 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.7 23-Feb-2021  rillig make: add quotes around variable name in an error message
 1.6 18-Oct-2020  rillig make(1): explain existing tests for the ::= assignment modifiers
 1.5 25-Aug-2020  rillig make(1): fix error message for ::!= modifier with shell error

It's just too easy to confuse st->val and val.
 1.4 25-Aug-2020  rillig make(1): add test for ::!= modifier with shell error
 1.3 25-Aug-2020  rillig make(1): move test for the ::= modifier to varmod-assign
 1.2 16-Aug-2020  rillig make(1): move tests for the :gmtime and ::= modifiers to separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.20.2.2 02-Aug-2025  perseant Sync with HEAD
 1.20.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.28 30-Mar-2025  rillig make: add details to error message for the "::=" modifier

The previous error message about a bad modifier ":" was not helpful, as
the strcspn call stopped immediately due to the modifier starting with
the separater character ":". The previous error message also didn't
reveal that the "parse error" was due to the expression name being
empty.
 1.27 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.26 29-Mar-2025  rillig make: add more details to error message about unfinished modifier

These details allow to quickly see the place where the syntax error is,
based on the surrounding lines from the stack trace.
 1.25 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.24 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.23 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.22 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.21 30-Jun-2024  rillig make: add detailed exit status to message for failed sub-commands

Several commands communicate via the exit status and not only
distinguish between zero and non-zero, so make this information
available to ease investigations.

The command "false" is not guaranteed to exit with a consistent status,
so use "(exit 13)" instead in the tests, to keep these tests portable
across different operating systems. The exit status 127 is required for
a shell that cannot find a command, so keep that one.
 1.20 20-Apr-2024  rillig branches: 1.20.2;
make: provide more context information for parse/evaluate errors
 1.19 07-Jan-2024  rillig tests/make: test the '::=' modifier in target scope
 1.18 31-Dec-2023  rillig tests/make: finish incomplete sentence in test for assignment modifiers
 1.17 29-Dec-2023  rillig tests/make: test the '::=' assignment modifier
 1.16 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.15 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.14 05-Dec-2021  rillig tests/make: make test for '::=' easier to read, fix comments
 1.13 30-Nov-2021  rillig tests/make: convert tests for modifier '::=' to parse time

This puts the expected result of the expressions closer to the
expressions, making the tests self-contained.

The error messages that used to produce trailing spaces have been fixed
in var.c 1.853 from 2021-02-23. The error message now encloses the
variable name in quotes.
 1.12 15-Mar-2021  rillig make: fix double varname expansion in the variable modifier '::='

This is an edge case that doesn't occur in practice since pretty much
nobody dares to use variable names that contain an actual '$' in their
name. This is not about the fairly common VAR.${param} (as written in
the makefile), but instead about the variable whose name is literally
'VAR.${param}'.

The test demonstrates that after the fix, the variable name is taken
exactly as-is for the simple assignment modifier '::='. There are no
such tests for the modifiers '::+=', '::!=' and '::?=', but that's ok.
The code in ApplyModifier_Assign would look assymetrical and suspicious
enough if one of these modifiers would expand its variable name and the
others wouldn't.
 1.11 15-Mar-2021  rillig tests/make: demonstrate that the modifier '::=' expands the varname
 1.10 14-Feb-2021  rillig make: add test for ::= modifier enclosed in parentheses
 1.9 22-Jan-2021  rillig make(1): remove outdated comment from test

It was fixed in var.c 1.472 from 2020-08-25.
 1.8 18-Oct-2020  rillig make(1): add test for the ::+= modifier expanding its right-hand side
 1.7 18-Oct-2020  rillig make(1): explain existing tests for the ::= assignment modifiers
 1.6 25-Aug-2020  rillig make(1): fix error message for ::!= modifier with shell error

It's just too easy to confuse st->val and val.
 1.5 25-Aug-2020  rillig make(1): add test for ::!= modifier with shell error
 1.4 25-Aug-2020  rillig make(1): move test for the ::= modifier to varmod-assign
 1.3 25-Aug-2020  rillig make(1): explain the varmod-assign test

I have no idea why I added the mod-assign-nested test. It is completely
boring and doesn't provide any insight.
 1.2 16-Aug-2020  rillig make(1): move tests for the :gmtime and ::= modifiers to separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.20.2.2 02-Aug-2025  perseant Sync with HEAD
 1.20.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.14 29-Dec-2023  rillig make: simplify debug message for the ':@var@...@' modifier

The previous variant was hard to understand.
 1.13 23-Aug-2022  rillig make: revert parsing of modifier parts (since 2022-08-08)

The modifier ':@var@body@' parses the body in parse-only mode and later
uses Var_Subst on it, in which each literal '$' must be written as '$$'.

Trying to parse the loop body using Var_Parse treated the text
'$${var:-0}' as a single '$' followed by the expression '${var:-0}',
wrongly complaining about the 'Unknown modifier "-0"'.

Found by sjg.
 1.12 08-Aug-2022  rillig make: fix parsing of modifiers containing unbalanced subexpressions
 1.11 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.10 26-Mar-2022  rillig make: add space after colon in debug logging for variables

These log messages are intended for human interpretation, so don't make
them unnecessarily hard to read.
 1.9 20-Nov-2021  rillig make: use correct plural form in debug message
 1.8 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.7 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.6 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.5 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.4 15-Feb-2021  rillig make: rename ExprDefined constants for debug logging
 1.3 28-Dec-2020  rillig make(1): replace global preserveUndefined with VARE_KEEP_UNDEF

Controlling the expansion of variable expressions using a global
variable and a VARE flag was inconsistent.

Converting the global variable into a flag had to prerequisites:

1. The unintended duplicate variable assignment had to be fixed, as
done in parse.c 1.520 from 2020-12-27. Without this fix, it would have
been necessary to add more flags to Var_Exists and Var_SetWithFlags, and
this would have become too complex.

2. There had to be a unit test demonstrating that VARE_KEEP_DOLLAR only
applies to the top-level expression and is not passed to the
subexpressions, while VARE_KEEP_UNDEF applies to all subexpressions as
well. This test is in var-op-expand.mk 1.10 from 2020-12-28, at least
for the ':@word@' modifier. In ParseModifierPartSubst, VARE_KEEP_UNDEF
is not passed down either, in the same way.
 1.2 08-Nov-2020  rillig make(1): add test demonstrating the :D modifier with := assignments
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.16 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.15 02-Nov-2023  rillig make: clean up comments

No functional change.
 1.14 02-Nov-2023  rillig make: sync comments with the extracted ParseModifier_Match

No functional change.
 1.13 24-Aug-2022  rillig make: fix out-of-bounds read when parsing the ':D' modifier

Since 2000-04-29, when the ':D' and ':U' modifiers were added.
 1.12 30-Nov-2021  rillig tests/make: test and document .MAKE.SAVE_DOLLARS and ':='
 1.11 11-Apr-2021  rillig make: clean up remaining references to VarEvalFlags

VarEvalFlags has been replaced with VarEvalMode. There were some
comments and tests that still referred to the old names.

No functional change.
 1.10 15-Mar-2021  rillig make: replace enum bit-field with struct bit-field for VarEvalFlags

This makes the code easier to read, especially in var.c. It also makes
debugging sessions easier since some debuggers don't show enum
bit-fields symbolically as soon as more than one bit is set.

The code outside var.c is basically unchanged, except that instead of
passing the individual flags, there are 4 predefined evaluation modes.
These suffice for all practical use cases. Only in the implementation
deep inside var.c, the value of the flags keepDollar and keepUndef
differs.

There is no way of passing the struct to EnumFlags_ToString, which means
the ToString function has to be spelled out explicitly. This allows for
fine-tuning the representation in the debug log, to reduce the amount of
uppercae letters.

No functional change.
 1.9 12-Nov-2020  rillig make(1): fix tests varmod-defined and varmod-loop regarding dollars

Some derived versions of NetBSD's make set .MAKE.SAVE_DOLLARS to no. In
these versions, running the tests would fail. Therefore better set
.MAKE.SAVE_DOLLARS to yes explicitly as far as necessary.

Suggested by sjg.
 1.8 08-Nov-2020  rillig make(1): add test demonstrating the :D modifier with := assignments
 1.7 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.6 29-Sep-2020  rillig make(1): add test for using the :D variable modifier as comment
 1.5 12-Sep-2020  rillig make(1): add tests for combining the :D and :U variable modifiers
 1.4 03-Sep-2020  rillig make(1): add tests for the :D and :U modifiers

This prepares a refactoring for ApplyModifier_Defined.
 1.3 25-Aug-2020  rillig make(1): add test for the :D modifier
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.34 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.33 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.32 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.31 29-Mar-2025  rillig make: stop parsing after seeing an unknown modifier in an expression

Previously, after an expression such as ${VAR:Z::::}, make detected the
unknown modifier ":Z" and then continued parsing, which produced
unnecessary follow-up error messages. It was also necessary to
distinguish the error cases when logging the result of an applied
modifier in -dv mode.

Unify the error handling cases of a syntax error, an evaluation error
and an unknown modifier, to avoid the unnecessary follow-up error
messages.

The test in varmod-edge.mk now produces ":}" from the erroneous
expression, which may be misleading and thus will be looked at in a
follow-up commit.

The general idea of this patch was reviewed by sjg, I made a few
nonsubstantial changes after the review.
 1.30 29-Mar-2025  rillig make: add more details to error message about unfinished modifier

These details allow to quickly see the place where the syntax error is,
based on the surrounding lines from the stack trace.
 1.29 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.28 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.27 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.26 09-Jul-2024  rillig make: error out on syntax errors in ':M' and ':N' modifiers

More than a year ago, the warning has been added. Now it has been
promoted to an error.
 1.25 06-Jul-2024  rillig make: error out on a matching malformed matching pattern '[['
 1.24 06-Jul-2024  rillig tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.
 1.23 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.22 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.21 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.20 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.19 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.18 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.17 20-Apr-2024  rillig branches: 1.17.2;
make: provide more context information for parse/evaluate errors
 1.16 19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.15 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.14 23-Feb-2021  rillig make: improve error message for unclosed modifier

Replace "variable specification" with the more modern "variable
expression", reduce the number of parentheses, output more than a single
character for modifiers, make it obvious that in expressions such as
${:Serror}, the "" means a variable name.
 1.13 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.12 23-Feb-2021  rillig make: add quotes around variable name in an error message
 1.11 22-Feb-2021  rillig make: add test for confusing double space in error message
 1.10 20-Dec-2020  rillig make(1): error out on unknown variable modifiers at parse time

Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such. This "error message"
also did not influence the exit status in the default mode but only in
-dL mode. The error message also didn't include any line number
information and was thus rude.
 1.9 20-Dec-2020  rillig make(1): include line numbers in output of test varmod-edge.mk

Suppressing the line numbers does not provide much benefit, given that
the test file doesn't change often.
 1.8 08-Aug-2020  rillig make(1): improve error message in case of unfinished modifiers

The previous error message "Unclosed substitution" was wrong for several
reasons.

It is not about "unclosed", but about "unfinished" since in the
:@var@...@ modifier the missing '@' does not really close anything.

The word "substitution" may have originated in a time where :S and
:from=to were the only modifiers, and these were indeed substitutions,
but several other modifiers aren't.

The :S and :C modifiers allow an arbitrary delimiter, therefore it is
helpful to enclose the delimiter in quotes, just in case someone chooses
')' or '{' or even ' ' as delimiter.
 1.7 01-Aug-2020  rillig make(1): improve output grouping in varmod-edge test

The generated error messages are now closer to the test cases that
produce them. To keep the expected output stable, the line numbers are
omitted from the .info directives.
 1.6 01-Aug-2020  rillig make(1): add test for ${VAR::::}

It's a bit unrealistic, but at least there are good diagnostics.
 1.5 01-Aug-2020  rillig make(1): add test for empty modifier list after colon

This is a good candidate for becoming an error in strict mode.
Either write ${VAR} or write ${VAR:modifiers}, but not half-baked.
 1.4 02-Dec-2019  rillig branches: 1.4.4;
Add more tests for variable modifiers in make.
 1.3 30-Nov-2019  rillig Demonstrate some more edge cases for the :M modifier
 1.2 30-Nov-2019  rillig Add another unit test for the :M modifier
 1.1 30-Nov-2019  rillig Add unit tests for variable modifiers like :M and :N
 1.4.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.4.1 02-Dec-2019  martin file varmod-edge.exp was added on branch phil-wifi on 2020-04-08 14:09:17 +0000
 1.17.2.2 02-Aug-2025  perseant Sync with HEAD
 1.17.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.37 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.36 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.35 29-Mar-2025  rillig make: stop parsing after seeing an unknown modifier in an expression

Previously, after an expression such as ${VAR:Z::::}, make detected the
unknown modifier ":Z" and then continued parsing, which produced
unnecessary follow-up error messages. It was also necessary to
distinguish the error cases when logging the result of an applied
modifier in -dv mode.

Unify the error handling cases of a syntax error, an evaluation error
and an unknown modifier, to avoid the unnecessary follow-up error
messages.

The test in varmod-edge.mk now produces ":}" from the erroneous
expression, which may be misleading and thus will be looked at in a
follow-up commit.

The general idea of this patch was reviewed by sjg, I made a few
nonsubstantial changes after the review.
 1.34 29-Mar-2025  rillig make: add more details to error message about unfinished modifier

These details allow to quickly see the place where the syntax error is,
based on the surrounding lines from the stack trace.
 1.33 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.32 11-Jan-2025  rillig tests/make: force correct order of expected messages
 1.31 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.30 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.29 09-Jul-2024  rillig make: error out on syntax errors in ':M' and ':N' modifiers

More than a year ago, the warning has been added. Now it has been
promoted to an error.
 1.28 06-Jul-2024  rillig tests/make: sync a comment with reality
 1.27 06-Jul-2024  rillig make: error out on a matching malformed matching pattern '[['
 1.26 06-Jul-2024  rillig tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.
 1.25 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.24 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.23 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.22 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.21 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.20 20-Apr-2024  rillig branches: 1.20.2;
make: provide more context information for parse/evaluate errors
 1.19 19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.18 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.17 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.16 23-Feb-2021  rillig make: improve error message for unclosed modifier

Replace "variable specification" with the more modern "variable
expression", reduce the number of parentheses, output more than a single
character for modifiers, make it obvious that in expressions such as
${:Serror}, the "" means a variable name.
 1.15 23-Feb-2021  rillig make: add quotes around variable name in an error message
 1.14 22-Feb-2021  rillig make: add test for confusing double space in error message
 1.13 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.12 08-Aug-2020  rillig make(1): fixup for "Unfinished modifier"
 1.11 01-Aug-2020  rillig make(1): improve output grouping in varmod-edge test

The generated error messages are now closer to the test cases that
produce them. To keep the expected output stable, the line numbers are
omitted from the .info directives.
 1.10 01-Aug-2020  rillig make(1): add test for ${VAR::::}

It's a bit unrealistic, but at least there are good diagnostics.
 1.9 01-Aug-2020  rillig make(1): add test for empty modifier list after colon

This is a good candidate for becoming an error in strict mode.
Either write ${VAR} or write ${VAR:modifiers}, but not half-baked.
 1.8 19-Jul-2020  rillig make(1): rename VarGetPattern to ParseModifierPart
 1.7 27-Apr-2020  christos Adjust test for the new behavior: % on hls and no % on the rhs does not
prepend the lhs to the rhs.
 1.6 02-Dec-2019  rillig branches: 1.6.4;
Add more tests for variable modifiers in make.
 1.5 01-Dec-2019  rillig Fix out-of-bounds read in Str_Match.
 1.4 30-Nov-2019  rillig Demonstrate some more edge cases for the :M modifier
 1.3 30-Nov-2019  rillig Fix unit test for edge case in :M modifier
 1.2 30-Nov-2019  rillig Add another unit test for the :M modifier
 1.1 30-Nov-2019  rillig Add unit tests for variable modifiers like :M and :N
 1.6.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6.4.1 02-Dec-2019  martin file varmod-edge.mk was added on branch phil-wifi on 2020-04-08 14:09:17 +0000
 1.20.2.2 02-Aug-2025  perseant Sync with HEAD
 1.20.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 03-Nov-2020  rillig make(1): clean up unit tests
 1.3 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.2 16-Aug-2020  rillig make(1): move tests for the :gmtime and ::= modifiers to separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 20-Dec-2020  rillig make(1): add tests for variable modifiers on trailing slashes
 1.2 23-Aug-2020  rillig make(1): move tests for :H :E :R :T into separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 20-Dec-2020  rillig make(1): add tests for variable modifiers on trailing slashes
 1.3 23-Aug-2020  rillig make(1): move tests for :H :E :R :T into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.24 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.23 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.22 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.21 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.20 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.19 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.18 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.17 20-Apr-2024  rillig branches: 1.17.2;
make: provide more context information for parse/evaluate errors
 1.16 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.15 09-May-2023  rillig tests/make: clean up tests for ':gmtime' and ':localtime'
 1.14 09-May-2023  rillig make: allow ':gmtime' and ':localtime' with dynamic argument

This allows ${%Y:L:gmtime=${mtime}} instead of the indirect
${%Y:L:${:Ugmtime=${mtime}}}.

The direct form also prevents any ':' from the nested expression to be
interpreted as a separator, which doesn't matter for the ':gmtime' and
':localtime' modifiers but will prove useful for other modifiers that
follow the same pattern.
 1.13 09-May-2023  rillig tests/make: demonstrate parse bug in :gmtime and :localtime modifiers
 1.12 09-Dec-2021  rillig make: in parse errors, mark whitespace more clearly

This prevents any trailing whitespace from going unnoticed. It also
marks leading whitespace more clearly, as in the examples with the time
value " 1".
 1.11 19-Jan-2021  rillig make(1): fix tests for :gmtime and :localtime for 32-bit time_t

The comparison operator had accidentally been '!=' instead of '=='.

While here, proofread the documentation and add references for where the
32-bit time_t is defined on Linux and FreeBSD.
 1.10 21-Dec-2020  rillig make(1): remove excess newline from parse errors (since 2020-11-01)

For the modifiers :gmtime and :localtime, the excess newline had been
added in var.c 1.631 from 2020-10-31 21:40:20.

For the modifiers :range and :ts, the excess newline had been added in
var.c 1.635 from 2020-11-01 14:36:25.
 1.9 21-Dec-2020  rillig make(1): align tests for :localtime with those for :gmtime

These tests had been almost the same before, now they are as similar as
possible again.
 1.8 21-Dec-2020  rillig make(1): move tests for :gmtime to parse time

It's easier to have both the expressions and the expected values in a
single file. This also allows for flexible handling of multiple
acceptable outputs, in this case for 32-bit time_t.
 1.7 30-Nov-2020  rillig make(1): fix tests for :gmtime and :localtime for 32-bit time_t

https://bugs.freebsd.org/251465
 1.6 31-Oct-2020  rillig make(1): make parsing of the :gmtime and :localtime modifiers stricter

These variable modifiers accept an optional timestamp in seconds, to
select which date to print. This feature is only used very rarely. The
NetBSD build doesn't use it at all, and the FreeBSD build mainly uses
the plain modifiers :gmtime and :localtime, but not their optional
argument :gmtime=1500000000.

Therefore, this change is not going to affect many builds. Those that
are indeed affected had been wrong all the time anyway.

At parse time, these errors stop the build, as intended. After that,
when the actual shell commands of the targets are expanded and run,
these errors don't stop anything, the build just continues as if nothing
had happened. This is a general problem with Var_Parse, see the many
"handle errors" markers in the code. Another problem is that on parse
errors, parsing continues and spits out spurious strings of the form
"mtime" and "ocaltime". This as well is a general problem with error
handling in make.

ok sjg
 1.5 31-Oct-2020  rillig make(1): add more tests for the variable modifier :localtime
 1.4 31-Oct-2020  rillig make(1): add test for :gmtime with space before the number of seconds
 1.3 31-Oct-2020  rillig make(1): add tests for error handling in the :gmtime variable modifier
 1.2 16-Aug-2020  rillig make(1): move tests for the :gmtime and ::= modifiers to separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.17.2.1 02-Aug-2025  perseant Sync with HEAD
 1.27 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.26 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.25 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.24 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.23 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.22 20-Apr-2024  rillig branches: 1.22.2;
make: provide more context information for parse/evaluate errors
 1.21 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.20 19-Oct-2023  rillig tests/make: clean up, explain and reorganize several tests
 1.19 19-Aug-2023  rillig make: clean up comments regarding gmtime/strftime

These two functions are not supposed to be used together, thus it is not
a bug if combining them produces unexpected results.
 1.18 19-Aug-2023  rillig make: work around bugs in gmtime on several platforms
 1.17 19-Aug-2023  rillig tests/make: provide instructions for reproducing bug in gmtime

The test is not enabled because its results differ too much between the
platforms.
 1.16 19-Aug-2023  rillig tests/make: document bug in ':gmtime' with '%s'
 1.15 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.14 10-May-2023  rillig tests/make: clean up comments in tests
 1.13 09-May-2023  rillig tests/make: clean up tests for ':gmtime' and ':localtime'
 1.12 09-May-2023  rillig make: allow ':gmtime' and ':localtime' with dynamic argument

This allows ${%Y:L:gmtime=${mtime}} instead of the indirect
${%Y:L:${:Ugmtime=${mtime}}}.

The direct form also prevents any ':' from the nested expression to be
interpreted as a separator, which doesn't matter for the ':gmtime' and
':localtime' modifiers but will prove useful for other modifiers that
follow the same pattern.
 1.11 09-May-2023  rillig tests/make: demonstrate parse bug in :gmtime and :localtime modifiers
 1.10 19-Jan-2021  rillig make(1): fix tests for :gmtime and :localtime for 32-bit time_t

The comparison operator had accidentally been '!=' instead of '=='.

While here, proofread the documentation and add references for where the
32-bit time_t is defined on Linux and FreeBSD.
 1.9 22-Dec-2020  rillig make(1): fix commit number in tests for :gmtime and :localtime
 1.8 21-Dec-2020  rillig make(1): align tests for :localtime with those for :gmtime

These tests had been almost the same before, now they are as similar as
possible again.
 1.7 21-Dec-2020  rillig make(1): move tests for :gmtime to parse time

It's easier to have both the expressions and the expected values in a
single file. This also allows for flexible handling of multiple
acceptable outputs, in this case for 32-bit time_t.
 1.6 31-Oct-2020  rillig make(1): add more tests for the variable modifier :localtime
 1.5 31-Oct-2020  rillig make(1): add test for :gmtime with space before the number of seconds
 1.4 31-Oct-2020  rillig make(1): add tests for error handling in the :gmtime variable modifier
 1.3 29-Oct-2020  rillig make(1): add test for default time format of the :gmtime modifier
 1.2 16-Aug-2020  rillig make(1): move tests for the :gmtime and ::= modifiers to separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.22.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.9 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.8 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.7 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.6 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.5 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.4 20-Apr-2024  rillig branches: 1.4.2;
make: provide more context information for parse/evaluate errors
 1.3 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.2 23-Aug-2020  rillig make(1): move tests for :hash :range :localtime into separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.5 04-Sep-2020  rillig branches: 1.5.8;
make(1): add test for :hash returning ffffffff

In the previous brute force search, it seemed there was no string with
that hash code. That was probably an oversight or a little programming
mistake. Anyway, it's possible to get that hash value, so keep the
example.
 1.4 04-Sep-2020  rillig make(1): extend tests for the :hash variable modifier

The previous test vectors didn't contain any hash with a leading zero.
This could have been a simple programming mistake by using %8x instead
of the intended %08x. Using snprintf wouldn't have been possible anyway
since the hex digits are printed in little-endian order, but without
reversing the bits of each digit. Kind of unusual, but doesn't affect
the distribution of the hashes.
 1.3 23-Aug-2020  rillig make(1): move tests for :hash :range :localtime into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.8.1 02-Aug-2025  perseant Sync with HEAD
 1.4 10-Jul-2022  rillig tests/make: extend tests for modifier ':H'
 1.3 20-Dec-2020  rillig make(1): add tests for variable modifiers on trailing slashes
 1.2 23-Aug-2020  rillig make(1): move tests for :H :E :R :T into separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 01-Jun-2024  rillig tests/make: test more modifiers and special variables
 1.5 10-Jul-2022  rillig tests/make: extend tests for modifier ':H'
 1.4 20-Dec-2020  rillig make(1): add tests for variable modifiers on trailing slashes
 1.3 23-Aug-2020  rillig make(1): move tests for :H :E :R :T into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.32 29-Jun-2025  rillig make: if a condition is erroneous, skip the whole .if/.endif
 1.31 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.30 30-Apr-2025  rillig make: fix order of error messages in the ":?" modifier

While here: In Var_Parse, EvalStack_Pop needs to be called before
freeing the short-lived variable, as its name is part of the evaluation
stack.
 1.29 30-Apr-2025  rillig tests/make: demonstrate wrong order of error messages
 1.28 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.27 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.26 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.25 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.24 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.23 05-Jul-2024  rillig make: in error messages, distinguish parsing from evaluating
 1.22 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.21 30-Jun-2024  rillig make: error out on syntax error in conditions in ':?then:else' modifier

The 'Error' function only reports errors but does not affect the exit
status, the 'Parse_Error' function does, while providing more details to
find the cause of the syntax error.
 1.20 20-Apr-2024  rillig branches: 1.20.2;
make: provide more context information for parse/evaluate errors
 1.19 10-Dec-2023  rillig make: remove redundant text from diagnostic about bad '?:' modifier
 1.18 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.17 01-Jul-2023  rillig tests/make: show how to use indirect conditions in the '?:' modifier
 1.16 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.15 18-Feb-2023  rillig tests/make: document why ':?' cannot parse its operands in balanced mode
 1.14 25-Sep-2022  rillig tests/make: reduce trailing whitespace
 1.13 04-Sep-2022  rillig make: add more details to error message for numeric comparison

Before:
String comparison operator must be either == or !=

After:
Comparison with '>=' requires both operands 'no' and '10' to be numeric

Noticed by martin@ in pkgsrc/textproc/py-pygments.
 1.12 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.11 11-Jun-2021  rillig tests/make: demonstrate handling of '+' and '*' in modifier ':?'

It doesn't make sense that these two characters are handled differently,
but that's what the current code has been doing for years.
 1.10 19-Apr-2021  rillig make: do not complain when skipping the condition 'no >= 10'

Seen in external/bsd/tmux when building with Clang. See
varmod-ifelse.mk for the detailed story.
 1.9 19-Apr-2021  rillig tests/make: add another example for parsing of the modifier ':?'
 1.8 19-Apr-2021  rillig tests/make: add detailed explanation for error message in conditional
 1.7 19-Apr-2021  rillig make: use straight quotes for error 'Bad conditional expression'

This diagnostic was supposed to be an error, see ApplyModifier_IfElse.

When such an error occurs while the makefiles are read, make stops with
an error, as can be expected. But when such an error occurs later,
after all makefiles have been read, the message is printed but make does
not stop.

In lint mode (-dL), make stops in such a case. I didn't dare to make
this the default behavior, out of fear of breaking existing build
infrastructure, not only in NetBSD or pkgsrc, but also FreeBSD and other
operating systems that use the bmake distribution, generated from the
same source code.
 1.6 19-Apr-2021  rillig tests/make: demonstrate unexpected behavior of the modifier ':?'
 1.5 10-Dec-2020  rillig make(1): add test demonstrating how to defer evaluation in :? modifier
 1.4 12-Nov-2020  rillig make(1): add test for unhandled parse error in :? variable modifier
 1.3 23-Oct-2020  rillig make(1): move tests from cond2.mk to varmod-ifelse.mk (fixup)
 1.2 23-Oct-2020  rillig make(1): move tests from cond2.mk to varmod-ifelse.mk
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.20.2.2 02-Aug-2025  perseant Sync with HEAD
 1.20.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.41 29-Jun-2025  rillig make: if a condition is erroneous, skip the whole .if/.endif
 1.40 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.39 30-Apr-2025  rillig make: fix order of error messages in the ":?" modifier

While here: In Var_Parse, EvalStack_Pop needs to be called before
freeing the short-lived variable, as its name is part of the evaluation
stack.
 1.38 30-Apr-2025  rillig tests/make: demonstrate wrong order of error messages
 1.37 04-Apr-2025  rillig make: fix error message for undefined variable in conditional

Previously, only ${UNDEF} had the proper error message, while
${UNDEF:M*} still produced the wrong "Malformed conditional".
 1.36 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.35 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.34 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.33 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.32 05-Jul-2024  rillig make: in error messages, distinguish parsing from evaluating
 1.31 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.30 30-Jun-2024  rillig make: error out on syntax error in conditions in ':?then:else' modifier

The 'Error' function only reports errors but does not affect the exit
status, the 'Parse_Error' function does, while providing more details to
find the cause of the syntax error.
 1.29 02-Jun-2024  rillig branches: 1.29.2;
make: sync VarEvalMode constant names with their debug log names
 1.28 23-Apr-2024  rillig make: clean up comments, code and tests
 1.27 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.26 10-Dec-2023  rillig make: remove redundant text from diagnostic about bad '?:' modifier
 1.25 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.24 18-Nov-2023  rillig tests/make: test parsing of the ':?' modifier
 1.23 01-Jul-2023  rillig tests/make: show how to use indirect conditions in the '?:' modifier
 1.22 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.21 18-Feb-2023  rillig tests/make: document why ':?' cannot parse its operands in balanced mode
 1.20 25-Sep-2022  rillig tests/make: reduce trailing whitespace
 1.19 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.18 15-Jan-2022  rillig tests/make: fix comment in test
 1.17 11-Jun-2021  rillig tests/make: demonstrate handling of '+' and '*' in modifier ':?'

It doesn't make sense that these two characters are handled differently,
but that's what the current code has been doing for years.
 1.16 19-Apr-2021  rillig make: do not complain when skipping the condition 'no >= 10'

Seen in external/bsd/tmux when building with Clang. See
varmod-ifelse.mk for the detailed story.
 1.15 19-Apr-2021  rillig tests/make: add another example for parsing of the modifier ':?'
 1.14 19-Apr-2021  rillig tests/make: add detailed explanation for error message in conditional
 1.13 19-Apr-2021  rillig make: use straight quotes for error 'Bad conditional expression'

This diagnostic was supposed to be an error, see ApplyModifier_IfElse.

When such an error occurs while the makefiles are read, make stops with
an error, as can be expected. But when such an error occurs later,
after all makefiles have been read, the message is printed but make does
not stop.

In lint mode (-dL), make stops in such a case. I didn't dare to make
this the default behavior, out of fear of breaking existing build
infrastructure, not only in NetBSD or pkgsrc, but also FreeBSD and other
operating systems that use the bmake distribution, generated from the
same source code.
 1.12 19-Apr-2021  rillig tests/make: demonstrate unexpected behavior of the modifier ':?'
 1.11 11-Apr-2021  rillig make: clean up remaining references to VarEvalFlags

VarEvalFlags has been replaced with VarEvalMode. There were some
comments and tests that still referred to the old names.

No functional change.
 1.10 15-Mar-2021  rillig make: replace enum bit-field with struct bit-field for VarEvalFlags

This makes the code easier to read, especially in var.c. It also makes
debugging sessions easier since some debuggers don't show enum
bit-fields symbolically as soon as more than one bit is set.

The code outside var.c is basically unchanged, except that instead of
passing the individual flags, there are 4 predefined evaluation modes.
These suffice for all practical use cases. Only in the implementation
deep inside var.c, the value of the flags keepDollar and keepUndef
differs.

There is no way of passing the struct to EnumFlags_ToString, which means
the ToString function has to be spelled out explicitly. This allows for
fine-tuning the representation in the debug log, to reduce the amount of
uppercae letters.

No functional change.
 1.9 25-Jan-2021  rillig make(1): rename struct For to struct ForLoop

This removes the ambiguity whether For_Free is meant to be a
module-exported function or a local function associate with that struct.
Rename the affected functions as well.
 1.8 10-Dec-2020  rillig make(1): document limitations of deferred '$' in ':?' modifier
 1.7 10-Dec-2020  rillig make(1): add test demonstrating how to defer evaluation in :? modifier
 1.6 12-Nov-2020  rillig make(1): add test for unhandled parse error in :? variable modifier
 1.5 23-Oct-2020  rillig make(1): move tests from cond2.mk to varmod-ifelse.mk
 1.4 09-Oct-2020  rillig make(1): add test for parsing the :? variable modifier
 1.3 02-Oct-2020  rillig make(1): add tests for parsing and exporting variables

Once again, there are a few surprises deeply hidden inside the edge
cases.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.29.2.2 02-Aug-2025  perseant Sync with HEAD
 1.29.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.36 30-Mar-2025  rillig make: if there is an error in the items of a .for loop, don't iterate
 1.35 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.34 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.33 29-Mar-2025  rillig make: stop parsing after seeing an unknown modifier in an expression

Previously, after an expression such as ${VAR:Z::::}, make detected the
unknown modifier ":Z" and then continued parsing, which produced
unnecessary follow-up error messages. It was also necessary to
distinguish the error cases when logging the result of an applied
modifier in -dv mode.

Unify the error handling cases of a syntax error, an evaluation error
and an unknown modifier, to avoid the unnecessary follow-up error
messages.

The test in varmod-edge.mk now produces ":}" from the erroneous
expression, which may be misleading and thus will be looked at in a
follow-up commit.

The general idea of this patch was reviewed by sjg, I made a few
nonsubstantial changes after the review.
 1.32 29-Mar-2025  rillig make: add details about indirect modifiers to the stack traces

Previously, the error message "Unfinished modifier (',' missing)" from
moderrs.mk didn't provide enough context to understand where and why the
comma was missing.
 1.31 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.30 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.29 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.28 20-Apr-2024  rillig branches: 1.28.2;
make: provide more context information for parse/evaluate errors
 1.27 04-Feb-2024  rillig make: do not evaluate indirect modifiers in parse-only mode

Discovered by sjg.
 1.26 04-Feb-2024  rillig make: in parse-only mode, don't evaluate modifiers

Previously, the ':S', ':ts', ':tA' and ':from=to' modifiers were
evaluated in parse-only mode, unnecessarily. This is only noticeable
when an indirect modifier is evaluated in parse-only mode, which is
another bug that will be fixed in a follow-up commit.
 1.25 04-Feb-2024  rillig tests/make: extend test for wrong evaluation in parse-only mode
 1.24 04-Feb-2024  rillig tests/make: indirect modifiers are evaluated in parse-only mode

Found by sjg@.
 1.23 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.22 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.21 08-Jan-2022  rillig make: fix reported line numbers of continuation lines (since 2002)

Previously, multi-line directives like '.info' or '.error' reported the
line number of their last line instead of their first line, which is
more usual. This also affected the debug log from '-dp'.
 1.20 28-Dec-2021  rillig make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.19 20-Nov-2021  rillig make: use correct plural form in debug message
 1.18 10-Apr-2021  rillig make: reduce debug logging and memory allocation for ${:U...}

Expressions of the form ${:U...} are often generated by .for loops.
Since these expressions are not generated knowingly by the make user, do
not fill the debug log with them since that would interrupt the normal
reading flow of the -dv log for nested expressions.
 1.17 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.16 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.15 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.14 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.13 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.12 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.11 15-Feb-2021  rillig make: rename ExprDefined constants for debug logging
 1.10 14-Feb-2021  rillig make: update line numbers in expected test output

The documentation from the previous commit added a few lines.
 1.9 14-Feb-2021  rillig make: add more tests for edge cases in evaluating variable expressions

As a preparation for refactoring the code around variable expressions,
there need to be a few tests for indirect variable modifiers since these
were not covered before.

Indirect modifiers may include ':ts' and ':tW', which change the
interpretation of the variable expression in small details. The scope
of these changes is limited to the indirect modifier, any evaluations
outside this indirect modifier are unaffected.

The changes to the .exp file are mostly line number changes, plus a
demonstration of a newly found bug, where an expression is evaluated
successfully despite producing a parse error.
 1.8 02-Feb-2021  rillig make: replace VarExprFlags with VarExprStatus

The combination of !VEF_UNDEF && VEF_DEF was not possible, which made it
rather strange to model this state as a bit set.

The only functional change is the renamed constants in the debug output.

Using ENUM_VALUE_RTTI_2 felt like overengineering since it's harder to
understand than a simple array of names.
 1.7 28-Dec-2020  rillig make(1): replace global preserveUndefined with VARE_KEEP_UNDEF

Controlling the expansion of variable expressions using a global
variable and a VARE flag was inconsistent.

Converting the global variable into a flag had to prerequisites:

1. The unintended duplicate variable assignment had to be fixed, as
done in parse.c 1.520 from 2020-12-27. Without this fix, it would have
been necessary to add more flags to Var_Exists and Var_SetWithFlags, and
this would have become too complex.

2. There had to be a unit test demonstrating that VARE_KEEP_DOLLAR only
applies to the top-level expression and is not passed to the
subexpressions, while VARE_KEEP_UNDEF applies to all subexpressions as
well. This test is in var-op-expand.mk 1.10 from 2020-12-28, at least
for the ':@word@' modifier. In ParseModifierPartSubst, VARE_KEEP_UNDEF
is not passed down either, in the same way.
 1.6 27-Dec-2020  rillig make(1): split test for indirect modifiers into paragraphs
 1.5 27-Dec-2020  rillig make(1): add tests for parsing indirect modifiers in nested expressions
 1.4 27-Dec-2020  rillig make(1): remove dead code from ApplyModifiersIndirect

At that point, the expression can never be varUndefined. At the
beginning of ParseVarnameLong, the expression is initialized to a simple
empty string, and that string is only ever converted to varUndefined at
the very end of Var_Parse.
 1.3 20-Dec-2020  rillig make(1): error out on unknown variable modifiers at parse time

Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such. This "error message"
also did not influence the exit status in the default mode but only in
-dL mode. The error message also didn't include any line number
information and was thus rude.
 1.2 20-Dec-2020  rillig make(1): move tests for indirect modifiers around

The next commit will error out on unknown modifiers and influence the
exit status. The test modmisc.mk contains both parse time tests and run
time tests. To prevent the latter from being run, the parse error is
moved to varmod-indirect.mk, which only contains parse time tests.
 1.1 01-Dec-2020  rillig make(1): add test and tutorial for indirect modifiers
 1.28.2.1 02-Aug-2025  perseant Sync with HEAD
 1.24 30-Mar-2025  rillig make: if there is an error in the items of a .for loop, don't iterate
 1.23 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.22 29-Mar-2025  rillig make: stop parsing after seeing an unknown modifier in an expression

Previously, after an expression such as ${VAR:Z::::}, make detected the
unknown modifier ":Z" and then continued parsing, which produced
unnecessary follow-up error messages. It was also necessary to
distinguish the error cases when logging the result of an applied
modifier in -dv mode.

Unify the error handling cases of a syntax error, an evaluation error
and an unknown modifier, to avoid the unnecessary follow-up error
messages.

The test in varmod-edge.mk now produces ":}" from the erroneous
expression, which may be misleading and thus will be looked at in a
follow-up commit.

The general idea of this patch was reviewed by sjg, I made a few
nonsubstantial changes after the review.
 1.21 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.20 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.19 20-Apr-2024  rillig branches: 1.19.2;
make: provide more context information for parse/evaluate errors
 1.18 04-Feb-2024  rillig make: do not evaluate indirect modifiers in parse-only mode

Discovered by sjg.
 1.17 04-Feb-2024  rillig make: in parse-only mode, don't evaluate modifiers

Previously, the ':S', ':ts', ':tA' and ':from=to' modifiers were
evaluated in parse-only mode, unnecessarily. This is only noticeable
when an indirect modifier is evaluated in parse-only mode, which is
another bug that will be fixed in a follow-up commit.
 1.16 04-Feb-2024  rillig tests/make: extend test for wrong evaluation in parse-only mode
 1.15 04-Feb-2024  rillig tests/make: indirect modifiers are evaluated in parse-only mode

Found by sjg@.
 1.14 19-Nov-2023  rillig tests/make: replace 'variable expressions' with 'expressions'
 1.13 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.12 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.11 15-Jan-2022  rillig tests/make: ensure that the 'expect' comments in tests are correct

Based on tests/usr.bin/xlint/check-expect.lua.

For now, this extra check needs to be run manually.
 1.10 08-Jan-2022  rillig make: fix reported line numbers of continuation lines (since 2002)

Previously, multi-line directives like '.info' or '.error' reported the
line number of their last line instead of their first line, which is
more usual. This also affected the debug log from '-dp'.
 1.9 15-Mar-2021  rillig make: rename ApplyModifiersState to ModChain

The new name accurately describes the structural element that holds such
properties as the separator character and whether the expression value
is considered a single word. The old name ApplyModifiersState was too
long and was meant as a placeholder anyway, when I introduced it in
var.c 1.236 from 2020-07-03.
 1.8 14-Feb-2021  rillig make: add test for indirect ':U' modifier

Unlike ':ts' and ':tW', the effects of ':U' are visible even after the
modifiers from the nested expression have been applied. These subtle
details, like many others, are not documented in the manual page.
 1.7 14-Feb-2021  rillig make: document since when indirect modifiers are supported
 1.6 14-Feb-2021  rillig make: add more tests for edge cases in evaluating variable expressions

As a preparation for refactoring the code around variable expressions,
there need to be a few tests for indirect variable modifiers since these
were not covered before.

Indirect modifiers may include ':ts' and ':tW', which change the
interpretation of the variable expression in small details. The scope
of these changes is limited to the indirect modifier, any evaluations
outside this indirect modifier are unaffected.

The changes to the .exp file are mostly line number changes, plus a
demonstration of a newly found bug, where an expression is evaluated
successfully despite producing a parse error.
 1.5 27-Dec-2020  rillig make(1): split test for indirect modifiers into paragraphs
 1.4 27-Dec-2020  rillig make(1): add tests for parsing indirect modifiers in nested expressions
 1.3 27-Dec-2020  rillig make(1): remove dead code from ApplyModifiersIndirect

At that point, the expression can never be varUndefined. At the
beginning of ParseVarnameLong, the expression is initialized to a simple
empty string, and that string is only ever converted to varUndefined at
the very end of Var_Parse.
 1.2 20-Dec-2020  rillig make(1): move tests for indirect modifiers around

The next commit will error out on unknown modifiers and influence the
exit status. The test modmisc.mk contains both parse time tests and run
time tests. To prevent the latter from being run, the parse error is
moved to varmod-indirect.mk, which only contains parse time tests.
 1.1 01-Dec-2020  rillig make(1): add test and tutorial for indirect modifiers
 1.19.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 30-Sep-2020  rillig make(1): fix bug in evaluation of indirect variable modifiers

Since 2020-09-22, when indirect variable modifiers were applied to a
variable expression based on an undefined variable, these modifiers did
not change the state of a variable expression from undefined to defined.
The modifiers that do this are :D, :U, :L, :P. Minimal example:

${VARNAME:${:UL}}

The :L modifier from the inner expression sets the value of the outer
expression to its variable name, in this case "VARNAME". The outer
expression was not marked as being defined though, which resulted in a
"Malformed conditional" error.

In the commit from 2020-09-22, vardebug.exp had changed a lot, and I had
not inspected the change closely. The important detail was in lines 56
and 60, where VAR_JUNK|VAR_KEEP changed into VEF_UNDEF, thereby losing
the VEF_DEF bit.
 1.2 30-Sep-2020  rillig make(1): demonstrate bug in evaluation of indirect variable modifiers

Reported by sjg.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.7 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.6 02-Oct-2020  rillig make(1): add test for repeating the :L variable modifier
 1.5 30-Sep-2020  rillig make(1): fix typos in test for the :L variable modifier
 1.4 30-Sep-2020  rillig make(1): demonstrate bug in evaluation of indirect variable modifiers

Reported by sjg.
 1.3 25-Aug-2020  rillig make(1): add test for the :L modifier
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.21 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.20 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.19 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.18 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.17 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.16 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.15 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.14 20-Apr-2024  rillig branches: 1.14.2;
make: provide more context information for parse/evaluate errors
 1.13 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.12 09-May-2023  rillig tests/make: clean up tests for ':gmtime' and ':localtime'
 1.11 09-May-2023  rillig make: allow ':gmtime' and ':localtime' with dynamic argument

This allows ${%Y:L:gmtime=${mtime}} instead of the indirect
${%Y:L:${:Ugmtime=${mtime}}}.

The direct form also prevents any ':' from the nested expression to be
interpreted as a separator, which doesn't matter for the ':gmtime' and
':localtime' modifiers but will prove useful for other modifiers that
follow the same pattern.
 1.10 09-May-2023  rillig tests/make: demonstrate parse bug in :gmtime and :localtime modifiers
 1.9 09-Dec-2021  rillig make: in parse errors, mark whitespace more clearly

This prevents any trailing whitespace from going unnoticed. It also
marks leading whitespace more clearly, as in the examples with the time
value " 1".
 1.8 19-Jan-2021  rillig make(1): fix tests for :gmtime and :localtime for 32-bit time_t

The comparison operator had accidentally been '!=' instead of '=='.

While here, proofread the documentation and add references for where the
32-bit time_t is defined on Linux and FreeBSD.
 1.7 21-Dec-2020  rillig make(1): remove excess newline from parse errors (since 2020-11-01)

For the modifiers :gmtime and :localtime, the excess newline had been
added in var.c 1.631 from 2020-10-31 21:40:20.

For the modifiers :range and :ts, the excess newline had been added in
var.c 1.635 from 2020-11-01 14:36:25.
 1.6 21-Dec-2020  rillig make(1): align tests for :localtime with those for :gmtime

These tests had been almost the same before, now they are as similar as
possible again.
 1.5 30-Nov-2020  rillig make(1): fix tests for :gmtime and :localtime for 32-bit time_t

https://bugs.freebsd.org/251465
 1.4 31-Oct-2020  rillig make(1): make parsing of the :gmtime and :localtime modifiers stricter

These variable modifiers accept an optional timestamp in seconds, to
select which date to print. This feature is only used very rarely. The
NetBSD build doesn't use it at all, and the FreeBSD build mainly uses
the plain modifiers :gmtime and :localtime, but not their optional
argument :gmtime=1500000000.

Therefore, this change is not going to affect many builds. Those that
are indeed affected had been wrong all the time anyway.

At parse time, these errors stop the build, as intended. After that,
when the actual shell commands of the targets are expanded and run,
these errors don't stop anything, the build just continues as if nothing
had happened. This is a general problem with Var_Parse, see the many
"handle errors" markers in the code. Another problem is that on parse
errors, parsing continues and spits out spurious strings of the form
"mtime" and "ocaltime". This as well is a general problem with error
handling in make.

ok sjg
 1.3 31-Oct-2020  rillig make(1): add more tests for the variable modifier :localtime
 1.2 23-Aug-2020  rillig make(1): move tests for :hash :range :localtime into separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.14.2.1 02-Aug-2025  perseant Sync with HEAD
 1.20 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.19 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.18 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.17 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.16 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.15 20-Apr-2024  rillig branches: 1.15.2;
make: provide more context information for parse/evaluate errors
 1.14 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.13 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.12 10-May-2023  rillig tests/make: clean up comments in tests
 1.11 09-May-2023  rillig tests/make: clean up tests for ':gmtime' and ':localtime'
 1.10 09-May-2023  rillig make: allow ':gmtime' and ':localtime' with dynamic argument

This allows ${%Y:L:gmtime=${mtime}} instead of the indirect
${%Y:L:${:Ugmtime=${mtime}}}.

The direct form also prevents any ':' from the nested expression to be
interpreted as a separator, which doesn't matter for the ':gmtime' and
':localtime' modifiers but will prove useful for other modifiers that
follow the same pattern.
 1.9 09-May-2023  rillig tests/make: demonstrate parse bug in :gmtime and :localtime modifiers
 1.8 19-Jan-2021  rillig make(1): fix tests for :gmtime and :localtime for 32-bit time_t

The comparison operator had accidentally been '!=' instead of '=='.

While here, proofread the documentation and add references for where the
32-bit time_t is defined on Linux and FreeBSD.
 1.7 22-Dec-2020  rillig make(1): fix commit number in tests for :gmtime and :localtime
 1.6 21-Dec-2020  rillig make(1): align tests for :localtime with those for :gmtime

These tests had been almost the same before, now they are as similar as
possible again.
 1.5 31-Oct-2020  rillig make(1): add more tests for the variable modifier :localtime
 1.4 29-Oct-2020  rillig make(1): add test for default format of the :localtime modifier
 1.3 23-Aug-2020  rillig make(1): move tests for :hash :range :localtime into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.15.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.8 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.7 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.6 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.5 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.4 20-Apr-2024  rillig branches: 1.4.2;
make: provide more context information for parse/evaluate errors
 1.3 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 09-Dec-2021  rillig make: remove period from end of error messages and warnings

The majority of the existing error messages and warnings does not
include a period at the end. Follow this style consistently.
 1.1 05-Dec-2021  rillig make: fix use-after-free in modifier ':@'

Without memory allocator debugging, the newly added test doesn't show
any obvious failure.

With memory allocator debugging enabled, all make versions since
2016.02.27.16.20.06 crash with a segmentation fault.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.6 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.5 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.4 20-Apr-2024  rillig branches: 1.4.2;
make: provide more context information for parse/evaluate errors
 1.3 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 05-Dec-2021  rillig tests/make: document use-after-free in ':@' more precisely

The commit message from the previous commit was misleading. This bug
had not been introduced in 2016.02.27.16.20.06 (which was entirely
unrelated) but rather in 2016.02.18.23.33.25.

The commit 2016.02.27.16.20.06 just happened to be the first one from my
make-archive that triggered the bug. That's because I had only checked
out the last commit from each month, to save some disk space.
 1.1 05-Dec-2021  rillig make: fix use-after-free in modifier ':@'

Without memory allocator debugging, the newly added test doesn't show
any obvious failure.

With memory allocator debugging enabled, all make versions since
2016.02.27.16.20.06 crash with a segmentation fault.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.14 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.13 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.12 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.11 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.10 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.9 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.8 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.7 20-Apr-2024  rillig branches: 1.7.2;
make: provide more context information for parse/evaluate errors
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 09-Dec-2021  rillig make: remove period from end of error messages and warnings

The majority of the existing error messages and warnings does not
include a period at the end. Follow this style consistently.
 1.4 05-Dec-2021  rillig tests/make: demonstrate use-after-free in modifier ':@'
 1.3 30-Nov-2021  rillig tests/make: test and document .MAKE.SAVE_DOLLARS and ':='
 1.2 04-Apr-2021  rillig make: disallow '$' in the variable name of the modifier ':@'

If this restriction should break any existing makefile, the author of
that makefile was probably heading for the IOMCC.
 1.1 04-Apr-2021  rillig tests/make: split test for modifier ':@' into separate files

The file varmod-loop.mk has grown too large to be single-purpose, plus
it combined parse-time and run-time tests. This has the downside that
as soon as a parse-time test results in an error, the run-time tests are
not run anymore.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.11 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.10 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.9 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.8 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.7 20-Apr-2024  rillig branches: 1.7.2;
make: provide more context information for parse/evaluate errors
 1.6 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 05-Dec-2021  rillig tests/make: demonstrate use-after-free in modifier ':@'
 1.3 30-Nov-2021  rillig tests/make: test and document .MAKE.SAVE_DOLLARS and ':='
 1.2 04-Apr-2021  rillig make: disallow '$' in the variable name of the modifier ':@'

If this restriction should break any existing makefile, the author of
that makefile was probably heading for the IOMCC.
 1.1 04-Apr-2021  rillig tests/make: split test for modifier ':@' into separate files

The file varmod-loop.mk has grown too large to be single-purpose, plus
it combined parse-time and run-time tests. This has the downside that
as soon as a parse-time test results in an error, the run-time tests are
not run anymore.
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 04-Apr-2021  rillig tests/make: remove accidentally added intermediate files
 1.2 04-Apr-2021  rillig make: disallow '$' in the variable name of the modifier ':@'

If this restriction should break any existing makefile, the author of
that makefile was probably heading for the IOMCC.
 1.1 04-Apr-2021  rillig tests/make: split test for modifier ':@' into separate files

The file varmod-loop.mk has grown too large to be single-purpose, plus
it combined parse-time and run-time tests. This has the downside that
as soon as a parse-time test results in an error, the run-time tests are
not run anymore.
 1.3 04-Apr-2021  rillig tests/make: remove accidentally added intermediate files
 1.2 04-Apr-2021  rillig make: disallow '$' in the variable name of the modifier ':@'

If this restriction should break any existing makefile, the author of
that makefile was probably heading for the IOMCC.
 1.1 04-Apr-2021  rillig tests/make: split test for modifier ':@' into separate files

The file varmod-loop.mk has grown too large to be single-purpose, plus
it combined parse-time and run-time tests. This has the downside that
as soon as a parse-time test results in an error, the run-time tests are
not run anymore.
 1.3 04-Apr-2021  rillig tests/make: remove accidentally added intermediate files
 1.2 04-Apr-2021  rillig make: disallow '$' in the variable name of the modifier ':@'

If this restriction should break any existing makefile, the author of
that makefile was probably heading for the IOMCC.
 1.1 04-Apr-2021  rillig tests/make: split test for modifier ':@' into separate files

The file varmod-loop.mk has grown too large to be single-purpose, plus
it combined parse-time and run-time tests. This has the downside that
as soon as a parse-time test results in an error, the run-time tests are
not run anymore.
 1.22 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.21 01-Jun-2024  rillig branches: 1.21.2;
make: remove unused VARE_EVAL_KEEP_DOLLAR
 1.20 14-Apr-2024  rillig make: add debug logging for .if and .for lines in -dp mode

This helps track down in which line a condition is evaluated.
 1.19 18-Feb-2023  rillig tests/make: document the modifier ':@var@body@'
 1.18 23-Aug-2022  rillig tests/make: document how the modifier ':@' works
 1.17 23-Aug-2022  rillig make: revert parsing of modifier parts (since 2022-08-08)

The modifier ':@var@body@' parses the body in parse-only mode and later
uses Var_Subst on it, in which each literal '$' must be written as '$$'.

Trying to parse the loop body using Var_Parse treated the text
'$${var:-0}' as a single '$' followed by the expression '${var:-0}',
wrongly complaining about the 'Unknown modifier "-0"'.

Found by sjg.
 1.16 23-Aug-2022  rillig tests/make: demonstrate parse error in ':@' modifier (since 2022-08-08)

Reported by sjg via private mail.
 1.15 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.14 28-Dec-2021  rillig make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.13 05-Dec-2021  rillig make: fix use-after-free in modifier ':@'

Without memory allocator debugging, the newly added test doesn't show
any obvious failure.

With memory allocator debugging enabled, all make versions since
2016.02.27.16.20.06 crash with a segmentation fault.
 1.12 05-Dec-2021  rillig tests/make: demonstrate use-after-free in modifier ':@'
 1.11 30-Nov-2021  rillig tests/make: test and document .MAKE.SAVE_DOLLARS and ':='
 1.10 04-Apr-2021  rillig tests/make: split test for modifier ':@' into separate files

The file varmod-loop.mk has grown too large to be single-purpose, plus
it combined parse-time and run-time tests. This has the downside that
as soon as a parse-time test results in an error, the run-time tests are
not run anymore.
 1.9 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.8 15-Mar-2021  rillig tests/make: convert varmod-loop to parse-time

In case of unexpected failures, this provides the line number of the
'.error' directive.
 1.7 15-Mar-2021  rillig tests/make: add position marker in test 'varmod-loop'
 1.6 23-Feb-2021  rillig make: demonstrate how to undefine variables during evaluation

For a very long time now, I had thought that it would be impossible to
undefine global variables during the evaluation of variable expressions.
This is something that the memory management in Var_Parse relies upon,
see the comment 'the value of the variable must not change'.

After several unsuccessful attempts at referring to an already freed
previous value of a variable, today I discovered how to unset a global
variable while evaluating an expression, which has the same effect. To
demonstrate that this use-after-free can reliably crash make, it would
need a memory allocator with a debug mode that never re-allocates the
same memory block after it has been used once. This is something that
jemalloc cannot do at the moment. Valgrind would be another idea, but
that has not been ported to NetBSD.

Undefining a global variable while evaluating an expression is made
possible by an implementation detail of the modifier ':@'. That
modifier undefines the loop variable, without restoring its previous
value, see ApplyModifier_Loop.

By the very old conventions of ODE Make, these loop variables are named
'.V.' and thus do not conflict with variables from other naming
conventions. In NetBSD and pkgsrc, these loop variables are typically
called 'var', sometimes '_var' with a leading underscore, which also
doesn't conflict with the typical form 'VAR' of variables in the global
namespace. Therefore, in practice these loop variables don't interfere
with other variables.

One case that can practically arise is when an outer variable has a
modifier ':@word@${VAR.${word}}@' and one of the referenced variables
uses the same variable name in the modifier, see varmod-loop.mk 1.10
line 91 for a detailed explanation.

By using the ${:@VAR@@} modifier in a place that is evaluated with
cmdline scope, it is not only possible to undefine global variables, it
is possible to undefine cmdline variables as well. When evaluated in a
specific make target, the expression ${:@\@@@} can even be used to
undefine the variable '.TARGET', which will probably crash make with an
assertion failure.
 1.5 12-Nov-2020  rillig make(1): fix tests varmod-defined and varmod-loop regarding dollars

Some derived versions of NetBSD's make set .MAKE.SAVE_DOLLARS to no. In
these versions, running the tests would fail. Therefore better set
.MAKE.SAVE_DOLLARS to yes explicitly as far as necessary.

Suggested by sjg.
 1.4 08-Nov-2020  rillig make(1): add test demonstrating how ':=' and ':@var@' interact
 1.3 13-Sep-2020  rillig make(1): add test for empty variable name in :@var@...@ modifier
 1.2 16-Aug-2020  rillig make(1): move tests for :S, :C, :@ from modmisc to their separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.21.2.1 02-Aug-2025  perseant Sync with HEAD
 1.26 02-Jun-2024  rillig make: sync VarEvalMode constant names with their debug log names
 1.25 01-Jun-2024  rillig make: remove unused VARE_EVAL_KEEP_DOLLAR
 1.24 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.23 18-Feb-2023  rillig tests/make: document the modifier ':@var@body@'
 1.22 18-Feb-2023  rillig make: fix parsing of unevaluated subexpressions with unbalanced '{}'

Since var.c 1.323 from 2020-07-26, modifiers containing unbalanced
braces or parentheses were parsed differently, depending on whether they
were relevant or not.

For example, the expression '${VAR:...}' is enclosed with braces. When
this expression has a modifier ':S,},}},g' that would double each '}' in
that expression, the parser got confused:

If the expression was relevant, the modifier was parsed as usual, taking
into account that the 3 '}' in the modifier are ordinary characters.

If the expression was irrelevant, the parser only counted the '{' and
the '}', without taking into account that a '}' might be escaped by a
'\' or be an ordinary character. Parsing therefore stopped at the first
'}', assuming it would finish the expression '${VAR:S,}'.

This parsing mode of only counting balanced '{' and '}' makes sense for
the modifier ':@var@...@', which expands each word of the expression
using the template from the '...'. These templates tend to be simple
enough that counting the '{' and '}' suffices.
 1.21 23-Aug-2022  rillig tests/make: document how the modifier ':@' works
 1.20 23-Aug-2022  rillig make: revert parsing of modifier parts (since 2022-08-08)

The modifier ':@var@body@' parses the body in parse-only mode and later
uses Var_Subst on it, in which each literal '$' must be written as '$$'.

Trying to parse the loop body using Var_Parse treated the text
'$${var:-0}' as a single '$' followed by the expression '${var:-0}',
wrongly complaining about the 'Unknown modifier "-0"'.

Found by sjg.
 1.19 23-Aug-2022  rillig tests/make: demonstrate parse error in ':@' modifier (since 2022-08-08)

Reported by sjg via private mail.
 1.18 05-Dec-2021  rillig make: fix use-after-free in modifier ':@'

Without memory allocator debugging, the newly added test doesn't show
any obvious failure.

With memory allocator debugging enabled, all make versions since
2016.02.27.16.20.06 crash with a segmentation fault.
 1.17 05-Dec-2021  rillig tests/make: demonstrate use-after-free in modifier ':@'
 1.16 30-Nov-2021  rillig tests/make: test and document .MAKE.SAVE_DOLLARS and ':='
 1.15 11-Apr-2021  rillig make: clean up remaining references to VarEvalFlags

VarEvalFlags has been replaced with VarEvalMode. There were some
comments and tests that still referred to the old names.

No functional change.
 1.14 04-Apr-2021  rillig tests/make: split test for modifier ':@' into separate files

The file varmod-loop.mk has grown too large to be single-purpose, plus
it combined parse-time and run-time tests. This has the downside that
as soon as a parse-time test results in an error, the run-time tests are
not run anymore.
 1.13 15-Mar-2021  rillig tests/make: convert varmod-loop to parse-time

In case of unexpected failures, this provides the line number of the
'.error' directive.
 1.12 15-Mar-2021  rillig tests/make: add position marker in test 'varmod-loop'
 1.11 15-Mar-2021  rillig make: replace enum bit-field with struct bit-field for VarEvalFlags

This makes the code easier to read, especially in var.c. It also makes
debugging sessions easier since some debuggers don't show enum
bit-fields symbolically as soon as more than one bit is set.

The code outside var.c is basically unchanged, except that instead of
passing the individual flags, there are 4 predefined evaluation modes.
These suffice for all practical use cases. Only in the implementation
deep inside var.c, the value of the flags keepDollar and keepUndef
differs.

There is no way of passing the struct to EnumFlags_ToString, which means
the ToString function has to be spelled out explicitly. This allows for
fine-tuning the representation in the debug log, to reduce the amount of
uppercae letters.

No functional change.
 1.10 23-Feb-2021  rillig make: demonstrate how to undefine variables during evaluation

For a very long time now, I had thought that it would be impossible to
undefine global variables during the evaluation of variable expressions.
This is something that the memory management in Var_Parse relies upon,
see the comment 'the value of the variable must not change'.

After several unsuccessful attempts at referring to an already freed
previous value of a variable, today I discovered how to unset a global
variable while evaluating an expression, which has the same effect. To
demonstrate that this use-after-free can reliably crash make, it would
need a memory allocator with a debug mode that never re-allocates the
same memory block after it has been used once. This is something that
jemalloc cannot do at the moment. Valgrind would be another idea, but
that has not been ported to NetBSD.

Undefining a global variable while evaluating an expression is made
possible by an implementation detail of the modifier ':@'. That
modifier undefines the loop variable, without restoring its previous
value, see ApplyModifier_Loop.

By the very old conventions of ODE Make, these loop variables are named
'.V.' and thus do not conflict with variables from other naming
conventions. In NetBSD and pkgsrc, these loop variables are typically
called 'var', sometimes '_var' with a leading underscore, which also
doesn't conflict with the typical form 'VAR' of variables in the global
namespace. Therefore, in practice these loop variables don't interfere
with other variables.

One case that can practically arise is when an outer variable has a
modifier ':@word@${VAR.${word}}@' and one of the referenced variables
uses the same variable name in the modifier, see varmod-loop.mk 1.10
line 91 for a detailed explanation.

By using the ${:@VAR@@} modifier in a place that is evaluated with
cmdline scope, it is not only possible to undefine global variables, it
is possible to undefine cmdline variables as well. When evaluated in a
specific make target, the expression ${:@\@@@} can even be used to
undefine the variable '.TARGET', which will probably crash make with an
assertion failure.
 1.9 04-Feb-2021  rillig make: rename context and ctxt to scope

This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.

Renaming the variable 'ctxt' was trivial since that word is used nowhere
else. In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope. It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.
 1.8 12-Nov-2020  rillig make(1): fix tests varmod-defined and varmod-loop regarding dollars

Some derived versions of NetBSD's make set .MAKE.SAVE_DOLLARS to no. In
these versions, running the tests would fail. Therefore better set
.MAKE.SAVE_DOLLARS to yes explicitly as far as necessary.

Suggested by sjg.
 1.7 08-Nov-2020  rillig make(1): add test demonstrating how ':=' and ':@var@' interact
 1.6 03-Nov-2020  rillig make(1): in tests, replace "dollar character" with "dollar sign"
 1.5 31-Oct-2020  rillig make(1): add test for combining the :@ and :? variable modifiers
 1.4 18-Oct-2020  rillig make(1): add test for nested :@ modifiers using the same variable name
 1.3 13-Sep-2020  rillig make(1): add test for empty variable name in :@var@...@ modifier
 1.2 16-Aug-2020  rillig make(1): move tests for :S, :C, :@ from modmisc to their separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.29 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.28 28-Jun-2025  rillig make: error out on an ":M" modifier whose pattern ends with backslash

This edge case is not expected to occur intentionally in practice.
 1.27 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.26 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.25 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.24 09-Jul-2024  rillig make: error out on syntax errors in ':M' and ':N' modifiers

More than a year ago, the warning has been added. Now it has been
promoted to an error.
 1.23 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.22 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.21 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.20 15-Jun-2024  rillig branches: 1.20.2;
make: in warnings, move the word "warning" to the front
 1.19 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.18 23-Jun-2023  rillig make: warn about malformed patterns in ':M', ':N' and '.if make(...)'

These patterns shouldn't occur in practice, as their results are tricky
to predict. Generate a warning for now, and maybe an error later.

Reviewed by sjg@.
 1.17 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.16 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.15 10-Apr-2021  rillig make: reduce debug logging and memory allocation for ${:U...}

Expressions of the form ${:U...} are often generated by .for loops.
Since these expressions are not generated knowingly by the make user, do
not fill the debug log with them since that would interrupt the normal
reading flow of the -dv log for nested expressions.
 1.14 06-Apr-2021  rillig make: reduce verbosity of the -dv debug logging for standard cases

The verbosity was already removed from LogBeforeApply, now it is
consistent between LogBeforeApply and LogAfterApply.
 1.13 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.12 05-Apr-2021  rillig make: omit unnecessary details from -dv debug log

When an expression is based on a defined variable, it does not matter
whether the evaluation mode is "eval" or "eval-defined", therefore omit
these details to reduce confusion.
 1.11 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.10 05-Apr-2021  rillig make: clean up debug logging for ':M' and ':N'

Using square brackets as quotes was confusing since patterns can contain
square brackets themselves.

The debug logging for VarMatch was a bit too detailed. Having the
"before" and "after" states is enough for all practically relevant
cases.
 1.9 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.8 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.7 15-Feb-2021  rillig make: rename ExprDefined constants for debug logging
 1.6 02-Feb-2021  rillig make: replace VarExprFlags with VarExprStatus

The combination of !VEF_UNDEF && VEF_DEF was not possible, which made it
rather strange to model this state as a bit set.

The only functional change is the renamed constants in the debug output.

Using ENUM_VALUE_RTTI_2 felt like overengineering since it's harder to
understand than a simple array of names.
 1.5 01-Nov-2020  rillig make(1): add more tests for the variable modifier :M

Despite its popularity and usefulness, the variable modifier :M is
implemented so weirdly that it's not surprising people get confused
about make's parsing and escaping rules.
 1.4 01-Nov-2020  rillig make(1): add test for surprising parsing result of the :M modifier
 1.3 01-Nov-2020  rillig make(1): move test flags to test varmod-match-escape.mk
 1.2 25-Oct-2020  sjg Skip reading .MAKE.DEPENDFILE if set to
"/dev/null" or anything starting with "no".

Ref: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223564
 1.1 16-Aug-2020  rillig make(1): move tests for the :M modifier into separate files

The test for the different escaping has been adjusted to actually show
the different parsing results in the test output. To do this, it had to
get its own file since it needs the -dv debug flag and specialized
post-processing.
 1.20.2.1 02-Aug-2025  perseant Sync with HEAD
 1.20 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.19 28-Jun-2025  rillig make: error out on an ":M" modifier whose pattern ends with backslash

This edge case is not expected to occur intentionally in practice.
 1.18 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.17 09-Jul-2024  rillig make: error out on syntax errors in ':M' and ':N' modifiers

More than a year ago, the warning has been added. Now it has been
promoted to an error.
 1.16 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.15 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.14 15-Jun-2024  rillig branches: 1.14.2;
make: in warnings, move the word "warning" to the front
 1.13 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.12 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.11 02-Nov-2023  rillig make: sync comments with the extracted ParseModifier_Match

No functional change.
 1.10 23-Jun-2023  rillig make: warn about malformed patterns in ':M', ':N' and '.if make(...)'

These patterns shouldn't occur in practice, as their results are tricky
to predict. Generate a warning for now, and maybe an error later.

Reviewed by sjg@.
 1.9 22-Jun-2023  rillig tests/make: demonstrate inconsistency in pattern matching with ranges
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 03-Apr-2021  rillig make: use C99 bool type instead of defining its own

No functional change.
 1.6 01-Feb-2021  rillig make: document necessary tests for Str_Match
 1.5 01-Nov-2020  rillig make(1): add more tests for the variable modifier :M

Despite its popularity and usefulness, the variable modifier :M is
implemented so weirdly that it's not surprising people get confused
about make's parsing and escaping rules.
 1.4 01-Nov-2020  rillig make(1): add test for surprising parsing result of the :M modifier
 1.3 01-Nov-2020  rillig make(1): move test flags to test varmod-match-escape.mk
 1.2 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.1 16-Aug-2020  rillig make(1): move tests for the :M modifier into separate files

The test for the different escaping has been adjusted to actually show
the different parsing results in the test output. To do this, it had to
get its own file since it needs the -dv debug flag and specialized
post-processing.
 1.14.2.1 02-Aug-2025  perseant Sync with HEAD
 1.27 29-Jun-2025  rillig tests/make: test backslash at the end of a line and in the :M modifier

As described in PR bin/46139 by David A. Holland.
 1.26 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.25 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.24 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.23 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.22 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.21 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.20 09-Jul-2024  rillig make: error out on syntax errors in ':M' and ':N' modifiers

More than a year ago, the warning has been added. Now it has been
promoted to an error.
 1.19 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.18 15-Jun-2024  rillig branches: 1.18.2;
make: in warnings, move the word "warning" to the front
 1.17 05-Jun-2024  rillig make: sync comments with reality
 1.16 23-Apr-2024  rillig make: clean up comments, code and tests
 1.15 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.14 17-Dec-2023  rillig tests/make: test the fast code path for ':M' patterns like '*.c'
 1.13 17-Dec-2023  rillig tests/make: add basic tests for the ':M' modifier
 1.12 16-Dec-2023  rillig tests/make: fix line numbers in expected test output for ':M'
 1.11 16-Dec-2023  rillig tests/make: reorganize tests for the ':M' modifier

Add a table of contents. Group the existing tests into sections. Fix
the pattern of the test for the malformed ':M[\' modifier, now in line
283.

Note that the tests for the pattern characters '*?\' are missing.
 1.10 23-Jun-2023  rillig make: warn about malformed patterns in ':M', ':N' and '.if make(...)'

These patterns shouldn't occur in practice, as their results are tricky
to predict. Generate a warning for now, and maybe an error later.

Reviewed by sjg@.
 1.9 22-Jun-2023  rillig tests/make: fix line numbers in test result, since the previous commit
 1.8 22-Jun-2023  rillig make: clean up comments related to pattern matching
 1.7 11-Jun-2022  rillig tests/make: test edge cases in pattern matching
 1.6 11-Jun-2022  rillig tests/make: demonstrate another pathological pattern match
 1.5 03-Mar-2022  rillig tests/make: add more comprehensive tests for ':M' and ':N'
 1.4 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.3 12-Sep-2020  rillig make(1): add test for escaping dollars in the :M variable modifier
 1.2 16-Aug-2020  rillig make(1): move tests for the :M modifier into separate files

The test for the different escaping has been adjusted to actually show
the different parsing results in the test output. To do this, it had to
get its own file since it needs the -dv debug flag and specialized
post-processing.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.18.2.1 02-Aug-2025  perseant Sync with HEAD
 1.32 29-Jun-2025  rillig tests/make: test backslash at the end of a line and in the :M modifier

As described in PR bin/46139 by David A. Holland.
 1.31 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.30 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.29 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.28 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.27 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.26 09-Jul-2024  rillig make: error out on syntax errors in ':M' and ':N' modifiers

More than a year ago, the warning has been added. Now it has been
promoted to an error.
 1.25 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.24 15-Jun-2024  rillig branches: 1.24.2;
make: in warnings, move the word "warning" to the front
 1.23 05-Jun-2024  rillig make: sync comments with reality
 1.22 23-Apr-2024  rillig make: clean up comments, code and tests
 1.21 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.20 17-Dec-2023  rillig tests/make: test the fast code path for ':M' patterns like '*.c'
 1.19 17-Dec-2023  rillig tests/make: add basic tests for the ':M' modifier
 1.18 16-Dec-2023  rillig tests/make: reorganize tests for the ':M' modifier

Add a table of contents. Group the existing tests into sections. Fix
the pattern of the test for the malformed ':M[\' modifier, now in line
283.

Note that the tests for the pattern characters '*?\' are missing.
 1.17 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.16 02-Nov-2023  rillig make: sync comments with the extracted ParseModifier_Match

No functional change.
 1.15 23-Jun-2023  rillig make: warn about malformed patterns in ':M', ':N' and '.if make(...)'

These patterns shouldn't occur in practice, as their results are tricky
to predict. Generate a warning for now, and maybe an error later.

Reviewed by sjg@.
 1.14 22-Jun-2023  rillig make: speed up pattern matching in the ':M' and ':N' modifiers

In the code coverage report, the highest count for Str_Match goes from
5,298,924 down to 79,646.
 1.13 22-Jun-2023  rillig make: clean up comments related to pattern matching
 1.12 24-Aug-2022  rillig make: fix out-of-bounds read when parsing the ':M' modifier

Since at least 2009-01-17, probably already since 2006-02-18, when
modifiers were allowed to be nested expressions.
 1.11 11-Jun-2022  rillig tests/make: test edge cases in pattern matching
 1.10 11-Jun-2022  rillig tests/make: demonstrate another pathological pattern match
 1.9 08-May-2022  rillig tests/make: migrate cond1 test to other, more specific tests

The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
 1.8 27-Mar-2022  rillig make: fix spacing, and a typo in a test
 1.7 03-Mar-2022  rillig tests/make: add more comprehensive tests for ':M' and ':N'
 1.6 15-Nov-2020  rillig make(1): add remarks to var.c and the test varmod-match
 1.5 13-Sep-2020  rillig make(1): fix comments in test for the :M variable modifier

One mistake per sentence is pretty much, I must have been quite
unconcentrated.

The other commits from around that time are fine though.
 1.4 12-Sep-2020  rillig make(1): add test for escaping dollars in the :M variable modifier
 1.3 16-Aug-2020  rillig make(1): move tests for the :M modifier into separate files

The test for the different escaping has been adjusted to actually show
the different parsing results in the test output. To do this, it had to
get its own file since it needs the -dv debug flag and specialized
post-processing.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.24.2.1 02-Aug-2025  perseant Sync with HEAD
 1.16 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.15 12-Jun-2025  rillig make: use a common style for unexpected error messages

In enomem, report the actual error instead of a fixed ENOMEM.
 1.14 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.13 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.12 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.11 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.10 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.9 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.8 20-Apr-2024  rillig branches: 1.8.2;
make: provide more context information for parse/evaluate errors
 1.7 19-Nov-2023  rillig tests/make: cover all code paths for the ':mtime' modifier
 1.6 19-Nov-2023  rillig make: produce more accurate error message for invalid ':mtime' argument
 1.5 19-Nov-2023  rillig tests/make: test non-integer fallback in ':mtime' modifier
 1.4 19-Aug-2023  sjg varmod-mtime.mk: use :localtime for %s

Add a comment to explain why ${%s:L:localtime} should be used to get
a value that matches time(3).
 1.3 17-Aug-2023  rillig make: be strict when parsing the argument of the ':mtime' modifier
 1.2 17-Aug-2023  rillig tests/make: extend tests for the ':mtime' modifier
 1.1 09-May-2023  sjg make: add :mtime to provide mtime of file

The value of the variable is passed to stat(2)
and st_mtime is new value.
An optional arg can be used if stat(2) fails, otherwise
the current time is used.

See varmod-mtime.mk for usage examples.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.17 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.16 12-Jun-2025  rillig make: use a common style for unexpected error messages

In enomem, report the actual error instead of a fixed ENOMEM.
 1.15 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.14 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.13 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.12 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.11 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.10 20-Apr-2024  rillig branches: 1.10.2;
make: provide more context information for parse/evaluate errors
 1.9 17-Dec-2023  rillig tests/make: extend tests for include guards and empty expressions
 1.8 19-Nov-2023  rillig tests/make: cover all code paths for the ':mtime' modifier
 1.7 19-Nov-2023  rillig make: produce more accurate error message for invalid ':mtime' argument
 1.6 19-Nov-2023  rillig tests/make: test non-integer fallback in ':mtime' modifier
 1.5 19-Aug-2023  rillig tests/make: document bug in ':gmtime' with '%s'
 1.4 19-Aug-2023  sjg varmod-mtime.mk: use :localtime for %s

Add a comment to explain why ${%s:L:localtime} should be used to get
a value that matches time(3).
 1.3 17-Aug-2023  rillig make: be strict when parsing the argument of the ':mtime' modifier
 1.2 17-Aug-2023  rillig tests/make: extend tests for the ':mtime' modifier
 1.1 09-May-2023  sjg make: add :mtime to provide mtime of file

The value of the variable is passed to stat(2)
and st_mtime is new value.
An optional arg can be used if stat(2) fails, otherwise
the current time is used.

See varmod-mtime.mk for usage examples.
 1.10.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 26-Feb-2023  rillig tests/make: extend tests for expression modifiers, especially ':N'
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 31-Jul-2021  rillig tests/make: split tests for the variable modifier ':O'

The tests for parse errors are now in varmod-order, which lets the other
tests focus on the desired behavior of the modifiers.
 1.3 30-Jul-2021  rillig make: handle parse errors in ':O' uniformly

Previously, the error handling for the variable modifier ':O' differed
depending on the exact variant and in some cases led to misleading
or missing diagnostics.
 1.2 30-Jul-2021  rillig make: fix typo in manual page, add more tests for the new ':On'
 1.1 30-Jul-2021  sjg Add :On for numeric sort

Reviewed by: christos rillig
 1.8 27-Sep-2022  rillig tests/make: add tests for legacy local variables and sorting
 1.7 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.6 04-Feb-2022  rillig make: use fixed type for comparing numbers using the modifier ':On'

When the modifier ':On' was added on 2021-07-30, there were concerns
that pre-C99 environments would not have the type 'long long', therefore
the type was made configurable, but parsing such numbers was hard-coded
to using strtoll.

To improve compatibility with C90 environments, use 'long' and 'strtol'
in these environments. In C99 environments, use 'long long' and
'strtoll', to account for larger file sizes.

If the flexibility of choosing yet another type for these numbers should
ever arise, it can still be implemented. Until then, reduce the number
of possible build configurations.
 1.5 03-Aug-2021  rillig tests/make: fix test for the variable modifier ':On'

The variable modifier ':On' sorts words numerically. If these words are
not numeric at all, they get assigned the numeric value 0. Internally,
':On' uses qsort for sorting the words. Since qsort is not specified to
use a stable sorting algorithm, the test data must only use words that
either are written in the same way or that are numerically different.

The test varmod-order failed this requirement by trying to numerically
sort a list of non-numeric words. This led to different results on BSD
and Ubuntu, as could be expected.

To fix the tests, distinguish between words and numbers in the tests.
While here, clean up the tests for all variants of the variable modifier
':O'.

Found by sjg on Ubuntu.
 1.4 31-Jul-2021  rillig tests/make: split tests for the variable modifier ':O'

The tests for parse errors are now in varmod-order, which lets the other
tests focus on the desired behavior of the modifiers.
 1.3 30-Jul-2021  rillig make: handle parse errors in ':O' uniformly

Previously, the error handling for the variable modifier ':O' differed
depending on the exact variant and in some cases led to misleading
or missing diagnostics.
 1.2 30-Jul-2021  rillig make: fix typo in manual page, add more tests for the new ':On'
 1.1 30-Jul-2021  sjg Add :On for numeric sort

Reviewed by: christos rillig
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 03-Aug-2021  rillig tests/make: fix test for the variable modifier ':On'

The variable modifier ':On' sorts words numerically. If these words are
not numeric at all, they get assigned the numeric value 0. Internally,
':On' uses qsort for sorting the words. Since qsort is not specified to
use a stable sorting algorithm, the test data must only use words that
either are written in the same way or that are numerically different.

The test varmod-order failed this requirement by trying to numerically
sort a list of non-numeric words. This led to different results on BSD
and Ubuntu, as could be expected.

To fix the tests, distinguish between words and numbers in the tests.
While here, clean up the tests for all variants of the variable modifier
':O'.

Found by sjg on Ubuntu.
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 16-Aug-2020  rillig make(1): move tests for the :O and :Or modifiers into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8 26-Feb-2023  rillig tests/make: extend tests for expression modifiers, especially ':N'
 1.7 03-Aug-2021  rillig tests/make: fix test for the variable modifier ':On'

The variable modifier ':On' sorts words numerically. If these words are
not numeric at all, they get assigned the numeric value 0. Internally,
':On' uses qsort for sorting the words. Since qsort is not specified to
use a stable sorting algorithm, the test data must only use words that
either are written in the same way or that are numerically different.

The test varmod-order failed this requirement by trying to numerically
sort a list of non-numeric words. This led to different results on BSD
and Ubuntu, as could be expected.

To fix the tests, distinguish between words and numbers in the tests.
While here, clean up the tests for all variants of the variable modifier
':O'.

Found by sjg on Ubuntu.
 1.6 09-Nov-2020  rillig make(1): document since when the :Ox modifier is available
 1.5 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.4 27-Sep-2020  rillig make(1): mark test for the :Ox variable modifier as probabilistic

It fails very seldom, but it can.
 1.3 16-Aug-2020  rillig make(1): move tests for the :Ox modifier into separate file

The test has been extended by ensuring that the shuffled words are still
the same. Comparing two shuffled lists is probabilistic, but comparing
their sorted results is not, therefore that's completely sensible to do.

When writing this test, by coincidence I discovered how to generate the
"Undefined variable" error message. Unfortunately, the error message is
wrong since the variable NUMBERS is defined at that point. In summary,
that error message is shown when it shouldn't, and when it should it is
not shown. Still, I'm glad that I finally found it.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 31-Jul-2021  rillig tests/make: split tests for the variable modifier ':O'

The tests for parse errors are now in varmod-order, which lets the other
tests focus on the desired behavior of the modifiers.
 1.2 03-Aug-2021  rillig tests/make: fix test for the variable modifier ':On'

The variable modifier ':On' sorts words numerically. If these words are
not numeric at all, they get assigned the numeric value 0. Internally,
':On' uses qsort for sorting the words. Since qsort is not specified to
use a stable sorting algorithm, the test data must only use words that
either are written in the same way or that are numerically different.

The test varmod-order failed this requirement by trying to numerically
sort a list of non-numeric words. This led to different results on BSD
and Ubuntu, as could be expected.

To fix the tests, distinguish between words and numbers in the tests.
While here, clean up the tests for all variants of the variable modifier
':O'.

Found by sjg on Ubuntu.
 1.1 31-Jul-2021  rillig tests/make: split tests for the variable modifier ':O'

The tests for parse errors are now in varmod-order, which lets the other
tests focus on the desired behavior of the modifiers.
 1.20 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.19 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.18 29-Mar-2025  rillig make: let unknown ":O" modifiers fall back to the ":from=to" modifier

Inspired by https://bugs.freebsd.org/285726, which concerns the ":t"
modifier instead.

This means that future extensions to the ":O" modifier must not contain
a "=" anywhere, otherwise they may break existing code.
 1.17 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.16 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.15 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.14 20-Jul-2024  rillig make: remove wrong error message about an undefined variable
 1.13 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.12 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.11 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.10 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.9 19-Nov-2023  rillig branches: 1.9.2;
make: replace 'variable expression' with 'expression' in diagnostics
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 27-Feb-2023  rillig tests/make: describe the absent fallback for ':O' modifiers more clearly
 1.6 26-Feb-2023  rillig tests/make: extend tests for expression modifiers, especially ':N'
 1.5 03-Aug-2021  rillig tests/make: fix test for the variable modifier ':On'

The variable modifier ':On' sorts words numerically. If these words are
not numeric at all, they get assigned the numeric value 0. Internally,
':On' uses qsort for sorting the words. Since qsort is not specified to
use a stable sorting algorithm, the test data must only use words that
either are written in the same way or that are numerically different.

The test varmod-order failed this requirement by trying to numerically
sort a list of non-numeric words. This led to different results on BSD
and Ubuntu, as could be expected.

To fix the tests, distinguish between words and numbers in the tests.
While here, clean up the tests for all variants of the variable modifier
':O'.

Found by sjg on Ubuntu.
 1.4 31-Jul-2021  rillig tests/make: split tests for the variable modifier ':O'

The tests for parse errors are now in varmod-order, which lets the other
tests focus on the desired behavior of the modifiers.
 1.3 23-Feb-2021  rillig make: improve error message for bad modifier in variable expression

The improvement is especially noteable for variable expressions based on
the empty variable, see moderrs.exp:103.
 1.2 16-Aug-2020  rillig make(1): move tests for the :Ox modifier into separate file

The test has been extended by ensuring that the shuffled words are still
the same. Comparing two shuffled lists is probabilistic, but comparing
their sorted results is not, therefore that's completely sensible to do.

When writing this test, by coincidence I discovered how to generate the
"Undefined variable" error message. Unfortunately, the error message is
wrong since the variable NUMBERS is defined at that point. In summary,
that error message is shown when it shouldn't, and when it should it is
not shown. Still, I'm glad that I finally found it.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.20 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.19 29-Mar-2025  rillig make: let unknown ":O" modifiers fall back to the ":from=to" modifier

Inspired by https://bugs.freebsd.org/285726, which concerns the ":t"
modifier instead.

This means that future extensions to the ":O" modifier must not contain
a "=" anywhere, otherwise they may break existing code.
 1.18 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.17 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.16 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.15 20-Jul-2024  rillig make: remove wrong error message about an undefined variable
 1.14 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.13 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.12 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.11 01-Jun-2023  rillig branches: 1.11.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.10 27-Feb-2023  rillig tests/make: describe the absent fallback for ':O' modifiers more clearly
 1.9 26-Feb-2023  rillig tests/make: extend tests for expression modifiers, especially ':N'
 1.8 15-Jan-2022  rillig tests/make: ensure that the 'expect' comments in tests are correct

Based on tests/usr.bin/xlint/check-expect.lua.

For now, this extra check needs to be run manually.
 1.7 03-Aug-2021  rillig tests/make: fix test for the variable modifier ':On'

The variable modifier ':On' sorts words numerically. If these words are
not numeric at all, they get assigned the numeric value 0. Internally,
':On' uses qsort for sorting the words. Since qsort is not specified to
use a stable sorting algorithm, the test data must only use words that
either are written in the same way or that are numerically different.

The test varmod-order failed this requirement by trying to numerically
sort a list of non-numeric words. This led to different results on BSD
and Ubuntu, as could be expected.

To fix the tests, distinguish between words and numbers in the tests.
While here, clean up the tests for all variants of the variable modifier
':O'.

Found by sjg on Ubuntu.
 1.6 31-Jul-2021  rillig tests/make: split tests for the variable modifier ':O'

The tests for parse errors are now in varmod-order, which lets the other
tests focus on the desired behavior of the modifiers.
 1.5 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.4 16-Aug-2020  rillig make(1): move tests for the :Ox modifier into separate file

The test has been extended by ensuring that the shuffled words are still
the same. Comparing two shuffled lists is probabilistic, but comparing
their sorted results is not, therefore that's completely sensible to do.

When writing this test, by coincidence I discovered how to generate the
"Undefined variable" error message. Unfortunately, the error message is
wrong since the variable NUMBERS is defined at that point. In summary,
that error message is shown when it shouldn't, and when it should it is
not shown. Still, I'm glad that I finally found it.
 1.3 16-Aug-2020  rillig make(1): move tests for the :O and :Or modifiers into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.11.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 23-Aug-2020  rillig make(1): add test for the :P variable modifier
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 10-May-2023  rillig tests/make: clean up comments in tests
 1.3 23-Aug-2020  rillig make(1): add test for the :P variable modifier
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 08-May-2022  rillig tests/make: explain that assignments ignore leading spaces
 1.2 22-Jan-2022  rillig tests/make: add a few more tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 08-May-2022  rillig tests/make: explain that assignments ignore leading spaces
 1.3 22-Jan-2022  rillig tests/make: add a few more tests
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 29-Oct-2020  rillig make(1): add test for the :Q modifier
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.22 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.21 04-Apr-2025  rillig make: fix error message for undefined variable in conditional

Previously, only ${UNDEF} had the proper error message, while
${UNDEF:M*} still produced the wrong "Malformed conditional".
 1.20 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.19 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.18 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.17 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.16 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.15 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.14 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.13 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.12 20-Apr-2024  rillig branches: 1.12.2;
make: provide more context information for parse/evaluate errors
 1.11 17-Dec-2023  rillig tests/make: extend tests for include guards and empty expressions
 1.10 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.9 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.8 23-Feb-2021  rillig make: add context information to error message about ':range' modifier
 1.7 21-Dec-2020  rillig make(1): remove excess newline from parse errors (since 2020-11-01)

For the modifiers :gmtime and :localtime, the excess newline had been
added in var.c 1.631 from 2020-10-31 21:40:20.

For the modifiers :range and :ts, the excess newline had been added in
var.c 1.635 from 2020-11-01 14:36:25.
 1.6 20-Dec-2020  rillig make(1): error out on unknown variable modifiers at parse time

Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such. This "error message"
also did not influence the exit status in the default mode but only in
-dL mode. The error message also didn't include any line number
information and was thus rude.
 1.5 01-Nov-2020  rillig make(1): treat malformed :range, :ts and :[...] as errors

Before, integer overflow in the :[1..2] modifier had not been detected,
and the actual behavior varied between ILP64 and LP64I32 machines.

Before, the :ts modifier accepted character literals like \012345 and
\x1F600, which don't fit in a single character and were thus truncated.

Before, the :range modifier issued an "Unknown modifier" error message
for :range=x, which was not quite correct. The error message in this
case is now "Invalid number".
 1.4 01-Nov-2020  rillig make(1): add tests for the variable modifiers :[words] and :range
 1.3 01-Nov-2020  rillig make(1): add more tests for the variable modifier :range, edge cases
 1.2 23-Aug-2020  rillig make(1): move tests for :hash :range :localtime into separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.12.2.1 02-Aug-2025  perseant Sync with HEAD
 1.19 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.18 04-Apr-2025  rillig make: fix error message for undefined variable in conditional

Previously, only ${UNDEF} had the proper error message, while
${UNDEF:M*} still produced the wrong "Malformed conditional".
 1.17 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.16 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.15 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.14 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.13 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.12 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.11 20-Apr-2024  rillig branches: 1.11.2;
make: provide more context information for parse/evaluate errors
 1.10 17-Dec-2023  rillig tests/make: extend tests for include guards and empty expressions
 1.9 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 01-Nov-2020  rillig make(1): treat malformed :range, :ts and :[...] as errors

Before, integer overflow in the :[1..2] modifier had not been detected,
and the actual behavior varied between ILP64 and LP64I32 machines.

Before, the :ts modifier accepted character literals like \012345 and
\x1F600, which don't fit in a single character and were thus truncated.

Before, the :range modifier issued an "Unknown modifier" error message
for :range=x, which was not quite correct. The error message in this
case is now "Invalid number".
 1.6 01-Nov-2020  rillig make(1): add tests for the variable modifiers :[words] and :range
 1.5 01-Nov-2020  rillig make(1): add more tests for the variable modifier :range, edge cases
 1.4 27-Sep-2020  rillig make(1): add test cases for the :range variable modifier
 1.3 23-Aug-2020  rillig make(1): move tests for :hash :range :localtime into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.11.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 14-Mar-2021  rillig tests/make: convert test for ':_' modifier to parse time
 1.2 23-Aug-2020  rillig make(1): move tests for the :tu and :_ modifiers into separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.9 09-Feb-2023  rillig tests/make: remove debugging directive from test for ':_'
 1.8 09-Feb-2023  rillig tests/make: extend and explain test for the ':_' modifier
 1.7 09-Feb-2023  sjg make: ApplyModifier_Remember always use SCOPE_GLOBAL

Conditionals evaluate vars with SCOPE_CMDLINE, if :_
is used within a conditional expression and is thus
set in SCOPE_CMDLINE, it breaks any use of :_ in SCOPE_GLOBAL.

The simplest solution is for :_ to always use SCOPE_GLOBAL

Reviewed by: rillig
 1.6 14-Mar-2021  rillig make: do not expand the variable name in the ':_' modifier

This edge case had been so obscure that even discovering this takes
quite some time and requires reading the source code of make.

The manual page doesn't document whether the variable name is expanded
or not, it doesn't even give an example. When this obscure modifier was
initially added in var.c 1.210 from 2017-01-30, Var_Set always expanded
the variable name once, and there was no way around it. Therefore this
expansion has probably been unintentional.
 1.5 14-Mar-2021  rillig tests/make: demonstrate unintended edge case for the ':_' modifier
 1.4 14-Mar-2021  rillig tests/make: convert test for ':_' modifier to parse time
 1.3 23-Aug-2020  rillig make(1): move tests for the :tu and :_ modifiers into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 05-Dec-2021  rillig tests/make: split test cases for ':R' into separate tests

This allows to comment or explain individual test cases.

Remove duplicates.
 1.3 20-Dec-2020  rillig make(1): add tests for variable modifiers on trailing slashes
 1.2 23-Aug-2020  rillig make(1): move tests for :H :E :R :T into separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 05-Dec-2021  rillig tests/make: split test cases for ':R' into separate tests

This allows to comment or explain individual test cases.

Remove duplicates.
 1.4 20-Dec-2020  rillig make(1): add tests for variable modifiers on trailing slashes
 1.3 23-Aug-2020  rillig make(1): move tests for :H :E :R :T into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8 30-Mar-2025  rillig make: fix error message for invalid ":[...]" modifier

The unparsed value of the modifier argument can already be seen in the
stack trace, but the modifier argument may contain expressions and the
expanded value of these expressions was hidden up to now. See the EMPTY
test at the bottom of varmod-select-words.mk for details.
 1.7 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.6 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.5 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.4 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.3 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.2 23-Jan-2022  rillig branches: 1.2.4;
tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2.4.1 02-Aug-2025  perseant Sync with HEAD
 1.7 30-Mar-2025  rillig make: fix error message for invalid ":[...]" modifier

The unparsed value of the modifier argument can already be seen in the
stack trace, but the modifier argument may contain expressions and the
expanded value of these expressions was hidden up to now. See the EMPTY
test at the bottom of varmod-select-words.mk for details.
 1.6 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.5 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.4 23-Jan-2022  rillig branches: 1.4.4;
tests/make: extend test suite, move old tests to 2020 scheme

The tests from envfirst.mk are now in opt-env.mk.
The tests from modword.mk are now in varmod-select-words.mk.
 1.3 05-Dec-2021  rillig make: save a memory allocation in the modifier ':[...]'

No functional change.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.4.1 02-Aug-2025  perseant Sync with HEAD
 1.10 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.9 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.8 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.7 30-Jun-2024  rillig make: add detailed exit status to message for failed sub-commands

Several commands communicate via the exit status and not only
distinguish between zero and non-zero, so make this information
available to ease investigations.

The command "false" is not guaranteed to exit with a consistent status,
so use "(exit 13)" instead in the tests, to keep these tests portable
across different operating systems. The exit status 127 is required for
a shell that cannot find a command, so keep that one.
 1.6 30-Jun-2024  rillig make: add more context to "returned non-zero status" message

Previously, this message was an "error" but had no influence on the exit
status, so make it a warning instead. In the seldom used -W mode that
treats warnings as errors, this change influences the exit status.
 1.5 26-Mar-2022  rillig branches: 1.5.4;
make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.4 10-Jan-2022  rillig make: add debug logging for capturing the output of external commands

This applies to all 4 situations in which the output of an external
command is used for modifying a variable or an expression:

* the assignment operator '!='
* the assignment modifier '::!='
* the SUN shell modifier ':sh'
* the other shell modifier ':!cmd!'

Previously, only the shell modifier ':!cmd!' had debug logging.

Suggested by Christoph Badura.
 1.3 17-Nov-2020  rillig make(1): fix error message of failed :!cmd! modifier (since 2000-04-29)
 1.2 17-Nov-2020  rillig make(1): document 20-year-old bug in the :!cmd! modifier
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.4.2 02-Aug-2025  perseant Sync with HEAD
 1.5.4.1 01-Jul-2024  perseant Sync with HEAD.
 1.11 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.10 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.9 30-Jun-2024  rillig make: add detailed exit status to message for failed sub-commands

Several commands communicate via the exit status and not only
distinguish between zero and non-zero, so make this information
available to ease investigations.

The command "false" is not guaranteed to exit with a consistent status,
so use "(exit 13)" instead in the tests, to keep these tests portable
across different operating systems. The exit status 127 is required for
a shell that cannot find a command, so keep that one.
 1.8 30-Jun-2024  rillig make: add more context to "returned non-zero status" message

Previously, this message was an "error" but had no influence on the exit
status, so make it a warning instead. In the seldom used -W mode that
treats warnings as errors, this change influences the exit status.
 1.7 10-Jan-2022  rillig branches: 1.7.4;
make: add debug logging for capturing the output of external commands

This applies to all 4 situations in which the output of an external
command is used for modifying a variable or an expression:

* the assignment operator '!='
* the assignment modifier '::!='
* the SUN shell modifier ':sh'
* the other shell modifier ':!cmd!'

Previously, only the shell modifier ':!cmd!' had debug logging.

Suggested by Christoph Badura.
 1.6 14-Feb-2021  rillig make: add test for the variable modifier ':sh'
 1.5 17-Nov-2020  rillig make(1): fix error message of failed :!cmd! modifier (since 2000-04-29)
 1.4 17-Nov-2020  rillig make(1): document 20-year-old bug in the :!cmd! modifier
 1.3 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.4.2 02-Aug-2025  perseant Sync with HEAD
 1.7.4.1 01-Jul-2024  perseant Sync with HEAD.
 1.14 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.13 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.12 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.11 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.10 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.9 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.8 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.7 20-Apr-2024  rillig branches: 1.7.2;
make: provide more context information for parse/evaluate errors
 1.6 21-Jun-2021  rillig tests/make: move and extend test for unmatched '\1' in ':C'

This test lived together with a few unrelated tests in moderrs.mk, it is
better placed in varmod-subst-regex.mk though.

While here, extend, document and explain the test since its purpose was
not obvious from reading the code alone.
 1.5 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.4 05-Dec-2020  rillig make(1): add test for unknown modifier in :C modifier replacement
 1.3 28-Aug-2020  rillig make(1): fix manual page about the modifiers of the :C modifier
 1.2 16-Aug-2020  rillig make(1): move tests for :S, :C, :@ from modmisc to their separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.2 02-Aug-2025  perseant Sync with HEAD
 1.7.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.12 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.11 18-Dec-2023  rillig branches: 1.11.2;
tests/make: fix typo in test for ':C' modifier

The expression ${U:...} was always undefined, as there was no variable
named 'U'; the intended form was ${:U:...}. Due to this typo, the
comments in the tests for the ':S' and the ':C' modifier contradicted
each other.
 1.10 17-Dec-2023  rillig tests/make: extend tests for include guards and empty expressions
 1.9 10-Dec-2023  rillig make: fix crash in ':C' modifier on an empty expression

Since var.c 1.982 from 2021-12-13.
 1.8 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.7 21-Jun-2021  rillig tests/make: move and extend test for unmatched '\1' in ':C'

This test lived together with a few unrelated tests in moderrs.mk, it is
better placed in varmod-subst-regex.mk though.

While here, extend, document and explain the test since its purpose was
not obvious from reading the code alone.
 1.6 05-Dec-2020  rillig make(1): add test for unknown modifier in :C modifier replacement
 1.5 31-Oct-2020  rillig make(1): add tests for edge cases in the :C variable modifier
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 28-Aug-2020  rillig make(1): fix manual page about the modifiers of the :C modifier
 1.2 16-Aug-2020  rillig make(1): move tests for :S, :C, :@ from modmisc to their separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.11.2.1 02-Aug-2025  perseant Sync with HEAD
 1.11 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.10 29-Mar-2025  rillig make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.
 1.9 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.8 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.7 09-Jul-2024  rillig make: error out on parse/evaluation errors in shell commands

The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.

Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
 1.6 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.5 20-Apr-2024  rillig branches: 1.5.2;
make: provide more context information for parse/evaluate errors
 1.4 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.3 03-Nov-2020  rillig make(1): add all printable ASCII characters to the varmod-subst test

I must have missed some of them when I originally wrote the test. Not
sure how that happened. While here, use the official Unicode names.
 1.2 16-Aug-2020  rillig make(1): move tests for :S, :C, :@ from modmisc to their separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.17 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.16 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.15 20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.14 18-Dec-2023  rillig branches: 1.14.2;
tests/make: fix typo in test for ':C' modifier

The expression ${U:...} was always undefined, as there was no variable
named 'U'; the intended form was ${:U:...}. Due to this typo, the
comments in the tests for the ':S' and the ':C' modifier contradicted
each other.
 1.13 17-Dec-2023  rillig tests/make: extend tests for include guards and empty expressions
 1.12 16-Jun-2023  rillig tests/make: clean up tests for the ':M' and ':S' modifiers
 1.11 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.10 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.9 06-Sep-2021  rillig tests/make: test modifier ':S' with replacement '&'

Before 2020-08-30, OpenBSD make incorrectly copied the anchors '^' and
'$' to the replacement string. Just guard against this possible bug.
 1.8 14-May-2021  rillig tests/make: show that in ':S', '.' and '*' are ordinary characters
 1.7 15-Nov-2020  rillig branches: 1.7.2;
make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.6 03-Nov-2020  rillig make(1): in tests, replace "dollar character" with "dollar sign"
 1.5 03-Nov-2020  rillig make(1): add all printable ASCII characters to the varmod-subst test

I must have missed some of them when I originally wrote the test. Not
sure how that happened. While here, use the official Unicode names.
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 19-Aug-2020  rillig make(1): fix a few inconsistencies in the manual page
 1.2 16-Aug-2020  rillig make(1): move tests for :S, :C, :@ from modmisc to their separate tests
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7.2.1 31-May-2021  cjep sync with head
 1.14.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.6 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.5 30-Jun-2024  rillig make: add detailed exit status to message for failed sub-commands

Several commands communicate via the exit status and not only
distinguish between zero and non-zero, so make this information
available to ease investigations.

The command "false" is not guaranteed to exit with a consistent status,
so use "(exit 13)" instead in the tests, to keep these tests portable
across different operating systems. The exit status 127 is required for
a shell that cannot find a command, so keep that one.
 1.4 30-Jun-2024  rillig make: add more context to "returned non-zero status" message

Previously, this message was an "error" but had no influence on the exit
status, so make it a warning instead. In the seldom used -W mode that
treats warnings as errors, this change influences the exit status.
 1.3 26-Mar-2022  rillig branches: 1.3.4;
make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.2 10-Jan-2022  rillig make: add debug logging for capturing the output of external commands

This applies to all 4 situations in which the output of an external
command is used for modifying a variable or an expression:

* the assignment operator '!='
* the assignment modifier '::!='
* the SUN shell modifier ':sh'
* the other shell modifier ':!cmd!'

Previously, only the shell modifier ':!cmd!' had debug logging.

Suggested by Christoph Badura.
 1.1 14-Feb-2021  rillig make: add test for the variable modifier ':sh'
 1.3.4.2 02-Aug-2025  perseant Sync with HEAD
 1.3.4.1 01-Jul-2024  perseant Sync with HEAD.
 1.6 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.5 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.4 30-Jun-2024  rillig make: add detailed exit status to message for failed sub-commands

Several commands communicate via the exit status and not only
distinguish between zero and non-zero, so make this information
available to ease investigations.

The command "false" is not guaranteed to exit with a consistent status,
so use "(exit 13)" instead in the tests, to keep these tests portable
across different operating systems. The exit status 127 is required for
a shell that cannot find a command, so keep that one.
 1.3 30-Jun-2024  rillig make: add more context to "returned non-zero status" message

Previously, this message was an "error" but had no influence on the exit
status, so make it a warning instead. In the seldom used -W mode that
treats warnings as errors, this change influences the exit status.
 1.2 10-Jan-2022  rillig branches: 1.2.4;
make: add debug logging for capturing the output of external commands

This applies to all 4 situations in which the output of an external
command is used for modifying a variable or an expression:

* the assignment operator '!='
* the assignment modifier '::!='
* the SUN shell modifier ':sh'
* the other shell modifier ':!cmd!'

Previously, only the shell modifier ':!cmd!' had debug logging.

Suggested by Christoph Badura.
 1.1 14-Feb-2021  rillig make: add test for the variable modifier ':sh'
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 01-Jul-2024  perseant Sync with HEAD.
 1.19 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.18 29-Mar-2025  rillig make: add more details to error message about unfinished modifier

These details allow to quickly see the place where the syntax error is,
based on the surrounding lines from the stack trace.
 1.17 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.16 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.15 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.14 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.13 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.12 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.11 01-Jun-2024  rillig branches: 1.11.2;
tests/make: test more modifiers and special variables
 1.10 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.9 12-Apr-2021  rillig tests/make: fix test for modifier ':from=to'

I had forgotten to remove the single quotes, to produce a really empty
word. Plus I had forgotten the modifier ':Q' for the result, which
meant that the single quotes did not show up in the output.
 1.8 12-Apr-2021  rillig tests/make: add table test for the modifier ':from=to'

Just to prevent any accidental change in the upcoming refactoring to
reduce memory allocation in ApplyModifier_SysV.
 1.7 23-Feb-2021  rillig make: add quotes around variable name in an error message
 1.6 05-Dec-2020  rillig make(1): improve explanation of tests for the SysV modifier
 1.5 01-Nov-2020  rillig make(1): add another test case for the SysV modifier

The "special case" in ApplyModifier_SysV looks redundant since in
SysVMatch, the empty word does not match anything.
 1.4 01-Nov-2020  rillig make(1): add tests for parsing the SysV variable modifier
 1.3 06-Oct-2020  rillig make(1): migrate SysV modifier test to use the preprocessor

When both the expected and the actual expression are written in the same
line of the same file, it is easier to compare them and to document
anything interesting. The exp file doesn't provide any space for
comments or explanations.
 1.2 23-Aug-2020  rillig make(1): move some of the SysV modifier tests into another file
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.11.2.2 02-Aug-2025  perseant Sync with HEAD
 1.11.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.24 30-Mar-2025  rillig make: let the ":t" modifiers fall back to the ":from=to" modifier

Suggested by https://bugs.freebsd.org/285726.

This means that the ":t" modifiers cannot have future extensions that
include a "=", as that may break existing code.
 1.23 29-Mar-2025  rillig make: add more details to error message about unfinished modifier

These details allow to quickly see the place where the syntax error is,
based on the surrounding lines from the stack trace.
 1.22 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.21 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.20 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.19 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.18 30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.17 01-Jun-2024  rillig branches: 1.17.2;
tests/make: test more modifiers and special variables
 1.16 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.15 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.14 12-Apr-2021  rillig tests/make: fix test for modifier ':from=to'

I had forgotten to remove the single quotes, to produce a really empty
word. Plus I had forgotten the modifier ':Q' for the result, which
meant that the single quotes did not show up in the output.
 1.13 12-Apr-2021  rillig tests/make: add table test for the modifier ':from=to'

Just to prevent any accidental change in the upcoming refactoring to
reduce memory allocation in ApplyModifier_SysV.
 1.12 05-Dec-2020  rillig make(1): improve explanation of tests for the SysV modifier
 1.11 01-Nov-2020  rillig make(1): add another test case for the SysV modifier

The "special case" in ApplyModifier_SysV looks redundant since in
SysVMatch, the empty word does not match anything.
 1.10 01-Nov-2020  rillig make(1): add tests for parsing the SysV variable modifier
 1.9 31-Oct-2020  rillig make(1): merge the SysV modifier tests into varmod-sysv
 1.8 31-Oct-2020  rillig make(1): add tutorial for the :from=to variable modifier
 1.7 31-Oct-2020  rillig make(1): remove redundant code branch in SysVMatch

The general code path of parsing :from=to achieves the same effect.
 1.6 31-Oct-2020  rillig make(1): explain tests for the SysV variable modifier
 1.5 06-Oct-2020  rillig make(1): add test for double expansion in SySV modifier
 1.4 06-Oct-2020  rillig make(1): migrate SysV modifier test to use the preprocessor

When both the expected and the actual expression are written in the same
line of the same file, it is easier to compare them and to document
anything interesting. The exp file doesn't provide any space for
comments or explanations.
 1.3 23-Aug-2020  rillig make(1): move some of the SysV modifier tests into another file
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.17.2.2 02-Aug-2025  perseant Sync with HEAD
 1.17.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.3 20-Dec-2020  rillig make(1): add tests for variable modifiers on trailing slashes
 1.2 23-Aug-2020  rillig make(1): move tests for :H :E :R :T into separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 01-Jun-2024  rillig tests/make: test more modifiers and special variables
 1.4 20-Dec-2020  rillig make(1): add tests for variable modifiers on trailing slashes
 1.3 23-Aug-2020  rillig make(1): move tests for :H :E :R :T into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 01-Jun-2023  rillig branches: 1.5.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 15-Nov-2020  rillig make(1): fix test varmod-to-abs with USE_ABSOLUTE_TESTNAMES=yes

When running the tests with specifying absolute filenames, it doesn't
make sense to prefix the MAKEFILE with "./", which made the tests fail on
FreeBSD.
 1.3 14-Nov-2020  rillig make(1): switch cache for realpath from GNode to HashTable

An unintended side effect from the GNode implementation was that the
variable modifier :tA and the other places where cached_realpath are
used could be affected by setting a variable in the global scope,
thereby "redirecting" absolute paths to completely unrelated but
existing paths.

Another unintended side effect was that filenames containing a dollar
sign would not be resolved correctly since the dollar sign would be
expanded as a variable expression by Var_Set.

While here, the debugging output for the realpath cache has been
adjusted to the standard behavior. Previously, when a new entry was
added to the cache, this was logged for the module VAR, as a side effect
of calling Var_Set, but only if the preprocessor macro
DEBUG_REALPATH_CACHE was defined at compilation time. When relative
paths were purged from the cache because the current directory changed
and logging for the DIR module was active, the log output went directly
to stderr instead of the usual opts.debug_file. This deviation from the
standard behavior was probably not intended as well.

All logging concerning the realpath cache now goes into the standard
debug log file and is controlled by the -dd option, not -dv.
 1.2 14-Nov-2020  rillig make(1): add test for undocumented path-to-abspath mapping for :tA
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 15-Nov-2020  rillig make(1): fix test varmod-to-abs with USE_ABSOLUTE_TESTNAMES=yes

When running the tests with specifying absolute filenames, it doesn't
make sense to prefix the MAKEFILE with "./", which made the tests fail on
FreeBSD.
 1.4 14-Nov-2020  rillig make(1): switch cache for realpath from GNode to HashTable

An unintended side effect from the GNode implementation was that the
variable modifier :tA and the other places where cached_realpath are
used could be affected by setting a variable in the global scope,
thereby "redirecting" absolute paths to completely unrelated but
existing paths.

Another unintended side effect was that filenames containing a dollar
sign would not be resolved correctly since the dollar sign would be
expanded as a variable expression by Var_Set.

While here, the debugging output for the realpath cache has been
adjusted to the standard behavior. Previously, when a new entry was
added to the cache, this was logged for the module VAR, as a side effect
of calling Var_Set, but only if the preprocessor macro
DEBUG_REALPATH_CACHE was defined at compilation time. When relative
paths were purged from the cache because the current directory changed
and logging for the DIR module was active, the log output went directly
to stderr instead of the usual opts.debug_file. This deviation from the
standard behavior was probably not intended as well.

All logging concerning the realpath cache now goes into the standard
debug log file and is controlled by the -dd option, not -dv.
 1.3 14-Nov-2020  rillig make(1): add test for undocumented path-to-abspath mapping for :tA
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 29-Nov-2022  rillig tests/make: document that the ':tl' modifier does not split words
 1.5 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 28-Aug-2020  rillig make(1): add tests for :tl and :tu modifiers
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 20-Dec-2020  rillig make(1): add tests for :tW and :tw modifiers
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 20-Dec-2020  rillig make(1): add tests for :tW and :tw modifiers
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.21 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.20 30-Mar-2025  rillig make: let the ":t" modifiers fall back to the ":from=to" modifier

Suggested by https://bugs.freebsd.org/285726.

This means that the ":t" modifiers cannot have future extensions that
include a "=", as that may break existing code.
 1.19 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.18 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.17 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.16 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.15 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.14 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.13 01-Jun-2024  rillig branches: 1.13.2;
tests/make: test more modifiers and special variables
 1.12 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.11 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.10 23-Jan-2022  rillig tests/make: add more tests for the modifier ':ts'
 1.9 23-Jan-2022  rillig tests/make: migrate modts to varmod-to-separator and explain
 1.8 09-Dec-2021  rillig make: in parse errors, mark whitespace more clearly

This prevents any trailing whitespace from going unnoticed. It also
marks leading whitespace more clearly, as in the examples with the time
value " 1".
 1.7 23-Feb-2021  rillig make: improve error message for bad modifier in variable expression

The improvement is especially noteable for variable expressions based on
the empty variable, see moderrs.exp:103.
 1.6 21-Dec-2020  rillig make(1): remove excess newline from parse errors (since 2020-11-01)

For the modifiers :gmtime and :localtime, the excess newline had been
added in var.c 1.631 from 2020-10-31 21:40:20.

For the modifiers :range and :ts, the excess newline had been added in
var.c 1.635 from 2020-11-01 14:36:25.
 1.5 01-Nov-2020  rillig make(1): treat malformed :range, :ts and :[...] as errors

Before, integer overflow in the :[1..2] modifier had not been detected,
and the actual behavior varied between ILP64 and LP64I32 machines.

Before, the :ts modifier accepted character literals like \012345 and
\x1F600, which don't fit in a single character and were thus truncated.

Before, the :range modifier issued an "Unknown modifier" error message
for :range=x, which was not quite correct. The error message in this
case is now "Invalid number".
 1.4 01-Nov-2020  rillig make(1): add tests for parsing errors in the :ts variable modifier
 1.3 01-Nov-2020  rillig make(1): add test for out-of-bounds separator in variable modifier :ts
 1.2 31-Aug-2020  rillig make(1): move some of the :ts tests into a separate file

The successful cases can be easily tested in the .if conditions. Around
these conditions, there is enough space for explaining the test cases
and their purpose.

The failure cases have been left in the file for now since they still
produce unwanted characters in the output. These characters are not
produced when the parse error occurs in a conditional.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.23 30-Mar-2025  rillig make: let the ":t" modifiers fall back to the ":from=to" modifier

Suggested by https://bugs.freebsd.org/285726.

This means that the ":t" modifiers cannot have future extensions that
include a "=", as that may break existing code.
 1.22 29-Mar-2025  rillig tests/make: remove copy-and-paste errors from warning messages

Several of the warnings didn't match what they actually tested, so
remove them all to prevent further disagreements.
 1.21 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.20 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.19 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.18 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.17 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.16 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.15 01-Jun-2024  rillig branches: 1.15.2;
tests/make: test more modifiers and special variables
 1.14 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.13 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.12 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.11 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.10 23-Jan-2022  rillig tests/make: add a few more tests
 1.9 23-Jan-2022  rillig tests/make: add more tests for the modifier ':ts'
 1.8 23-Jan-2022  rillig tests/make: migrate modts to varmod-to-separator and explain
 1.7 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.6 01-Nov-2020  rillig make(1): treat malformed :range, :ts and :[...] as errors

Before, integer overflow in the :[1..2] modifier had not been detected,
and the actual behavior varied between ILP64 and LP64I32 machines.

Before, the :ts modifier accepted character literals like \012345 and
\x1F600, which don't fit in a single character and were thus truncated.

Before, the :range modifier issued an "Unknown modifier" error message
for :range=x, which was not quite correct. The error message in this
case is now "Invalid number".
 1.5 01-Nov-2020  rillig make(1): add tests for parsing errors in the :ts variable modifier
 1.4 01-Nov-2020  rillig make(1): add test for out-of-bounds separator in variable modifier :ts
 1.3 31-Aug-2020  rillig make(1): move some of the :ts tests into a separate file

The successful cases can be easily tested in the .if conditions. Around
these conditions, there is enough space for explaining the test cases
and their purpose.

The failure cases have been left in the file for now since they still
produce unwanted characters in the output. These characters are not
produced when the parse error occurs in a conditional.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.15.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 01-Jul-2024  sjg branches: 1.1.4;
make: add :tc to capitalize first letter of each word

This is very hard to do without :tc

Reviewed by: rillig
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 01-Jul-2024  perseant file varmod-to-title.exp was added on branch perseant-exfatfs on 2025-08-02 05:58:39 +0000
 1.1 01-Jul-2024  sjg branches: 1.1.4;
make: add :tc to capitalize first letter of each word

This is very hard to do without :tc

Reviewed by: rillig
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 01-Jul-2024  perseant file varmod-to-title.mk was added on branch perseant-exfatfs on 2025-08-02 05:58:40 +0000
 1.2 23-Aug-2020  rillig make(1): move tests for the :tu and :_ modifiers into separate files
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.4 28-Aug-2020  rillig make(1): add tests for :tl and :tu modifiers
 1.3 23-Aug-2020  rillig make(1): move tests for the :tu and :_ modifiers into separate files
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.11 03-Jun-2024  sjg Note that varmod-undefined depends on .MAKE.SAVE_DOLLARS=yes
 1.10 02-Jun-2024  rillig tests/make: test more details of the :U and :D modifiers
 1.9 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.8 06-Aug-2022  rillig tests/make: demonstrate bug in parsing of modifier parts

In the modifier ':S,from,to,', parsing the two parts 'from' and 'to' of
the modifier differs depending on whether the expression is actually
evaluated or merely parsed. This not only applies to the ':S' modifier,
but also to ':C', ':@var@body@', ':!cmd!', ':[...]', ':?:', '::=' and
':from=to'.
 1.7 15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.6 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.5 12-Sep-2020  rillig make(1): add tests for combining the :D and :U variable modifiers
 1.4 03-Sep-2020  rillig make(1): add tests for the :D and :U modifiers

This prepares a refactoring for ApplyModifier_Defined.
 1.3 23-Aug-2020  rillig make(1): add test for :U modifier
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 31-Aug-2020  rillig make(1): fix the :u modifier, which was broken for almost a day

Big thanks go to sjg, who discovered the bug and did the main work to
track it down.

In the unit tests for the :u modifier from the previous commit, I had
forgotten to actually add the :u modifier at the end. I added it now
and also added a few other tests. It's better to have a few more tests
than too few.
 1.2 31-Aug-2020  rillig make(1): add test for the currently broken :u variable modifier

The :u modifier had been broken in var.c 1.479 from 2020.08.30.19.56.02.
The code that implements the :u modifier was well-covered in the unit
tests, except for the single line that actually deals with adjacent
duplicate words.

The "refactoring" commit that replaced brk_string with Str_Words had not
taken into account that the number of words (in ac) had to be passed to
WordList_JoinFree. Instead, the number of words was always preserved,
and the words at the end were therefore duplicated in the result.

The fix for this bug will be in the follow-up commit.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 05-Dec-2021  rillig tests/make: replace ':U' with ':L' in test for ':u'

In expressions using ':L', the value of the variable is delimited by
'{', which makes it easier to recognize it visually, as opposed to being
delimited by 'U'.
 1.5 30-May-2021  rillig tests/make: test whitespace normalization for modifier ':u'
 1.4 31-Aug-2020  rillig branches: 1.4.2;
make(1): fix the :u modifier, which was broken for almost a day

Big thanks go to sjg, who discovered the bug and did the main work to
track it down.

In the unit tests for the :u modifier from the previous commit, I had
forgotten to actually add the :u modifier at the end. I added it now
and also added a few other tests. It's better to have a few more tests
than too few.
 1.3 31-Aug-2020  rillig make(1): add test for the currently broken :u variable modifier

The :u modifier had been broken in var.c 1.479 from 2020.08.30.19.56.02.
The code that implements the :u modifier was well-covered in the unit
tests, except for the single line that actually deals with adjacent
duplicate words.

The "refactoring" commit that replaced brk_string with Str_Words had not
taken into account that the number of words (in ac) had to be passed to
WordList_JoinFree. Instead, the number of words was always preserved,
and the words at the end were therefore duplicated in the result.

The fix for this bug will be in the follow-up commit.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4.2.1 31-May-2021  cjep sync with head
 1.26 29-Jun-2025  rillig make: if a condition is erroneous, skip the whole .if/.endif
 1.25 29-Jun-2025  rillig make: fix parsing of modifier parts for :gmtime and :localtime

There's no practical use for escaping the ":" or "}" in these two
modifiers, but the same scheme may prove useful for the :M and :N
modifiers, which are currently parsed in a completely different manner,
thus adding needless complexity.

Parsing of the :M and :N modifiers is discussed in PR bin/46139.
 1.24 29-Jun-2025  rillig tests/make: demonstrate bug in parsing :gmtime and :localtime

When the parsing of modifiers was unified a bit in May 2024, the :gmtime
and :localtime modifiers were the only ones that had two different
delimiters. Of these delimiters, only the second one can be escaped, but
the intention was that both of them can be escaped.

Since it doesn't make sense to have either ":" or "}" or ")" in a
second-based timestamp, this bug has survived more than a year.
 1.23 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.22 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.21 30-Mar-2025  rillig make: fix error message for invalid ":[...]" modifier

The unparsed value of the modifier argument can already be seen in the
stack trace, but the modifier argument may contain expressions and the
expanded value of these expressions was hidden up to now. See the EMPTY
test at the bottom of varmod-select-words.mk for details.
 1.20 29-Mar-2025  rillig tests/make: fix the documented modifier table

The SysV column was largely incorrect or too unspecific, stating N/A
when "no" was actually correct.

The modifiers differ in whether they fall back to the ":from=to"
modifier. The suggestion in https://bugs.freebsd.org/285726 to make more
of the modifiers fall back to the ":from=to" modifier thus becomes
nonobvious to decide.
 1.19 29-Mar-2025  rillig make: add details about indirect modifiers to the stack traces

Previously, the error message "Unfinished modifier (',' missing)" from
moderrs.mk didn't provide enough context to understand where and why the
comma was missing.
 1.18 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.17 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.16 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.15 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.14 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.13 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.12 06-Jun-2024  rillig branches: 1.12.2;
tests/make: test unescaped '$' at the end of a modifier part

In ParseModifierPart, an unescaped '$' that occurs right before a
delimiter is handled differently from a '$' that occurs in the middle of
the modifier part.

In practice, this edge case is only used by the first part of the
':C,from,to,' modifier. Using it in most other modifier parts produces
an error message.
 1.11 02-Jun-2024  rillig make: fix out-of-bounds read when parsing indirect modifiers
 1.10 01-Jun-2024  rillig tests/make: test more modifiers and special variables
 1.9 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.8 03-Feb-2024  sjg make: state of save_dollars affects what is a parse error

When save_dollars is false it is not a parse error to
encounter $$ rather than \$.
 1.7 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 24-Aug-2022  rillig tests/make: test misleading error messages on unclosed expressions

The error messages say 'Unknown modifier' or 'Bad modifier', which is
not entirely correct. The modifier in itself is valid, it's just that
make doesn't expect the end of the string after the modifier.
 1.5 06-Aug-2022  rillig tests/make: document parsing behavior of modifiers

The table was created by manually inspecting the code of the various
ApplyModifier functions in var.c.

The modifiers are listed in alphabetical order, except for the SysV
modifier, which is listed at the end since it is used as a fallback
modifier for many other modifiers and because it does not have a fixed
prefix.
 1.4 19-Dec-2020  rillig make(1): fix error message for .info/.warning/.error without argument

Previously, the error message was "Unknown directive", which was
obviously wrong. The new error message is "Missing argument".
 1.3 02-Nov-2020  rillig make(1): add test for the :P modifier, which does not fall back
 1.2 13-Sep-2020  rillig make(1): in lint mode, complain about erroneous $$

Since 2008-12-21, make has silently ignored strange variable names in
constructs like '$$', '$}', '$' followed by nothing. Ignoring these
bugs in makefiles instead of reporting them is not a good idea.

To improve the situation, make complains about these errors now, but
only in lint mode (-dL). This preserves existing behavior while still
allowing to validate existing makefiles that they don't depend on this
bug.

If the test phase goes well, these error messages may be enabled
unconditionally.

https://mail-index.netbsd.org/pkgsrc-users/2020/09/12/msg032229.html
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.12.2.1 02-Aug-2025  perseant Sync with HEAD
 1.30 29-Jun-2025  rillig make: if a condition is erroneous, skip the whole .if/.endif
 1.29 29-Jun-2025  rillig make: fix parsing of modifier parts for :gmtime and :localtime

There's no practical use for escaping the ":" or "}" in these two
modifiers, but the same scheme may prove useful for the :M and :N
modifiers, which are currently parsed in a completely different manner,
thus adding needless complexity.

Parsing of the :M and :N modifiers is discussed in PR bin/46139.
 1.28 29-Jun-2025  rillig tests/make: demonstrate bug in parsing :gmtime and :localtime

When the parsing of modifiers was unified a bit in May 2024, the :gmtime
and :localtime modifiers were the only ones that had two different
delimiters. Of these delimiters, only the second one can be escaped, but
the intention was that both of them can be escaped.

Since it doesn't make sense to have either ":" or "}" or ")" in a
second-based timestamp, this bug has survived more than a year.
 1.27 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.26 30-Mar-2025  rillig make: fix error message for invalid ":[...]" modifier

The unparsed value of the modifier argument can already be seen in the
stack trace, but the modifier argument may contain expressions and the
expanded value of these expressions was hidden up to now. See the EMPTY
test at the bottom of varmod-select-words.mk for details.
 1.25 30-Mar-2025  rillig make: let the ":t" modifiers fall back to the ":from=to" modifier

Suggested by https://bugs.freebsd.org/285726.

This means that the ":t" modifiers cannot have future extensions that
include a "=", as that may break existing code.
 1.24 29-Mar-2025  rillig make: let unknown ":O" modifiers fall back to the ":from=to" modifier

Inspired by https://bugs.freebsd.org/285726, which concerns the ":t"
modifier instead.

This means that future extensions to the ":O" modifier must not contain
a "=" anywhere, otherwise they may break existing code.
 1.23 29-Mar-2025  rillig tests/make: fix the documented modifier table

The SysV column was largely incorrect or too unspecific, stating N/A
when "no" was actually correct.

The modifiers differ in whether they fall back to the ":from=to"
modifier. The suggestion in https://bugs.freebsd.org/285726 to make more
of the modifiers fall back to the ":from=to" modifier thus becomes
nonobvious to decide.
 1.22 11-Jan-2025  rillig make: omit redundant follow-up message "Malformed conditional"

If there is a parse error or an evaluation error during the conditional,
the conditional is already mentioned in the "while evaluating condition"
line, so there's no reason to repeat it once again.

Same for the "Bad condition" message from the '?:' modifier.
 1.21 11-Jan-2025  rillig tests/make: force correct order of expected messages
 1.20 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.19 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.18 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.17 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.16 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.15 06-Jun-2024  rillig branches: 1.15.2;
tests/make: test unescaped '$' at the end of a modifier part

In ParseModifierPart, an unescaped '$' that occurs right before a
delimiter is handled differently from a '$' that occurs in the middle of
the modifier part.

In practice, this edge case is only used by the first part of the
':C,from,to,' modifier. Using it in most other modifier parts produces
an error message.
 1.14 05-Jun-2024  rillig make: sync comments with reality
 1.13 02-Jun-2024  rillig make: fix out-of-bounds read when parsing indirect modifiers
 1.12 01-Jun-2024  rillig tests/make: test more modifiers and special variables
 1.11 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.10 03-Feb-2024  sjg make: state of save_dollars affects what is a parse error

When save_dollars is false it is not a parse error to
encounter $$ rather than \$.
 1.9 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.8 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 24-Aug-2022  rillig tests/make: test misleading error messages on unclosed expressions

The error messages say 'Unknown modifier' or 'Bad modifier', which is
not entirely correct. The modifier in itself is valid, it's just that
make doesn't expect the end of the string after the modifier.
 1.6 06-Aug-2022  rillig tests/make: document parsing behavior of modifiers

The table was created by manually inspecting the code of the various
ApplyModifier functions in var.c.

The modifiers are listed in alphabetical order, except for the SysV
modifier, which is listed at the end since it is used as a fallback
modifier for many other modifiers and because it does not have a fixed
prefix.
 1.5 19-Dec-2020  rillig make(1): fix error message for .info/.warning/.error without argument

Previously, the error message was "Unknown directive", which was
obviously wrong. The new error message is "Missing argument".
 1.4 02-Nov-2020  rillig make(1): add test for the :P modifier, which does not fall back
 1.3 13-Sep-2020  rillig make(1): in lint mode, complain about erroneous $$

Since 2008-12-21, make has silently ignored strange variable names in
constructs like '$$', '$}', '$' followed by nothing. Ignoring these
bugs in makefiles instead of reporting them is not a good idea.

To improve the situation, make complains about these errors now, but
only in lint mode (-dL). This preserves existing behavior while still
allowing to validate existing makefiles that they don't depend on this
bug.

If the test phase goes well, these error messages may be enabled
unconditionally.

https://mail-index.netbsd.org/pkgsrc-users/2020/09/12/msg032229.html
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.15.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 28-Jun-2025  rillig branches: 1.2.4;
make: add POSIX $^ support

POSIX 2024 [1] introduced the $^ internal macro. Implement it as an
alias for $> (.ALLSRC), following the suggestion from defect 1520 [2].

[1]: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html
[2]: https://www.austingroupbugs.net/view.php?id=1520

Patch provided by Diogo Santos in PR bin/59018.
 1.1 27-Jun-2025  rillig tests/make: test missing support for $^

Test provided by Diogo Santos via PR bin/59018; extended by me for .WAIT
and implicit rules.
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 28-Jun-2025  perseant file varname-circumflex.exp was added on branch perseant-exfatfs on 2025-08-02 05:58:40 +0000
 1.2 09-Aug-2025  rillig make: clean up
 1.1 27-Jun-2025  rillig branches: 1.1.4;
tests/make: test missing support for $^

Test provided by Diogo Santos via PR bin/59018; extended by me for .WAIT
and implicit rules.
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 27-Jun-2025  perseant file varname-circumflex.mk was added on branch perseant-exfatfs on 2025-08-02 05:58:40 +0000
 1.4 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.3 01-Jun-2023  rillig branches: 1.3.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 19-Aug-2020  rillig make(1): add test for the $$ expression
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 19-Aug-2020  rillig make(1): add test for the $$ expression
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 25-Aug-2020  rillig make(1): add test for the .ALLTARGETS special variable
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 25-Aug-2020  rillig make(1): add test for the .ALLTARGETS special variable
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7 08-Oct-2020  rillig make(1): move test for .CURDIR from misc.mk to varname-dot-curname.mk
 1.6 05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.5 05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.4 04-Oct-2020  rillig make(1): fix assignment to .CURDIR via the shell assignment operator

This is probably an edge case that nobody will ever stumble upon, since
.CURDIR is usually regarded as a read-only variable.

The other variable that is affected by this code path is .MAKE.EXPORTED,
and for this variable as well, it would be unusual to assign it a value
from a shell command.
 1.3 04-Oct-2020  rillig make(1): add test for assigning to .CURDIR
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 28-Aug-2020  rillig make(1): add tests for the special .INCLUDES and .LIBS variables
 1.2 13-Sep-2020  rillig make(1): fix tests for .INCLUDES and .LIBS

Found by an early draft of a refactoring of Var_Parse to properly report
errors.
 1.1 28-Aug-2020  rillig make(1): add tests for the special .INCLUDES and .LIBS variables
 1.1 28-Aug-2020  rillig make(1): add tests for the special .INCLUDES and .LIBS variables
 1.2 13-Sep-2020  rillig make(1): fix tests for .INCLUDES and .LIBS

Found by an early draft of a refactoring of Var_Parse to properly report
errors.
 1.1 28-Aug-2020  rillig make(1): add tests for the special .INCLUDES and .LIBS variables
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 09-Sep-2023  sjg make: allow -j to compute a multiple of ncpu

If _SC_NPROCESSORS_ONLN is supported; and -j arg is a floating point
number or ends in 'C' compute .MAKE.JOBS as a multiple of _SC_NPROCESSORS_ONLN

Based on a suggestion from des at freebsd.org
Discussed with: rillig, christos
 1.2 26-Jan-2022  rillig tests/make: test meta mode in jobs mode
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5 10-Sep-2023  sjg make: skip -jC tests unless .MAKE.JOBS.C is yes
 1.4 09-Sep-2023  sjg make: allow -j to compute a multiple of ncpu

If _SC_NPROCESSORS_ONLN is supported; and -j arg is a floating point
number or ends in 'C' compute .MAKE.JOBS as a multiple of _SC_NPROCESSORS_ONLN

Based on a suggestion from des at freebsd.org
Discussed with: rillig, christos
 1.3 26-Jan-2022  rillig tests/make: test meta mode in jobs mode
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 13-Jun-2025  rillig make: add on-demand inter-process stack traces

When debugging a build that heavily uses nested calls to sub-makes, the
chain of calls is useful to quickly assess the situation. If explicitly
requested, include the actions from any parent processes in the stack
traces.

Reviewed by: sjg
 1.5 22-Mar-2025  rillig make: ignore attempts to override a read-only global with the same value

Up to NetBSD 9, make passed around the internal variable .MAKE.LEVEL.ENV
via MAKEFLAGS. Allow these old versions of make to coexist with newer
versions of make. See unit-tests/varname-dot-make-level.mk for details.

Fixes PR pkg/59184.
 1.4 23-Nov-2024  rillig make: fix confusing error message when overriding a read-only variable
 1.3 23-Nov-2024  rillig tests/make: demonstrate confusing error message for .MAKE.LEVEL.ENV
 1.2 01-Jun-2024  rillig branches: 1.2.2;
tests/make: test more modifiers and special variables
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 22-Mar-2025  rillig make: ignore attempts to override a read-only global with the same value

Up to NetBSD 9, make passed around the internal variable .MAKE.LEVEL.ENV
via MAKEFLAGS. Allow these old versions of make to coexist with newer
versions of make. See unit-tests/varname-dot-make-level.mk for details.

Fixes PR pkg/59184.
 1.5 23-Nov-2024  rillig make: fix confusing error message when overriding a read-only variable
 1.4 23-Nov-2024  rillig tests/make: demonstrate confusing error message for .MAKE.LEVEL.ENV
 1.3 01-Jun-2024  rillig branches: 1.3.2;
tests/make: test more modifiers and special variables
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 12-Apr-2025  sjg make/unit-tests: Fix expected results for meta-ignore tests
 1.3 25-Feb-2023  sjg branches: 1.3.2;
make: meta-ignore tests will not work if TMPDIR is /tmp

Since /tmp and /var/tmp are always part of .MAKE.META.IGNORE_PATHS
the varname-dot-make-meta-ignore_* tests will not work
if TMPDIR is either (or subdir) of those.
 1.2 23-Feb-2023  sjg Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 23-Feb-2023  sjg Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 12-Apr-2025  sjg make/unit-tests: Fix expected results for meta-ignore tests
 1.3 25-Feb-2023  sjg branches: 1.3.2;
make: meta-ignore tests will not work if TMPDIR is /tmp

Since /tmp and /var/tmp are always part of .MAKE.META.IGNORE_PATHS
the varname-dot-make-meta-ignore_* tests will not work
if TMPDIR is either (or subdir) of those.
 1.2 23-Feb-2023  sjg Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 23-Feb-2023  sjg Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.4 12-Apr-2025  sjg make/unit-tests: Fix expected results for meta-ignore tests
 1.3 25-Feb-2023  sjg branches: 1.3.2;
make: meta-ignore tests will not work if TMPDIR is /tmp

Since /tmp and /var/tmp are always part of .MAKE.META.IGNORE_PATHS
the varname-dot-make-meta-ignore_* tests will not work
if TMPDIR is either (or subdir) of those.
 1.2 23-Feb-2023  sjg Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 23-Feb-2023  sjg Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 07-May-2022  rillig make: allow to randomize build order of targets

In complex dependency structures, when a build fails, a probable cause
is a missing dependency declaration between some files. In compat mode,
the build order is deterministic, in jobs mode, it is somewhat
deterministic. To explore more edge cases, add the line ".MAKE.MODE +=
randomize-targets" somewhere in the makefile.

Fixes PR bin/45226 by riastradh. Reviewed by christos.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 07-May-2022  rillig make: allow to randomize build order of targets

In complex dependency structures, when a build fails, a probable cause
is a missing dependency declaration between some files. In compat mode,
the build order is deterministic, in jobs mode, it is somewhat
deterministic. To explore more edge cases, add the line ".MAKE.MODE +=
randomize-targets" somewhere in the makefile.

Fixes PR bin/45226 by riastradh. Reviewed by christos.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 23-Jan-2022  rillig tests/make: add a few more tests
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 23-Jan-2022  rillig tests/make: add a few more tests
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7 03-Dec-2021  rillig tests/make: document .MAKE.SAVE_DOLLARS in modifier ':@'
 1.6 02-Dec-2021  rillig tests/make: fix test for .MAKE.SAVE_DOLLARS

The previous assumption was wrong that only literal '$$' that occur
directly in the right-hand side of a variable assignment would be
affected. Indirect variable definitions are affected as well when they
are evaluated nestedly, as long as the '$$' appears in the text of the
variable that is actually parsed. Whether the '$$' ends up in the
expanded value of the expression doesn't matter though.
 1.5 01-Dec-2021  rillig tests/make: clean up test for .MAKE.SAVE_DOLLARS
 1.4 30-Nov-2021  rillig tests/make: document that undefining .MAKE.SAVE_DOLLARS has no effect
 1.3 30-Nov-2021  rillig tests/make: test and document .MAKE.SAVE_DOLLARS and ':='
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 01-Jun-2023  rillig branches: 1.7.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 25-Feb-2023  rillig tests/make: clean up tests for MAKEFLAGS and related variables
 1.5 25-Feb-2023  rillig tests/make: move tests for MAKRFLAGS to the correct file

I had accidentally added these tests to the file for the special
variable '.MAKEFLAGS' instead of the file for the environment variable
'MAKEFLAGS'. While here, add a basic test that shows how 'MAKEFLAGS' is
built from '.MAKEFLAGS' and '.MAKEOVERRIDES'.
 1.4 25-Feb-2023  rillig tests/make: test that MAKEFLAGS is an environment variable
 1.3 25-Feb-2023  rillig tests/make: activate all tests for MAKEFLAGS
 1.2 25-Feb-2023  rillig tests/make: reproduce and explain '$' in MAKEFLAGS

https://mail-index.netbsd.org/current-users/2023/02/24/msg043633.html
 1.1 01-Dec-2020  rillig make(1): add test for the special .MAKEFLAGS variable
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.11 20-May-2025  sjg Revert export of MAKEFLAGS from Cmd_Exec

Until we work out what the issue is.
Revert related unit-test changes as well
 1.10 18-May-2025  rillig tests/make: test exporting of MAKEFLAGS in compat and parallel mode
 1.9 18-May-2025  sjg make: Cmd_Exec call Main_ExportMAKEFLAGS

export MAKEFLAGS the fist time Cmd_Exec is called.
This allows ${.MAKE} run via x!= to see them.

Remove test case from varname-dot-makeflags that checked
this does not happen.

Reviewed by: christos
 1.8 01-Jun-2023  rillig branches: 1.8.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.7 25-Feb-2023  rillig tests/make: clean up tests for MAKEFLAGS and related variables
 1.6 25-Feb-2023  rillig tests/make: move tests for MAKRFLAGS to the correct file

I had accidentally added these tests to the file for the special
variable '.MAKEFLAGS' instead of the file for the environment variable
'MAKEFLAGS'. While here, add a basic test that shows how 'MAKEFLAGS' is
built from '.MAKEFLAGS' and '.MAKEOVERRIDES'.
 1.5 25-Feb-2023  rillig tests/make: test that MAKEFLAGS is an environment variable
 1.4 25-Feb-2023  rillig tests/make: fix explanation for '$' in MAKEFLAGS

My previous interpretation was completely wrong.
 1.3 25-Feb-2023  rillig tests/make: activate all tests for MAKEFLAGS
 1.2 25-Feb-2023  rillig tests/make: reproduce and explain '$' in MAKEFLAGS

https://mail-index.netbsd.org/current-users/2023/02/24/msg043633.html
 1.1 01-Dec-2020  rillig make(1): add test for the special .MAKEFLAGS variable
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 07-May-2024  sjg make: all command line overrides go in .MAKEOVERRIDES

Not all variables that start with '.' are internals,
and unless they are explicitly flagged as internal should go
into .MAKEOVERRIDES

Update varname-dot-makeoverrides to check this.

Also avoid using SCOPE_CMDLINE when ReadOnly will do.
 1.3 25-Feb-2023  rillig tests/make: reproduce and explain '$' in MAKEFLAGS

https://mail-index.netbsd.org/current-users/2023/02/24/msg043633.html
 1.2 25-Feb-2023  rillig tests/make: test how '$' behaves in .MAKEOVERRIDES and MAKEFLAGS
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 07-May-2024  sjg make: all command line overrides go in .MAKEOVERRIDES

Not all variables that start with '.' are internals,
and unless they are explicitly flagged as internal should go
into .MAKEOVERRIDES

Update varname-dot-makeoverrides to check this.

Also avoid using SCOPE_CMDLINE when ReadOnly will do.
 1.5 25-Feb-2023  rillig tests/make: reproduce and explain '$' in MAKEFLAGS

https://mail-index.netbsd.org/current-users/2023/02/24/msg043633.html
 1.4 25-Feb-2023  rillig tests/make: test how '$' behaves in .MAKEOVERRIDES and MAKEFLAGS
 1.3 15-Feb-2023  rillig make: inline macros for variable names

The variable name '.MAKEOVERRIDES' was already used in the non-macro
form.

No binary change.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.10 12-Jun-2025  rillig make: add program name to stack traces from sub-makes
 1.9 12-Jun-2025  rillig make: add quotes to "in directory" line in stack traces

The other lines in stack traces use quotes as well.
 1.8 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.7 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.6 04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.5 15-Jun-2024  rillig branches: 1.5.2;
make: error out if an internal read-only variable is overwritten

The affected variables are:
* .newline
* .MAKE.OS
* .MAKE.JOBS.C
* .MAKE.LEVEL.ENV
* .MAKE.PID
* .MAKE.PPID
* .MAKE.UID
* .MAKE.GID

This change does not affect the .SHELL and .SUFFIXES variables, as well
as variables that are manually turned read-only by the special .READONLY
target.
 1.4 26-Jan-2023  sjg make: some variables should be read-only

Make variables like .newline and .MAKE.{GID,PID,PPID,UID} read-only.

Reviewed by: rillig
 1.3 17-Jan-2023  rillig tests/make: test backslash-newline after macro expansion in command
 1.2 19-Aug-2020  rillig make(1): add test for the .newline variable
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 15-Jun-2024  rillig make: error out if an internal read-only variable is overwritten

The affected variables are:
* .newline
* .MAKE.OS
* .MAKE.JOBS.C
* .MAKE.LEVEL.ENV
* .MAKE.PID
* .MAKE.PPID
* .MAKE.UID
* .MAKE.GID

This change does not affect the .SHELL and .SUFFIXES variables, as well
as variables that are manually turned read-only by the special .READONLY
target.
 1.6 26-Jan-2023  sjg make: some variables should be read-only

Make variables like .newline and .MAKE.{GID,PID,PPID,UID} read-only.

Reviewed by: rillig
 1.5 17-Jan-2023  rillig tests/make: test backslash-newline after macro expansion in command
 1.4 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.3 19-Aug-2020  rillig make(1): add test for the .newline variable
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 01-Jun-2024  rillig tests/make: cover purging the realpath cache

In purge_relative_cached_realpaths, the hash table containing the cache
is modified while being iterated, which needs extra care, so add a test
that covers this code in at least a single simple scenario.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 01-Jun-2024  rillig tests/make: cover purging the realpath cache

In purge_relative_cached_realpaths, the hash table containing the cache
is modified while being iterated, which needs extra care, so add a test
that covers this code in at least a single simple scenario.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.7 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.6 21-Jun-2023  rillig branches: 1.6.2;
tests/make: document a few tests
 1.5 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.4 21-Sep-2020  rillig make(1): fix tests for .PARSEDIR/.PARSEFILE

The output of these tests previously depended upon whether the test
makefile was specified as relative or as absolute path. In NetBSD, it
is specified as relative path, in FreeBSD as absolute path.

Adjust the expected output to hide this difference; in the .rawout files
it is still visible.
 1.3 12-Sep-2020  rillig make(1): add test for .PARSEFILE
 1.2 12-Sep-2020  rillig make(1): add test for .PARSEDIR
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 21-Jun-2023  rillig tests/make: document a few tests
 1.7 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.5 21-Sep-2020  rillig make(1): fix tests for .PARSEDIR/.PARSEFILE

The output of these tests previously depended upon whether the test
makefile was specified as relative or as absolute path. In NetBSD, it
is specified as relative path, in FreeBSD as absolute path.

Adjust the expected output to hide this difference; in the .rawout files
it is still visible.
 1.4 12-Sep-2020  rillig make(1): add test for .PARSEFILE
 1.3 12-Sep-2020  rillig make(1): add test for .PARSEDIR
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 21-Jun-2023  rillig branches: 1.5.2;
tests/make: document a few tests
 1.4 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.3 21-Sep-2020  rillig make(1): fix tests for .PARSEDIR/.PARSEFILE

The output of these tests previously depended upon whether the test
makefile was specified as relative or as absolute path. In NetBSD, it
is specified as relative path, in FreeBSD as absolute path.

Adjust the expected output to hide this difference; in the .rawout files
it is still visible.
 1.2 12-Sep-2020  rillig make(1): add test for .PARSEFILE
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 21-Jun-2023  rillig tests/make: document a few tests
 1.6 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.5 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.4 21-Sep-2020  rillig make(1): fix tests for .PARSEDIR/.PARSEFILE

The output of these tests previously depended upon whether the test
makefile was specified as relative or as absolute path. In NetBSD, it
is specified as relative path, in FreeBSD as absolute path.

Adjust the expected output to hide this difference; in the .rawout files
it is still visible.
 1.3 12-Sep-2020  rillig make(1): add test for .PARSEFILE
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 02-Oct-2020  rillig make(1): add test for the special .PATH target and variable
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.23 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.22 31-Oct-2024  rillig make: in the debug log, always qualify line number with filename

Previously, to find out the filename corresponding to a line number from
a 'Parsing' line, it was necessary to find the preceding
'SetFilenameVars' line, which was unnecessarily time-consuming and
distracting.

The 'filename:line' format matches the one used in PrintStackTrace, and
it differs from the one used in PrintLocation, as the former format is
more common in other tools.

Most of the affected unit tests only use the 'Parsing' lines to give
additional context to their debug log, so no structural changes there.
 1.21 14-Apr-2024  rillig branches: 1.21.2;
make: add debug logging for .if and .for lines in -dp mode

This helps track down in which line a condition is evaluated.
 1.20 20-Dec-2023  rillig make: use consistent debug messages style when ignoring variables

When a variable is not modified or not deleted, clearly say so and state
the reason. Use the same style of debug messages everywhere, putting
the word 'ignoring' at the front. Previously, that word sticked out to
the right, but only in some cases.
 1.19 20-Dec-2023  rillig make: fix confusing debug logging when deleting a variable

Be clear when deleting a variable is ignored and state the reason,
instead of only providing a keyword as a hint for insiders.
 1.18 10-Dec-2023  rillig make: explain in the debug log why a variable assignment is ignored
 1.17 09-Dec-2023  sjg make: Var_SetWithFlags set fromCmd for SCOPE_CMDLINE

Set fromCmd true for SCOPE_CMDLINE
regardless of the variable name.

Reviewed by: rillig
 1.16 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.15 26-Mar-2022  rillig make: add space after colon in debug logging for variables

These log messages are intended for human interpretation, so don't make
them unnecessarily hard to read.
 1.14 03-Mar-2022  rillig make: make debug logging for comparisons less technical
 1.13 28-Dec-2021  rillig make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number. Additionally, having
both a colon and quotes in a log message is uncommon. The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans. The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities. The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous. Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.
 1.12 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.11 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.10 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.9 28-Dec-2020  rillig make(1): replace global preserveUndefined with VARE_KEEP_UNDEF

Controlling the expansion of variable expressions using a global
variable and a VARE flag was inconsistent.

Converting the global variable into a flag had to prerequisites:

1. The unintended duplicate variable assignment had to be fixed, as
done in parse.c 1.520 from 2020-12-27. Without this fix, it would have
been necessary to add more flags to Var_Exists and Var_SetWithFlags, and
this would have become too complex.

2. There had to be a unit test demonstrating that VARE_KEEP_DOLLAR only
applies to the top-level expression and is not passed to the
subexpressions, while VARE_KEEP_UNDEF applies to all subexpressions as
well. This test is in var-op-expand.mk 1.10 from 2020-12-28, at least
for the ':@word@' modifier. In ParseModifierPartSubst, VARE_KEEP_UNDEF
is not passed down either, in the same way.
 1.8 08-Nov-2020  rillig make(1): rename VARE_ASSIGN to VARE_KEEP_DOLLAR

The other flags in VarEvalFlags already describe their effects, not the
place where they are used. It's more important to know the effect.

Only a single unit test had to be adjusted. This probably means that
there are too few tests where the special effects of VARE_KEEP_DOLLAR
come into play. It could also mean that the effects are so simple and
obvious that they don't need any debug log, but that's not the case.
 1.7 30-Oct-2020  rillig make(1): prevent appending to read-only variables
 1.6 30-Oct-2020  rillig make(1): demonstrate how to append to a read-only variable
 1.5 30-Oct-2020  rillig make(1): move test flags for varname-dot-shell to the test itself
 1.4 22-Sep-2020  rillig make(1): move VAR_JUNK and VAR_KEEP away from VarFlags

These two flags have nothing to do with a variable. They are only used
while evaluating a variable expression.

While here, rename the flags and make their documentation more precise.
 1.3 13-Sep-2020  rillig make(1): shorten debug output of ApplyModifiers

Having the words "eflags" and "vflags" in the debug output was too
repetitive. That they are flags is made obvious by the '|' separator,
and the flags have clearly distinguishable names (VARE_* vs. VAR_*),
which lowers the chance for confusion.
 1.2 23-Aug-2020  rillig make(1): fix assertion failure in debug output for read-only variables
 1.1 23-Aug-2020  rillig make(1): add test for the newly added .SHELL variable
 1.21.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 04-Feb-2021  rillig make: rename context and ctxt to scope

This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.

Renaming the variable 'ctxt' was trivial since that word is used nowhere
else. In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope. It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.
 1.6 30-Oct-2020  rillig make(1): prevent appending to read-only variables
 1.5 30-Oct-2020  rillig make(1): demonstrate how to append to a read-only variable
 1.4 30-Oct-2020  rillig make(1): move test flags for varname-dot-shell to the test itself
 1.3 24-Oct-2020  rillig make(1): indent directives like .info, .if, .for consistently

Done by "pkglint -F *.mk", no manual corrections.
 1.2 23-Aug-2020  rillig make(1): fix assertion failure in debug output for read-only variables
 1.1 23-Aug-2020  rillig make(1): add test for the newly added .SHELL variable
 1.9 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.8 29-Dec-2023  rillig branches: 1.8.2;
make: simplify debug message for the ':@var@...@' modifier

The previous variant was hard to understand.
 1.7 20-Dec-2023  rillig make: use consistent debug messages style when ignoring variables

When a variable is not modified or not deleted, clearly say so and state
the reason. Use the same style of debug messages everywhere, putting
the word 'ignoring' at the front. Previously, that word sticked out to
the right, but only in some cases.
 1.6 20-Dec-2023  rillig make: fix confusing debug logging when deleting a variable

Be clear when deleting a variable is ignored and state the reason,
instead of only providing a keyword as a hint for insiders.
 1.5 23-Aug-2022  rillig make: revert parsing of modifier parts (since 2022-08-08)

The modifier ':@var@body@' parses the body in parse-only mode and later
uses Var_Subst on it, in which each literal '$' must be written as '$$'.

Trying to parse the loop body using Var_Parse treated the text
'$${var:-0}' as a single '$' followed by the expression '${var:-0}',
wrongly complaining about the 'Unknown modifier "-0"'.

Found by sjg.
 1.4 08-Aug-2022  rillig make: fix parsing of modifiers containing unbalanced subexpressions
 1.3 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.2 26-Mar-2022  rillig make: add space after colon in debug logging for variables

These log messages are intended for human interpretation, so don't make
them unnecessarily hard to read.
 1.1 12-Dec-2021  rillig tests/make: test and document the newly added "variable" .SUFFIXES
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 20-Dec-2023  rillig make: use consistent debug messages style when ignoring variables

When a variable is not modified or not deleted, clearly say so and state
the reason. Use the same style of debug messages everywhere, putting
the word 'ignoring' at the front. Previously, that word sticked out to
the right, but only in some cases.
 1.4 20-Dec-2023  rillig make: fix confusing debug logging when deleting a variable

Be clear when deleting a variable is ignored and state the reason,
instead of only providing a keyword as a hint for insiders.
 1.3 15-Apr-2022  rillig tests/make: adjust expectations to actual behavior

The bug in deptgt-silent-jobs.mk has been fixed, the debug logging for
comparing conditions and for deleting global variables has changed
intentionally.
 1.2 15-Jan-2022  rillig tests/make: ensure that the 'expect' comments in tests are correct

Based on tests/usr.bin/xlint/check-expect.lua.

For now, this extra check needs to be run manually.
 1.1 12-Dec-2021  rillig tests/make: test and document the newly added "variable" .SUFFIXES
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.24 20-May-2025  sjg Revert export of MAKEFLAGS from Cmd_Exec

Until we work out what the issue is.
Revert related unit-test changes as well
 1.23 18-May-2025  sjg make: Cmd_Exec call Main_ExportMAKEFLAGS

export MAKEFLAGS the fist time Cmd_Exec is called.
This allows ${.MAKE} run via x!= to see them.

Remove test case from varname-dot-makeflags that checked
this does not happen.

Reviewed by: christos
 1.22 20-Dec-2023  rillig make: use consistent debug messages style when ignoring variables

When a variable is not modified or not deleted, clearly say so and state
the reason. Use the same style of debug messages everywhere, putting
the word 'ignoring' at the front. Previously, that word sticked out to
the right, but only in some cases.
 1.21 20-Dec-2023  rillig make: fix confusing debug logging when deleting a variable

Be clear when deleting a variable is ignored and state the reason,
instead of only providing a keyword as a hint for insiders.
 1.20 26-Mar-2022  rillig make: avoid trailing whitespace in debug log for variables

Since trailing whitespace is invisible, describe the variable value in
words to make it visible.
 1.19 26-Mar-2022  rillig make: add space after colon in debug logging for variables

These log messages are intended for human interpretation, so don't make
them unnecessarily hard to read.
 1.18 10-Jan-2022  rillig make: add debug logging for capturing the output of external commands

This applies to all 4 situations in which the output of an external
command is used for modifying a variable or an expression:

* the assignment operator '!='
* the assignment modifier '::!='
* the SUN shell modifier ':sh'
* the other shell modifier ':!cmd!'

Previously, only the shell modifier ':!cmd!' had debug logging.

Suggested by Christoph Badura.
 1.17 19-Oct-2021  sjg Replace ${.OBJDIR} with <curdir> for consistent results.

If we replace ${.OBJDIR} with <objdir> some tests produce
different results depending on the value of .OBJDIR

For similar reasons eliminate .OBJDIR and .PATH from output of
varname-empty

Reviewed by: rillig
 1.16 14-Apr-2021  rillig make: remove unnecessary modifier ':U' for certain fixed expressions

No functional change, since the expression is evaluated using
VARE_WANTRES, not using VARE_UNDEFERR.
 1.15 10-Apr-2021  rillig make: reword debug log message for empty variable name

The function names did not match anymore, after one of the many
refactorings in the last few months.
 1.14 10-Apr-2021  rillig make: reduce debug logging and memory allocation for ${:U...}

Expressions of the form ${:U...} are often generated by .for loops.
Since these expressions are not generated knowingly by the make user, do
not fill the debug log with them since that would interrupt the normal
reading flow of the -dv log for nested expressions.
 1.13 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.12 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.11 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.10 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.9 15-Feb-2021  rillig make: rename ExprDefined constants for debug logging
 1.8 04-Feb-2021  rillig make: remove .PARSEDIR from test output of varname-empty

The .PARSEDIR has nothing to do with .CURDIR. This wrong assumption
made the NetBSD test suite fail since the actual .PARSEDIR was not
replaced with "<curdir>".
 1.7 03-Feb-2021  rillig make: fix double expansion when appending to a new variable
 1.6 03-Feb-2021  rillig make: in the test varname-empty, keep more debug output

Filtering out the interesting lines based on the very specific pattern
"Var_Set" was surprising.
 1.5 15-Nov-2020  rillig make(1): fix typo in test for variable with empty name
 1.4 23-Oct-2020  rillig make(1): add tests for the variable named ""
 1.3 22-Aug-2020  rillig make(1): try to set the variable named "" using the command line

Before 2020-08-22, the command line argument '=cmline-plain' triggered
undefined behavior, just like the assignment '=assigned' in the Makefile.
 1.2 22-Aug-2020  rillig make(1): prevent assignment to the variable with the empty name
 1.1 22-Aug-2020  rillig make(1): add test for assigning to the variable named ""

This has been possible at least since 2013, probably much longer.
 1.10 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.9 04-Apr-2021  rillig make: remove filler word 'Do' from function names for parsing

No functional change, except for debug logging.
 1.8 03-Feb-2021  rillig make: in the test varname-empty, keep more debug output

Filtering out the interesting lines based on the very specific pattern
"Var_Set" was surprising.
 1.7 23-Oct-2020  rillig make(1): add tests for the variable named ""
 1.6 24-Sep-2020  rillig make(1): extend documentation in the varname-empty test
 1.5 22-Aug-2020  rillig make(1): try to set the variable named "" using the command line

Before 2020-08-22, the command line argument '=cmline-plain' triggered
undefined behavior, just like the assignment '=assigned' in the Makefile.
 1.4 22-Aug-2020  rillig make(1): fix undefined behavior when assigning to variable ""

Using a programming language with built-in array bounds checks would
have prevented this bug, and many others as well.
 1.3 22-Aug-2020  rillig make(1): try a bit harder to set the variable with the empty name

There is not only the != assignment operator, but a few others as well.
Especially the += operator is interesting since it has a different code
path. But all is good.
 1.2 22-Aug-2020  rillig make(1): prevent assignment to the variable with the empty name
 1.1 22-Aug-2020  rillig make(1): add test for assigning to the variable named ""

This has been possible at least since 2013, probably much longer.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.2 13-Dec-2020  rillig branches: 1.2.8;
make(1): add tests for variable expansion in .ERROR handling
 1.1 23-Oct-2020  rillig make(1): add test for .ERROR_CMD in jobs mode
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.4 19-Nov-2023  rillig tests/make: replace 'variable expressions' with 'expressions'
 1.3 04-Feb-2021  rillig make: rename some VAR constants to SCOPE

The word "context" does not fit perfectly to the variables that are
associate with a GNode, as the context is usually something from the
outside and the variables are more like properties inherent to the
GNode.

The term "global context" fits even less. Since the thing where
variables are looked up is commonly named a scope, use that term
instead.

This commit only renames the global variables VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE, plus a few very closely related comments. These are:

GNode.vars (because of line breaks)
GNode_Free (dito)
varname-make_print_var_on_error.mk
varname-make_print_var_on_error-jobs.mk

The debug message in Var_Stats is left as-is since there is no unit test
for it yet.

The other renamings (variable names "context", "ctxt", as well as
further comments) will be done in a follow-up commit.
 1.2 13-Dec-2020  rillig make(1): add tests for variable expansion in .ERROR handling
 1.1 23-Oct-2020  rillig make(1): add test for .ERROR_CMD in jobs mode
 1.4 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.3 13-Dec-2020  rillig branches: 1.3.8;
make(1): add tests for variable expansion in .ERROR handling
 1.2 23-Oct-2020  rillig make(1): add test for MAKE_PRINT_VAR_ON_ERROR
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3.8.1 02-Aug-2025  perseant Sync with HEAD
 1.6 04-Feb-2021  rillig make: rename some VAR constants to SCOPE

The word "context" does not fit perfectly to the variables that are
associate with a GNode, as the context is usually something from the
outside and the variables are more like properties inherent to the
GNode.

The term "global context" fits even less. Since the thing where
variables are looked up is commonly named a scope, use that term
instead.

This commit only renames the global variables VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE, plus a few very closely related comments. These are:

GNode.vars (because of line breaks)
GNode_Free (dito)
varname-make_print_var_on_error.mk
varname-make_print_var_on_error-jobs.mk

The debug message in Var_Stats is left as-is since there is no unit test
for it yet.

The other renamings (variable names "context", "ctxt", as well as
further comments) will be done in a follow-up commit.
 1.5 13-Dec-2020  rillig make(1): add tests for variable expansion in .ERROR handling
 1.4 23-Oct-2020  rillig make(1): add test for .ERROR_CMD in jobs mode
 1.3 23-Oct-2020  rillig make(1): add test for MAKE_PRINT_VAR_ON_ERROR
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 13-Jun-2025  rillig branches: 1.1.4;
make: add on-demand inter-process stack traces

When debugging a build that heavily uses nested calls to sub-makes, the
chain of calls is useful to quickly assess the situation. If explicitly
requested, include the actions from any parent processes in the stack
traces.

Reviewed by: sjg
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 13-Jun-2025  perseant file varname-make_stack_trace.exp was added on branch perseant-exfatfs on 2025-08-02 05:58:40 +0000
 1.1 13-Jun-2025  rillig branches: 1.1.4;
make: add on-demand inter-process stack traces

When debugging a build that heavily uses nested calls to sub-makes, the
chain of calls is useful to quickly assess the situation. If explicitly
requested, include the actions from any parent processes in the stack
traces.

Reviewed by: sjg
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 13-Jun-2025  perseant file varname-make_stack_trace.mk was added on branch perseant-exfatfs on 2025-08-02 05:58:40 +0000
 1.2 09-Nov-2020  rillig make(1): add test for MAKEFILE after reading all files
 1.1 04-Sep-2020  rillig make(1): add test for the special variable MAKEFILE
 1.3 09-Nov-2020  rillig make(1): add test for MAKEFILE after reading all files
 1.2 05-Sep-2020  rillig make(1): fix test for the MAKEFILE variable

That test had assumed that it would always be run with CURDIR ==
PARSEDIR, which is not the case for ./build.sh.
 1.1 04-Sep-2020  rillig make(1): add test for the special variable MAKEFILE
 1.2 25-Feb-2023  rillig tests/make: move tests for MAKRFLAGS to the correct file

I had accidentally added these tests to the file for the special
variable '.MAKEFLAGS' instead of the file for the environment variable
'MAKEFLAGS'. While here, add a basic test that shows how 'MAKEFLAGS' is
built from '.MAKEFLAGS' and '.MAKEOVERRIDES'.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.8 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.7 25-Feb-2023  rillig tests/make: clean up tests for MAKEFLAGS and related variables
 1.6 25-Feb-2023  rillig tests/make: move tests for MAKRFLAGS to the correct file

I had accidentally added these tests to the file for the special
variable '.MAKEFLAGS' instead of the file for the environment variable
'MAKEFLAGS'. While here, add a basic test that shows how 'MAKEFLAGS' is
built from '.MAKEFLAGS' and '.MAKEOVERRIDES'.
 1.5 16-Jan-2022  sjg Ensure make gets -r

Apart from ensuring no influence from /usr/share/mk
when bmake is built for the first time on a non-BSD
system, sys.mk will not be found
 1.4 27-Dec-2021  rillig tests/make: test MAKEFLAGS in POSIX mode

This test covers the function 'explode' in main.c, the case in which the
flags are actually expanded.
 1.3 01-Dec-2020  rillig make(1): add test for the special .MAKEFLAGS variable
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.3 06-Jul-2025  rillig make: improve debug log message for 'exists' function

The previous wording came from a time where the return type of
FuncExists was a string; this wording neither matches the current
implementation nor is it understandable without knowing the code.
 1.2 10-Nov-2020  rillig branches: 1.2.8;
make(1): add test for the obsolete variable VPATH
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.3 10-Nov-2020  rillig make(1): add test for the obsolete variable VPATH
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.27 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.26 12-Jun-2025  rillig tests/make: add tests for detection of GNU-make-style expressions
 1.25 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.24 14-Jan-2025  rillig make: simplify parsing of dependency lines

The evaluation modes that allow or deny undefined variables have the same
effect in this case, as Var_Subst does not return an error marker.
 1.23 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.22 06-Aug-2024  rillig make: add details to error messages about missing ')'
 1.21 04-Jul-2024  rillig make: on error, print the targets to be made

This helps to understand situations with several nested sub-makes in
varying directories.
 1.20 19-Aug-2023  rillig branches: 1.20.2;
make: show realistic invalid line in error message

Previously, the error message 'Invalid line' showed only the expanded
line, which might or might not show the actual problem. To be more
helpful, add the unexpanded line to the error message in case they
differ.

Remove the special handling of invalid lines that result from merge
conflicts. RCS is not commonly used anymore, and mentioning CVS was too
specific. By echoing the whole line, the patterns '<<<<<<' and '>>>>>>'
are clear enough to hint at the problem.
 1.19 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.18 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.17 10-Apr-2021  rillig make: reduce debug logging and memory allocation for ${:U...}

Expressions of the form ${:U...} are often generated by .for loops.
Since these expressions are not generated knowingly by the make user, do
not fill the debug log with them since that would interrupt the normal
reading flow of the -dv log for nested expressions.
 1.16 05-Apr-2021  rillig make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'. From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.
 1.15 05-Apr-2021  rillig make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable. Give more
hints by describing each part of the expression when evaluating a
modifier. Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.
 1.14 03-Apr-2021  rillig make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information. The other VarFlags
do not influence the evaluation, so there is no point logging them.
 1.13 15-Mar-2021  rillig make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.
 1.12 15-Feb-2021  rillig make: rename ExprDefined constants for debug logging
 1.11 02-Feb-2021  rillig make: replace VarExprFlags with VarExprStatus

The combination of !VEF_UNDEF && VEF_DEF was not possible, which made it
rather strange to model this state as a bit set.

The only functional change is the renamed constants in the debug output.

Using ENUM_VALUE_RTTI_2 felt like overengineering since it's harder to
understand than a simple array of names.
 1.10 01-Feb-2021  rillig make: replace parse error "Need an operator" with better message

The previous error message is not easily understandable since it is
missing a crucial detail, the column where the operator is needed.
Without this information, the author of the makefile gets no useful
hint. Furthermore, there are several types of operators in makefiles:

the dependency operators ':', '!', '::',
the variable assignment operators '=', '!=', '+=', '?=', ':=',
the conditional operators '&&', '||', '!',
the comparison operators '==', '!=', '>', '>=', '<', '<='.

This leaves too much ambiguity.

Replace this error message with "Invalid line type", which is more
generic, more accurate and thus less misleading.
 1.9 07-Nov-2020  rillig make(1): properly handle errors for malformed archive target names

Error messages don't belong on stdout.
 1.8 02-Nov-2020  rillig make(1): document test for parsing of variable assignments
 1.7 02-Nov-2020  rillig make(1): fix line numbers in test output of varname.mk
 1.6 02-Nov-2020  rillig make(1): document undefined behavior in Parse_IsVar

Sigh. If only C could be compiled in strict mode that detects these
out-of-bounds memory accesses.
 1.5 02-Nov-2020  rillig make(1): fix test for parsing obscure variable names

I had forgotten the :U modifier. Without that modifier, there's no
chance that the variable names would come out correctly.
 1.4 02-Nov-2020  rillig make(1): add tests for parsing ob obscure variable names
 1.3 18-Oct-2020  rillig make(1): sort variables in debug output

This way it's easier to see whether an expected variable is missing, or
to compare the values of related variables, since they usually share a
common prefix. Any sorting criterion is better than the hash code.

Sorting the variables by name changed the order of the output in
varname.mk. That test didn't test anything meaningful, it was just a
playground to understand and demonstrate the current implementation of
how the variables are stored, therefore it has been removed.
 1.2 05-Sep-2020  rillig make(1): add expected test result for hashing variable names
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.20.2.1 02-Aug-2025  perseant Sync with HEAD
 1.18 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.17 12-Jun-2025  rillig tests/make: add tests for detection of GNU-make-style expressions
 1.16 11-Jan-2025  rillig tests/make: force correct order of expected messages
 1.15 06-Aug-2024  rillig make: add details to error messages about missing ')'
 1.14 19-Nov-2023  rillig branches: 1.14.2;
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.13 19-Aug-2023  rillig make: show realistic invalid line in error message

Previously, the error message 'Invalid line' showed only the expanded
line, which might or might not show the actual problem. To be more
helpful, add the unexpanded line to the error message in case they
differ.

Remove the special handling of invalid lines that result from merge
conflicts. RCS is not commonly used anymore, and mentioning CVS was too
specific. By echoing the whole line, the patterns '<<<<<<' and '>>>>>>'
are clear enough to hint at the problem.
 1.12 19-Aug-2023  rillig make: add more details to error message about invalid lines
 1.11 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.10 09-Feb-2022  rillig make: fix mistakes, spelling and typos in comments and manual page

No binary change for -DNDEBUG.
 1.9 27-Jan-2022  rillig tests/make: test hash code collisions of variable names

In HashEntry_KeyEquals, the line 'return false' was not covered by any
tests before. Since it is an edge case that two variable names (or
other keys) have the same 32-bit hash code and still differ, better test
for that edge case explicitly since a bug in this place would be rare
and hard to find.
 1.8 02-Nov-2020  rillig make(1): document test for parsing of variable assignments
 1.7 02-Nov-2020  rillig make(1): document undefined behavior in Parse_IsVar

Sigh. If only C could be compiled in strict mode that detects these
out-of-bounds memory accesses.
 1.6 02-Nov-2020  rillig make(1): fix test for parsing obscure variable names

I had forgotten the :U modifier. Without that modifier, there's no
chance that the variable names would come out correctly.
 1.5 02-Nov-2020  rillig make(1): add tests for parsing ob obscure variable names
 1.4 18-Oct-2020  rillig make(1): sort variables in debug output

This way it's easier to see whether an expected variable is missing, or
to compare the values of related variables, since they usually share a
common prefix. Any sorting criterion is better than the hash code.

Sorting the variables by name changed the order of the output in
varname.mk. That test didn't test anything meaningful, it was just a
playground to understand and demonstrate the current implementation of
how the variables are stored, therefore it has been removed.
 1.3 05-Sep-2020  rillig make(1): add test for intentional hash collision for variable names

Hash collisions may slow down make in certain special situations. There
is no point though in maliciously triggering such a situation since
anyone who can inject values into makefiles can easily run shell
commands using the :!cmd! modifier or similar mechanisms. Crafting
variable names just to slow down make is thus not an attack vector.
 1.2 16-Aug-2020  rillig make(1): describe the purpose of each newly added unit test dummy
 1.1 16-Aug-2020  rillig make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.
 1.14.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.5 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.4 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.3 01-Jun-2023  rillig branches: 1.3.2;
tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.2 26-Jul-2020  rillig make(1): fix off-by-one error in Var_Parse for dynamic variables
 1.1 26-Jul-2020  rillig make(1): add test for off-by-one error in Var_Parse
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 11-Jan-2025  rillig make: replace "Malformed conditional" with "Variable is undefined"

Evaluating a conditional such as ".if ${UNDEF}" produced a "Malformed
conditional" error, even though the form of the conditional was correct,
it was the content of the variable that was wrong.

Replace this message with the more accurate "Variable is undefined",
revealing which of the possibly many variables is actually undefined.
 1.9 06-Aug-2024  rillig make: in error message about conditionals, use single quotes

Single quotes are used less often in the conditionals themselves, which
leads to fewer confusions.
 1.8 19-Nov-2023  rillig branches: 1.8.2;
tests/make: replace 'variable expressions' with 'expressions'
 1.7 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.6 01-Jun-2023  rillig tests/make: clean up comments, extend a few tests
 1.5 22-Feb-2021  rillig make: update constant names in comments

No functional change.
 1.4 04-Feb-2021  rillig make: rename context and ctxt to scope

This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.

Renaming the variable 'ctxt' was trivial since that word is used nowhere
else. In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope. It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.
 1.3 21-Nov-2020  rillig make(1): add test for dynamic variable with modifiers in global context
 1.2 13-Sep-2020  rillig make(1): add test for dynamic variable with modifiers in Var_Parse
 1.1 26-Jul-2020  rillig make(1): add test for off-by-one error in Var_Parse
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.21 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.20 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.19 29-Mar-2025  rillig make: let unknown ":O" modifiers fall back to the ":from=to" modifier

Inspired by https://bugs.freebsd.org/285726, which concerns the ":t"
modifier instead.

This means that future extensions to the ":O" modifier must not contain
a "=" anywhere, otherwise they may break existing code.
 1.18 29-Mar-2025  rillig make: in a stack trace with details and includes, list the current file
 1.17 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.16 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.15 20-Jul-2024  rillig make: remove wrong error message about an undefined variable
 1.14 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.13 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.12 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.11 20-Apr-2024  rillig branches: 1.11.2;
make: provide more context information for parse/evaluate errors
 1.10 19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.9 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.8 14-Feb-2023  rillig make: remove redundant type VarParseResult

No functional change.
 1.7 24-Aug-2022  rillig make: prevent future out-of-bounds errors when parsing expressions

A modifier in an expression ends not only at the next ':' or at the
closing '}' or ')', but also at the end of the string.

Previously, testing for the end of the string had been done separately,
which was error-prone since 2006-05-11, when indirect modifiers were
introduced. Since then, it was possible that the string terminator '\0'
was accidentally skipped in cases where the loop condition only tested
for the ending character. When parsing indirect modifiers, the ending
character is indeed '\0', but when parsing direct modifiers, it is '}'
or ')'.

A welcome side effect is that in the case of unclosed expressions such
as '${VAR:Modifier', the amount of error messages is reduced from 2 or 3
to only 1. The removed error messages were wrong and thus confusing
anyway.
 1.6 24-Aug-2022  rillig tests/make: test misleading error messages on unclosed expressions

The error messages say 'Unknown modifier' or 'Bad modifier', which is
not entirely correct. The modifier in itself is valid, it's just that
make doesn't expect the end of the string after the modifier.
 1.5 24-Jan-2022  rillig tests/make: demonstrate that the 'static' in Var_Parse has an effect
 1.4 23-Feb-2021  rillig make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character. Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is. The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.
 1.3 20-Dec-2020  rillig make(1): error out on unknown variable modifiers at parse time

Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such. This "error message"
also did not influence the exit status in the default mode but only in
-dL mode. The error message also didn't include any line number
information and was thus rude.
 1.2 01-Dec-2020  rillig make(1): add test for parse errors in variable name in Var_SetWithFlags
 1.1 08-Nov-2020  rillig make(1): add test for expanding variable expressions
 1.11.2.1 02-Aug-2025  perseant Sync with HEAD
 1.26 28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.25 03-May-2025  rillig make: miscellaneous cleanups
 1.24 30-Mar-2025  rillig make: use '"filename" line 123' for locations instead of 'filename:123'

The format 'filename:123' is commonly used for identifying a location in
a file. Text editors recognize it and allow quick navigation through it.
The previous format was specific to make and would have required custom
support in editors.

The new format was already used in stack traces, except for the first
line. Now all lines use the same format.
 1.23 30-Mar-2025  rillig tests/make: fix test for printing the stack trace

Depending on the exact environment in which the test is run, the "./"
path component may or may not be trimmed from the output. Use an
absolute path instead.
 1.22 29-Mar-2025  rillig make: let unknown ":O" modifiers fall back to the ":from=to" modifier

Inspired by https://bugs.freebsd.org/285726, which concerns the ":t"
modifier instead.

This means that future extensions to the ":O" modifier must not contain
a "=" anywhere, otherwise they may break existing code.
 1.21 29-Mar-2025  rillig make: in a stack trace with details and includes, list the current file
 1.20 29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.19 29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.18 20-Jul-2024  rillig make: remove wrong error message about an undefined variable
 1.17 05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.16 05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.15 05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.14 04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.13 02-Jun-2024  rillig branches: 1.13.2;
make: sync VarEvalMode constant names with their debug log names
 1.12 20-Apr-2024  rillig make: provide more context information for parse/evaluate errors
 1.11 19-Nov-2023  rillig tests/make: replace 'variable expressions' with 'expressions'
 1.10 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.9 01-Jun-2023  rillig tests/make: force line-based diagnostics to be listed in the tests

This way, contradictions between the intended output and the actual
output are closer together and have a better chance of being spotted.
 1.8 14-Feb-2023  rillig make: remove redundant type VarParseResult

No functional change.
 1.7 24-Aug-2022  rillig make: prevent future out-of-bounds errors when parsing expressions

A modifier in an expression ends not only at the next ':' or at the
closing '}' or ')', but also at the end of the string.

Previously, testing for the end of the string had been done separately,
which was error-prone since 2006-05-11, when indirect modifiers were
introduced. Since then, it was possible that the string terminator '\0'
was accidentally skipped in cases where the loop condition only tested
for the ending character. When parsing indirect modifiers, the ending
character is indeed '\0', but when parsing direct modifiers, it is '}'
or ')'.

A welcome side effect is that in the case of unclosed expressions such
as '${VAR:Modifier', the amount of error messages is reduced from 2 or 3
to only 1. The removed error messages were wrong and thus confusing
anyway.
 1.6 24-Aug-2022  rillig tests/make: test misleading error messages on unclosed expressions

The error messages say 'Unknown modifier' or 'Bad modifier', which is
not entirely correct. The modifier in itself is valid, it's just that
make doesn't expect the end of the string after the modifier.
 1.5 24-Jan-2022  rillig tests/make: demonstrate that the 'static' in Var_Parse has an effect
 1.4 15-Mar-2021  rillig make: replace enum bit-field with struct bit-field for VarEvalFlags

This makes the code easier to read, especially in var.c. It also makes
debugging sessions easier since some debuggers don't show enum
bit-fields symbolically as soon as more than one bit is set.

The code outside var.c is basically unchanged, except that instead of
passing the individual flags, there are 4 predefined evaluation modes.
These suffice for all practical use cases. Only in the implementation
deep inside var.c, the value of the flags keepDollar and keepUndef
differs.

There is no way of passing the struct to EnumFlags_ToString, which means
the ToString function has to be spelled out explicitly. This allows for
fine-tuning the representation in the debug log, to reduce the amount of
uppercae letters.

No functional change.
 1.3 20-Dec-2020  rillig make(1): error out on unknown variable modifiers at parse time

Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such. This "error message"
also did not influence the exit status in the default mode but only in
-dL mode. The error message also didn't include any line number
information and was thus rude.
 1.2 01-Dec-2020  rillig make(1): add test for parse errors in variable name in Var_SetWithFlags
 1.1 08-Nov-2020  rillig make(1): add test for expanding variable expressions
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 02-Oct-2020  rillig make(1): add tests for parsing and exporting variables

Once again, there are a few surprises deeply hidden inside the edge
cases.
 1.2 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.1 02-Oct-2020  rillig make(1): add tests for parsing and exporting variables

Once again, there are a few surprises deeply hidden inside the edge
cases.
 1.1 25-Sep-2020  rillig make(1): add test for partial expansion of undefined variables
 1.5 07-Jan-2024  rillig make: clean up comments, constify shell name
 1.4 19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.3 04-Nov-2020  rillig make(1): fix typo and reasoning in test varparse-undef-partial.mk
 1.2 27-Sep-2020  rillig make(1): fix CRLF line endings in unit tests
 1.1 25-Sep-2020  rillig make(1): add test for partial expansion of undefined variables
 1.3 08-May-2022  rillig tests/make: remove test varquote

The test varmod-quote-dollar covers the same topic.
 1.2 27-May-2018  christos branches: 1.2.2; 1.2.4;
- Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Revert :Q to work as before.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@
XXX: pullup 8
 1.1 24-May-2018  christos unit test for $ underquoting in :Q modifier
 1.2.4.2 25-Jun-2018  pgoyette Sync with HEAD
 1.2.4.1 27-May-2018  pgoyette file varquote.exp was added on branch pgoyette-compat on 2018-06-25 07:26:11 +0000
 1.2.2.2 09-Jun-2018  martin Pull up following revision(s) (requested by christos in ticket #870):

sys/lib/libgnuefi/Makefile.inc: revision 1.5
external/mit/xorg/xorg-pkg-ver.mk: revision 1.9
sys/arch/i386/stand/lib/Makefile.inc: revision 1.17
sys/compat/common/Makefile.inc: revision 1.25
usr.bin/make/unit-tests/varquote.exp: revision 1.1, 1.2
sys/lib/libsa/Makefile.inc: revision 1.24
usr.bin/make/var.c: revision 1.220
sys/arch/ia64/stand/efi/libefi/Makefile.inc: revision 1.5
sys/arch/hppa/spmath/Makefile.inc: revision 1.10
usr.bin/make/unit-tests/varquote.mk: revision 1.1, 1.2
usr.bin/make/unit-tests/Makefile: revision 1.53
sys/lib/libkern/Makefile.inc: revision 1.45
sys/arch/acorn32/stand/lib/Makefile.inc: revision 1.4
sys/arch/m68k/fpsp/Makefile.inc: revision 1.21
usr.bin/make/make.1: revision 1.273
sys/lib/libz/Makefile.inc: revision 1.17

- Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@

XXX: pullup 8
 1.2.2.1 27-May-2018  martin file varquote.exp was added on branch netbsd-8 on 2018-06-09 15:35:38 +0000
 1.6 08-May-2022  rillig tests/make: remove test varquote

The test varmod-quote-dollar covers the same topic.
 1.5 28-Dec-2021  rillig tests/make: use tabs instead of spaces for indentation
 1.4 16-Dec-2018  christos use %s formats to avoid -flag confusion (from sjg)
 1.3 16-Dec-2018  christos Use printf instead of echo since we can't portably use \ in string (from sjg@)
http://pubs.opengroup.org/onlinepubs/009695399/utilities/echo.html
 1.2 27-May-2018  christos branches: 1.2.2; 1.2.4; 1.2.6;
- Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Revert :Q to work as before.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@
XXX: pullup 8
 1.1 24-May-2018  christos unit test for $ underquoting in :Q modifier
 1.2.6.1 10-Jun-2019  christos Sync with HEAD
 1.2.4.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.2.4.2 25-Jun-2018  pgoyette Sync with HEAD
 1.2.4.1 27-May-2018  pgoyette file varquote.mk was added on branch pgoyette-compat on 2018-06-25 07:26:11 +0000
 1.2.2.2 09-Jun-2018  martin Pull up following revision(s) (requested by christos in ticket #870):

sys/lib/libgnuefi/Makefile.inc: revision 1.5
external/mit/xorg/xorg-pkg-ver.mk: revision 1.9
sys/arch/i386/stand/lib/Makefile.inc: revision 1.17
sys/compat/common/Makefile.inc: revision 1.25
usr.bin/make/unit-tests/varquote.exp: revision 1.1, 1.2
sys/lib/libsa/Makefile.inc: revision 1.24
usr.bin/make/var.c: revision 1.220
sys/arch/ia64/stand/efi/libefi/Makefile.inc: revision 1.5
sys/arch/hppa/spmath/Makefile.inc: revision 1.10
usr.bin/make/unit-tests/varquote.mk: revision 1.1, 1.2
usr.bin/make/unit-tests/Makefile: revision 1.53
sys/lib/libkern/Makefile.inc: revision 1.45
sys/arch/acorn32/stand/lib/Makefile.inc: revision 1.4
sys/arch/m68k/fpsp/Makefile.inc: revision 1.21
usr.bin/make/make.1: revision 1.273
sys/lib/libz/Makefile.inc: revision 1.17

- Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@

XXX: pullup 8
 1.2.2.1 27-May-2018  martin file varquote.mk was added on branch netbsd-8 on 2018-06-09 15:35:38 +0000
 1.2 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.1 20-Aug-2014  apb Add tests for VAR != command.
 1.4 09-Nov-2020  rillig make(1): move test for != assignments to var-op-shell
 1.3 04-Jul-2020  rillig make(1): add post-processing for tests

By defining SED_CMDS.${test}, a test can do additional post-processing
on its output, for example to normalize paths or error messages.

The Makefile for the tests now follows the common style to have all
relevant definitions at the top of the file, and all the implementation
details at the bottom.

By using the += instead of backslashed lists, it becomes easier to
comment out a single test, either temporarily or permanently (such as
the POSIX tests).

The :C modifier has been replaced with the simpler :S, some :S modifiers
have been replaced with simpler := modifiers.

The postprocessing commands have been extracted from the actual command.
This makes editing and commenting them easier.
 1.2 10-Apr-2015  sjg export-all.mk should be including export.mk
sadly some shells do not grok named signals.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.5 09-Nov-2020  rillig make(1): move test for != assignments to var-op-shell
 1.4 24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.3 24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.2 10-Apr-2015  sjg export-all.mk should be including export.mk
sadly some shells do not grok named signals.
 1.1 21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).

RSS XML Feed