Commit Graph

15251 Commits

Author SHA1 Message Date
rillig
47974f53da make(1): replace a few Lst_ForEachUntil with simpler Lst_ForEach 2020-09-26 00:03:29 +00:00
rillig
6513361416 make(1): fix grammar and style in test dep-colon-bug-cross-file 2020-09-25 23:42:43 +00:00
rillig
6686652d07 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.
2020-09-25 23:39:51 +00:00
rillig
f500f93435 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.
2020-09-25 23:35:25 +00:00
rillig
37aa92d20a make(1): fix missing check for duplicate commands in Parse_File 2020-09-25 23:30:16 +00:00
rillig
6c4e4cfc20 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.
2020-09-25 23:24:49 +00:00
rillig
68badaed50 make(1): fix undefined behavior for .MAKEFLAGS: -f file
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.
2020-09-25 23:18:59 +00:00
rillig
0ba7433aaf make(1): inline Lst_ForEachUntil in ParseLine_ShellCommand 2020-09-25 21:13:44 +00:00
rillig
31142950da make(1): extract ParseLine_ShellCommand from Parse_File
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.
2020-09-25 20:57:22 +00:00
rillig
ba0ed6616b make(1): rename variables cp2 to be more expressive 2020-09-25 20:48:23 +00:00
rillig
922e04669b make(1): add test for make() function in conditions 2020-09-25 20:11:06 +00:00
rillig
abab61aa26 make(1): declare strings for suff.c constant 2020-09-25 19:50:04 +00:00
rillig
628f6ff857 make(1): extract parsing of the -dF option into separate function 2020-09-25 19:40:23 +00:00
rillig
489634a883 make(1): extract InitVarTarget from main 2020-09-25 19:24:56 +00:00
rillig
3d82cec1cd make(1): in FindSuffByName, return the suffix instead of a list node
None of the callers was interested in the list node.
2020-09-25 18:58:12 +00:00
rillig
b4b854cf1c make(1): add test for deleting the suffixes during parsing 2020-09-25 18:18:25 +00:00
rillig
ee4bd6beb7 make(1): migrate suff.c from Lst_ForEachUntil to Lst_ForEach 2020-09-25 17:55:19 +00:00
rillig
2db477ba0f make(1): convert int to size_t for string lengths
Just for formal reasons.  There is no practical scenario in which any
filename suffix would grow larger than a few kilocharacters.
2020-09-25 17:14:32 +00:00
rillig
14b8b0f106 make(1): don't use reserved names in type names 2020-09-25 16:28:29 +00:00
rillig
aae3c7b59c make(1): replace Lst_Find with FindSuffByName 2020-09-25 16:27:15 +00:00
rillig
009ae8030a make(1): add tags to some of the unnamed structs
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.
2020-09-25 15:54:50 +00:00
rillig
9e29c82f91 make(1): rename local variables in ParseFuncArg 2020-09-25 15:40:06 +00:00
rillig
8d74bb7e38 make(1): inline ArchFindArchive into ArchStatMember
This avoids a few void pointers and unnecessary function calls.
2020-09-25 14:49:51 +00:00
rillig
cd77909724 make(1): make code in ArchSVR4Entry simpler 2020-09-25 14:41:35 +00:00
rillig
1699bf056f make(1): fix type of local variable in ParseModifierPart
Thanks, Clang-Tidy.
2020-09-25 14:10:09 +00:00
rillig
f7a07e60cf make(1): fix type of local variable in ApplyModifiers
Thanks, Clang-Tidy.
2020-09-25 14:07:12 +00:00
rillig
e1c1f6772d make(1): inline Lst_ForEach in MakeUnmark
By the way, the additional argument to Lst_ForEach was not used at all.
2020-09-25 14:00:17 +00:00
rillig
921a8f8fce make(1): replace a few calls to Lst_Open with simple loops
This avoids relying on the internal iterator of the list, which is
supposed to be removed in the near future.
2020-09-25 06:49:13 +00:00
rillig
96e1152df4 make(1): document details on why JobRun runs .END in compat mode 2020-09-25 06:20:44 +00:00
rillig
4b0186d54c make(1): document expansion of undefined variables in Var_Subst
From reading the code alone, it is not obvious what effects this
innocent-looking code has.
2020-09-25 06:06:15 +00:00
rillig
df955ddda3 make(1): add test for partial expansion of undefined variables 2020-09-25 05:56:59 +00:00
rillig
bb82a5bfdc make(1): rename local variables in Var_Subst
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.
2020-09-25 05:04:51 +00:00
rillig
293320330f make(1): fix build on Debian 9
lst.h:92:5: error: unknown type name 'uint8_t'

It had been broken since the previous commit on 2020-09-24 08:23:29.
2020-09-25 04:18:11 +00:00
rillig
ff01c24104 make(1): make the API of the List partially public
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.
2020-09-24 08:23:29 +00:00
rillig
7e3fe24ae7 make(1): remove redundant function prototypes in suff.c 2020-09-24 08:02:32 +00:00
rillig
1848d6d425 make(1): inline Lst_ForEach in Targ_PrintCmds 2020-09-24 07:59:33 +00:00
rillig
6d249710d5 make(1): migrate printCMD in meta mode to Lst_ForEach 2020-09-24 07:53:32 +00:00
rillig
c51b6afb9a make(1): inline Lst_ForEach for debugging output in search paths 2020-09-24 07:49:58 +00:00
rillig
02ca9f2d7e make(1): migrate MakeTimeStamp and MakeUnmark to Lst_ForEach 2020-09-24 07:37:42 +00:00
rillig
455f274a50 make(1): migrate MakeAddAllSrc to Lst_ForEach 2020-09-24 07:34:35 +00:00
rillig
7a5c7eeb37 make(1): move documentation for MakeAddAllSrc to its correct place 2020-09-24 07:32:03 +00:00
rillig
c3188d97f7 make(1): merge Lst_ForEachFrom into Lst_ForEachUntil 2020-09-24 07:23:26 +00:00
rillig
4ec7405c5c make(1): rename Lst_ForEach to Lst_ForEachUntil
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.
2020-09-24 07:11:29 +00:00
rillig
8410b85440 make(1): refactor add_wait_dep to not use Lst_ForEachFrom anymore
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).
2020-09-24 06:45:59 +00:00
rillig
e9a7cfb4a5 make(1): extend documentation in the varname-empty test 2020-09-24 06:03:44 +00:00
rillig
24f144256a make(1): add tests for spaces in condition functions 2020-09-23 08:11:28 +00:00
rillig
7a66810d3a 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.
2020-09-23 07:54:08 +00:00
rillig
b289a7c0b8 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.
2020-09-23 07:50:58 +00:00
rillig
df5be418ac make(1): merge duplicate code for delayed commands 2020-09-23 07:30:12 +00:00
rillig
b032101167 make(1): inline local variable delim
Now that ParseModifierPart generates the error message itself, there is
no need to keep this variable around since it is read a single time.
2020-09-23 04:27:39 +00:00