Commit Graph

2198 Commits

Author SHA1 Message Date
rillig
3f25d2876e make(1): fix archive test when .CURDIR != .PARSEDIR 2020-09-07 05:16:32 +00:00
rillig
fa00c797c6 make(1): add const for Parse_IsVar 2020-09-06 19:34:36 +00:00
rillig
78cc09048b make(1): add const to For_Eval and For_Accum 2020-09-06 19:30:53 +00:00
rillig
2d9413362f make(1): clean up For_Eval
* Reduce scope of local variables.
* Remove unnecessary null character test before positive isspace call.
2020-09-06 19:28:49 +00:00
rillig
44d49322ad make(1): properly initialize For structure in For_Eval
Initializing a Buffer or a strlist_t with zero-valued bytes only works
by conincidence, but because it would be the correct way.  In the code
path "missing `in' in for", that zero-filled Buffer is freed using
Buf_Destroy, which could have invoked undefined behavior.
2020-09-06 19:24:12 +00:00
rillig
0244d862b4 make(1): improve documentation in For_Eval 2020-09-06 19:19:49 +00:00
rillig
47ba525800 make(1): fix type of For.short_var 2020-09-06 19:18:16 +00:00
rillig
d2ef6c55f3 make(1): add test for the -de option 2020-09-06 04:35:03 +00:00
rillig
000f3267b7 make(1): replay the changes from v1.283
I accidentally reverted them in v1.284.
2020-09-05 19:11:16 +00:00
rillig
f31746d78f make(1): clean up comments about parsing 2020-09-05 19:07:25 +00:00
rillig
c058562d66 make(1): fix comments about setting .PARSEDIR and .PARSEFILE 2020-09-05 18:41:59 +00:00
rillig
568c2fcd37 make(1): make GetActuallyIncludingFile faster
In deeply nested includes, starting the search from the inner end is
faster since it needs fewer comparisons.
2020-09-05 18:31:03 +00:00
rillig
3dd79b1f4a make(1): fix .INCLUDEDFROMDIR/.INCLUDEDFROMFILE 2020-09-05 18:18:05 +00:00
rillig
118ec9dfc5 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.
2020-09-05 18:13:47 +00:00
rillig
8981885e47 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.
2020-09-05 16:59:19 +00:00
rillig
9378c3ad8d make(1): add tests for some of the special sources 2020-09-05 15:57:12 +00:00
rillig
613d864f26 make(1): fix local variable type in ParseIsEscaped 2020-09-05 15:12:03 +00:00
rillig
6fa639d0d3 make(1): fix return type of ParseIsEscaped 2020-09-05 15:05:08 +00:00
rillig
bc484e3768 make(1): remove redundant prototype for ParseMark 2020-09-05 15:04:09 +00:00
rillig
41034fe6df make(1): remove redundant prototypes for local functions from parse.c 2020-09-05 14:58:07 +00:00
rillig
59980735fc make(1): remove initial size argument from Hash_InitTable
In all but one case this argument was set to auto-detect anyway.  The
one case where it was set was not worth keeping this complicated API.
2020-09-05 13:55:08 +00:00
rillig
09d79112a7 make(1): make Hash_Table independent from -funsigned-char
This only makes a difference for Hash_Table keys outside the ASCII
character set, and these are barely used in practice, if at all.

The effects of this change can only be seen in debug mode, when printing
the full contents of the variable namespaces.  In this output, the order
of the entries might change.

All other use cases stay the same as before.
2020-09-05 13:36:25 +00:00
rillig
42e06d6e82 make(1): add expected test result for hashing variable names 2020-09-05 13:34:19 +00:00
rillig
6544b03ea1 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.
2020-09-05 12:59:07 +00:00
rillig
55c34e75ce make(1): remove trailing whitespace in -dg1 debug output 2020-09-05 06:46:12 +00:00
rillig
95fadeb4d8 make(1): move test for -dg1 from opt-debug-g1 to opt-debug-graph1 2020-09-05 06:36:40 +00:00
rillig
edc462c8ea 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.
2020-09-05 06:25:38 +00:00
rillig
5630da511e make(1): add tests for each debug option 2020-09-05 06:20:50 +00:00
rillig
919ee589c7 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.
2020-09-04 21:08:44 +00:00
rillig
3e8f8a1a29 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.
2020-09-04 20:51:01 +00:00
rillig
09567ebca5 make(1): migrate Var_Parse in CondGetArg to Var_ParsePP 2020-09-04 20:32:34 +00:00
rillig
26222804bc make(1): add more explanation for undefined variable expressions 2020-09-04 20:28:15 +00:00
rillig
a1d05e1e9e 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.
2020-09-04 19:03:38 +00:00
rillig
9cc1256284 make(1): use a stack instead of a list for the nested include path
By using a Stack instead of a Lst, the available API is reduced to the
very few functions that are really needed for a stack.  This prevents
accidental misuse (such as confusing Lst_Append with Lst_Prepend) and
clearly communicates what the expected behavior is.

A stack also needs fewer calls to bmake_malloc than an equally-sized
list, and the memory is contiguous.  For the nested include path, all
this doesn't matter, but the type is so generic that it may be used in
other places as well.
2020-09-04 17:59:36 +00:00
rillig
612b32e506 make(1): unexport For_Iterate
By convention, exported functions have an underscore, and static
functions don't.
2020-09-04 17:35:00 +00:00
rillig
60c2e21286 make(1): add test for the special variable MAKEFILE 2020-09-04 17:05:39 +00:00
rillig
d4bba47099 make(1): fix expected file for archive test
This test is currently disabled, therefore it didn't fail immediately.
2020-09-04 17:03:17 +00:00
rillig
e8702174c8 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.
2020-09-04 06:54:07 +00:00
rillig
cd269e3b78 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.
2020-09-04 05:23:25 +00:00
rillig
a2fc9de97d make(1): add test for expansion of indirect variables in dependencies 2020-09-03 19:50:14 +00:00
rillig
ed3d9167a3 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.
2020-09-03 19:10:56 +00:00
rillig
4a7f0cb429 make(1): migrate ApplyModifier_Defined to Var_ParsePP 2020-09-03 18:53:46 +00:00
rillig
c183963589 make(1): add tests for the :D and :U modifiers
This prepares a refactoring for ApplyModifier_Defined.
2020-09-03 18:52:36 +00:00
rillig
0cc07a3c94 make(1): migrate Var_Parse API to parsing position
The ApplyModifier functions already use this pattern.  For simplicity
and consistency Var_Parse should do the same.  This saves a parameter to
be passed.

The migration takes place step by step, just like for the Lst functions
a few days ago.
2020-09-03 18:19:15 +00:00
rillig
ecb4f44224 make(1): document use of magic values in CondDoEmpty 2020-09-03 17:16:01 +00:00
rillig
4dd5292c3e make(1): add test for the empty function in conditionals 2020-09-03 17:13:42 +00:00
rillig
e3cda9a21a make(1): update documentation for Cond_EvalExpression and Cond_Eval 2020-09-03 16:14:58 +00:00
rillig
da17666427 make(1): make parameter of Cond_Eval and Cond_EvalExpression const 2020-09-03 16:02:02 +00:00
rillig
e010af6e23 make(1): document the value restrictions for Boolean variables
The previous lenient rule came from the sprite.h header that was not
specific to make.  To avoid confusion, only the expected values should
be stored in a Boolean variable.  To help find obvious violations and
inconsistencies, there are different possibilities for the Boolean type,
during development.

In C there is no way to actually enforce this restriction at runtime.
It would be possible in C++, but the code is not ready to be compiled
with a C++ compiler.
2020-09-02 23:42:58 +00:00
rillig
c62bab2173 make(1): improve grouping of the Lst functions
Lst_IsEmpty does not belong in the "create and destroy" group, but in
"query information without modifying anything".

The functions named LstNode_* all belong together.  They do not provide
much abstraction, but still they restrict the API and hide a few struct
fields that are only used internally by Lst_Open/Lst_Close and
Lst_ForEach.

Use consistent wording in the documentation of the functions (list,
node, datum).
2020-09-02 23:33:13 +00:00