Commit Graph

346 Commits

Author SHA1 Message Date
rillig
985b27d91a 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.
2021-02-23 15:56:29 +00:00
rillig
835b4db442 make: in the Var_ functions, move the scope to the front
This change provides for a more natural reading order in the code.
Placing the scope first makes it immediately clear in which context the
remaining parameters are interpreted.

No functional change.
2021-02-05 05:15:12 +00:00
rillig
4dc2cd5c6f 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.
2021-02-04 21:42:46 +00:00
rillig
87686000da make: replace Global_SetExpand with Global_Set for constant names 2021-02-03 08:08:18 +00:00
rillig
3ec10f8db6 make: use shortcut functions Global_SetExpand and Global_AppendExpand
There are many places where global variables are set or appended to.  To
reduce clutter and code size, encode the VAR_GLOBAL in the function
name.

The word Expand in the function names says that the variable name is
expanded.  In most of the cases, this is not necessary, but there are no
corresponding functions Global_Set or Global_Append yet.

Encoding the information whether the name is expanded or not in the
function name will make inconsistencies obvious in future manual code
reviews. Letting the compiler check this by using different types for
unexpanded and expanded variable names is probably not worth the effort.
There are still a few bugs to be fixed, such as in SetVar, which expands
the variable name twice in a row.
2021-02-03 08:00:36 +00:00
rillig
95ef2024c3 make(1): reduce boilerplate for printing bit sets in debug mode
No functional change.
2021-01-30 15:48:42 +00:00
rillig
f1a32e5707 make(1): convert SearchPath to struct
This prepares for making dotLast a simple struct member instead of a
fake CachedDir, which is easier to understand.
2021-01-24 20:11:55 +00:00
rillig
7c9be8409a make(1): rename local variable in FindCmds 2021-01-23 12:35:22 +00:00
rillig
c17fa239cb make(1): remove the remaining beasts from the comments 2021-01-23 12:25:35 +00:00
rillig
c66282df08 make(1): rename Dir_AddDir, reorder parameters of SearchPath_ToFlags 2021-01-23 11:34:41 +00:00
rillig
34d4e06a16 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.
2021-01-23 10:48:49 +00:00
rillig
31940a95cd make(1): consistently use boolean expressions in conditions
Most of the make code already followed the style of explicitly writing
(ptr != NULL) instead of the shorter (ptr) in conditions.

The remaining 50 instances have been found by an experimental,
unpublished check in lint(1) that treats bool expressions as
incompatible to any other scalar type, just as in Java, C#, Pascal and
several other languages.

The only unsafe operation on Boolean that is left over is (flags &
FLAG), for an enum implementing a bit set.  If Boolean is an ordinary
integer type (the default), some high bits may get lost.  But if Boolean
is the same as _Bool (by compiling with -DUSE_C99_BOOLEAN), C99 6.3.1.2
defines that a conversion from any scalar to the type _Bool acts as a
comparison to 0, which cannot lose any bits.
2021-01-10 21:20:46 +00:00
rillig
462cbdfa37 make(1): fix lint warnings 2021-01-09 16:06:09 +00:00
rillig
b754dcb0cc make(1): format multi-line comments 2020-12-30 10:03:16 +00:00
rillig
7b3d8cbe3a make(1): return FStr from Var_Parse
This reduces the number of variable declarations at the call sites.
2020-12-20 13:38:43 +00:00
rillig
6e84975ccd make(1): spell nonexistent consistently 2020-12-18 15:47:34 +00:00
rillig
7f604d4793 make(1): add str_basename to reduce duplicate code
The function basename from POSIX has a few unfortunate properties, it is
allowed to return a pointer to static memory.  This is too unreliable,
therefore this trivial own implementation.
2020-12-13 20:14:48 +00:00
rillig
01c0fcab45 make(1): actually fix the use-after-free bug and the double-free
The use-after-free bug had been there since 2020-11-22, the double-free
bug since a few minutes.
2020-12-07 01:27:08 +00:00
rillig
dc1759932a make(1): fix use-after-free in -DDEBUG_SRC mode (since 2020-11-22) 2020-12-07 01:24:41 +00:00
rillig
9df90c54cf make(1): inline macros for debug logging
No changes to the resulting binary, except for the line numbers in
assertions.
2020-12-06 10:49:02 +00:00
rillig
ee9186d684 make(1): define constants for enum zero-values 2020-12-05 18:38:02 +00:00
rillig
1dc8f59fce make(1): extract ExpandChildrenRegular from ExpandChildren 2020-12-05 17:12:02 +00:00
rillig
a4609fef81 make(1): indent suff.c with tabs instead of spaces
ExpandChildren is way too deeply nested.
2020-12-05 16:59:47 +00:00
rillig
6f66206a01 make(1): reduce memory allocation for dirSearchPath 2020-11-29 01:40:26 +00:00
rillig
d9f6df7cec make(1): reduce memory allocations in suffix storage 2020-11-29 01:30:38 +00:00
rillig
c91d221250 make(1): reduce memory allocations in suffix handling 2020-11-29 01:24:18 +00:00
rillig
ddcc472c42 make(1): reduce memory allocation in ExpandWildcards for suffixes 2020-11-29 01:19:11 +00:00
rillig
26c51dd6fc make(1): reduce memory allocation in ExpandChildren for suffixes 2020-11-29 01:16:37 +00:00
rillig
4c46d4bd3d make(1): reduce memory allocation in suffix candidate search 2020-11-29 01:12:45 +00:00
rillig
4e0b769f19 make(1): reduce memory allocation in suffix rule handling 2020-11-29 01:10:08 +00:00
rillig
997298cde5 make(1): reduce memory allocation in suffix handling
The function Lst_MoveAll previously freed the source list.  This
function was only used in a few places, and none of them really needed
the allocation.
2020-11-29 00:54:43 +00:00
rillig
9bc32ab45b make(1): replace Dir_Destroy with SearchPath_Free
The function Dir_Destroy is an implementation detail of the cached
directories, and it should not be exported to the other modules.  The
search paths, on the other hand, are the high-level API that may be used
by the other modules, as the concept of search paths is documented in
the manual page.
2020-11-28 22:56:01 +00:00
rillig
2c1f8b4c34 make(1): rename some Dir functions to SearchPath
These functions have the search path as their main subject.
2020-11-28 22:13:56 +00:00
rillig
673efe08f3 make(1): reduce pointer indirection for GNode.implicitParents 2020-11-28 19:22:32 +00:00
rillig
eac02ebf12 make(1): reduce pointer indirection for GNode.cohorts 2020-11-28 19:20:03 +00:00
rillig
04763a4014 make(1): reduce pointer indirection for GNode.order_pred and order_succ 2020-11-28 19:16:53 +00:00
rillig
5a24a58276 make(1): reduce memory allocation for GNode.parents and GNode.children 2020-11-28 19:12:28 +00:00
rillig
e93d02d95f make(1): remove pointer indirection from GNode.commands
Just to save a few memory allocations.  No noticeable effect on the
performance though.
2020-11-28 18:55:52 +00:00
rillig
7179b788e7 make(1): align end-of-line comments with tabs 2020-11-23 20:41:20 +00:00
rillig
1830d415fa make(1): add HashSet type
This makes the code for handling suffixes simpler since it doesn't need
the clumsy API of HashTable_CreateEntry anymore.
2020-11-23 18:07:10 +00:00
rillig
fcbb2eb2b1 make(1): fix endless loop when resolving circular suffix rules 2020-11-23 14:47:12 +00:00
rillig
87b846ef9e make(1): make control flow simpler in FindThem 2020-11-23 14:04:28 +00:00
rillig
2a440a6f23 make(1): fix DEBUG_SRC logging in FindThem
The node is also removed from the list if it is neither found in the
nodes nor in the file system.  The logging did not reflect this.
2020-11-23 13:52:27 +00:00
rillig
492003234b make(1): add high-level API for CandidateSearcher
This avoids passing invisible void pointers around in Lst_Append.  It
also provides a convenient place to document what it means to "add a
candidate to the searcher".
2020-11-22 22:58:43 +00:00
rillig
1f8c1f89fc make(1): add CandidateSearcher to resolve transformation rules
Having a simple list of candidates is not enough.  It is currently
possible to construct endless loops with huge memory usage, as
demonstrated in suff-transform-endless.mk.

To fix this, a straight-forward idea is to remember which candidates
have already been searched and to not search them again.

This also fixes a small inconsistency in the code.  Most parameters had
been named slst (the s came from a time when Candidate was named Src),
except for Suff_FindDeps, where the variable was named srcs.  The
confusing thing about this was that the name srcs is used throughout the
file for a different purpose.  Only in FindThem there were two
parameters of the same type, which made this even more confusing.
2020-11-22 22:27:19 +00:00
rillig
3c2d904d39 make(1): add more debugging for searching transformation rules 2020-11-22 21:34:34 +00:00
rillig
a8fc26104f make(1): add debug logging for setting and resetting the main target
The suffix code still doesn't behave as expected.  Make sure that at
least setting the main target works as expected.  It does, and the added
debug logging provides further hints for debugging the suffix handling
code.
2020-11-22 20:29:53 +00:00
rillig
b9640f2714 make(1): rename local variable in UpdateTargets 2020-11-22 18:13:52 +00:00
rillig
0f3758f11f make(1): extract FindDepsLib from FindDepsRegularKnown 2020-11-22 17:20:15 +00:00
rillig
d5db985cf3 make(1): rename Candidate.pref to prefix
The new name nicely matches the .PREFIX variable.
2020-11-22 12:05:20 +00:00