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.
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.
Since at least 1993-03-21, adding other makefiles in a .MAKEFILES
dependency has invoked undefined behavior because the command line
arguments were copied directly into the global makefiles variable,
without a proper strdup. Shortly after that, the word list created by
Str_Words (formerly brk_string) was freed.
This applies to both the -f and the -v and -V options. Luckily it is an
edge case to use these options in .MAKEFLAGS at all.
The -T option had already been fixed at 2000-12-30, but not the other
options.
Parsing a single shell command from a line does not belong in
Parse_File, its proper place is in Parse_Line. Having the whole
detailed code inline in Parse_File is even more confusing.
The tags prevent the structs from accidentally becoming compatible
types.
While here, remove a few typedefs for structs that are single-purpose,
since there is no point in abstracting from the actual representation of
these types.
The variable name "str" did not make it clear enough that the pointer is
constantly moving, to parse the given string. The name "p" expresses
this more clearly.
Accessing the fields List.first, List.last, ListNode.prev, ListNode.next
and ListNode.datum in read-only mode should be more efficient than a
whole function call.
All modifications to the lists or their nodes must still happen via
function calls.
This change reduces the code size, makes the code faster to execute and
allows Lst_ForEach to be written inline without the visual overhead of
function calls.
Since the callback function returns a terminating condition, this is not
really a foreach loop.
Many of the calls to Lst_ForEachUntil don't make use of the terminating
condition, and several don't modify the list structurally, which means
they don't need this complicated implementation.
In a follow-up commit, Lst_ForEach will be added back with a much
simpler implementation that iterates over the list naively, without a
terminating condition and without taking the iteration state from
Lst_Open/Lst_Next/Lst_Close into account. The migration to this simpler
implementation will be done step by step since each callback function
needs to be examined closely.
It was the last remaining use of that function outside of lst.c.
While here, clean up the code of add_wait_dep by removing unreachable
code (the GNode lists never contain NULL, only the GNode.commands lists
do that).
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.
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.