Commit Graph

2487 Commits

Author SHA1 Message Date
rillig
8644c277f7 make(1): replace Lst_Open with direct iteration 2020-09-28 23:31:18 +00:00
rillig
35a8c8e3ca make(1): replace += 1 with ++ and -= 1 with --
Just for visual consistency.  The generated code stays exactly the same.
2020-09-28 23:13:57 +00:00
rillig
fa2d8ab826 make(1): migrate Make_ProcessWait from Lst_ForEachUntil to Lst_ForEach 2020-09-28 23:02:02 +00:00
rillig
7cf03aa59d make(1): remove the inline attribute from debug_printf
The code size overhead of a varargs function is much more than I had
expected.  Since GCC 5 didn't inline the function anyway and it is only
used in debug mode, there is no point keeping multiple copies of that
code around.
2020-09-28 22:38:32 +00:00
rillig
37111947f1 make(1): make debug logging simpler
This avoids referring to the debug_file variable in many places where
this implementation detail is not necessary.
2020-09-28 22:23:35 +00:00
rillig
ee41c9d210 make(1): extract logging from ApplyModifiers into separate functions
These two logging blocks are massive enough to disturb the reading flow
of the remaining code.

Even without these two blocks, ApplyModifiers is still 250 lines long,
which is quite much.
2020-09-28 21:11:05 +00:00
rillig
99967cf4ab make(1): move variable modifier :sh into separate function 2020-09-28 21:01:53 +00:00
rillig
e3e4182775 make(1): make debug logging in var.c compatible to C90
The ... ellipsis for macros is only available since C99.
2020-09-28 20:55:20 +00:00
rillig
ae6e2b2c4b make(1): make debugging code shorter 2020-09-28 20:46:11 +00:00
sjg
2f6ec61b00 Revert last 2020-09-28 03:34:07 +00:00
sjg
858c94d56b more unit-tests 2020-09-28 03:32:51 +00:00
sjg
af1c8532d3 Remove unnecessary dieQuietly calls 2020-09-28 02:06:27 +00:00
sjg
d9de394581 Ensure that parse errors report 'stopped in' 2020-09-28 01:24:34 +00:00
rillig
22b1a300bf make(1): format job.h consistently 2020-09-28 00:13:03 +00:00
rillig
c22794195d make(1): split Job.jobPipe into 2 separate fields
Just because these file descriptors have to be in an array when they are
created is not reason enough to keep this array and a few access macros
in the Job struct.  It's better to have separate fields, as they can be
documented independently.
2020-09-28 00:06:36 +00:00
rillig
1937e04f2b make(1): in JobCreatePipe, use descriptive field names 2020-09-27 23:56:25 +00:00
rillig
4b03128094 make(1): fix indentation in JobCreatePipe 2020-09-27 23:52:02 +00:00
rillig
596f47a11c make(1): rewrite documentation of Job
The comment above a struct is supposed to give a high-level overview.
The previous comment didn't do that but instead listed the struct fields
in declaration order in a numbered list, which was not helpful.
2020-09-27 23:12:12 +00:00
rillig
74e0563954 make(1): improve documentation of CachedDir and Dir_AddDir 2020-09-27 22:17:07 +00:00
rillig
c4def5ee7a 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.
2020-09-27 21:35:16 +00:00
rillig
611c8d45dc make(1): mark test for the :Ox variable modifier as probabilistic
It fails very seldom, but it can.
2020-09-27 20:13:44 +00:00
rillig
84d053a33b make(1): add test for merging long lines of job output 2020-09-27 20:11:33 +00:00
rillig
f468c552f6 make(1): remove nonexistent function from header 2020-09-27 19:17:03 +00:00
rillig
0490d42245 make(1): fix type of Shell.noPLen 2020-09-27 19:15:43 +00:00
rillig
2da4d4059e make(1): reduce line noise in Job_ParseShell
The generated code is exactly the same.
2020-09-27 19:13:46 +00:00
rillig
23b5e3ef8a make(1): fix indentation in Job_ParseShell 2020-09-27 19:06:47 +00:00
rillig
228b243e5a make(1): add test cases for the :range variable modifier 2020-09-27 18:11:31 +00:00
rillig
c5520b1066 make(1): fix punctuation and add paragraphs in config.h comments 2020-09-27 17:17:01 +00:00
rillig
304dea8c2e make(1): in the Buffer functions, rename bp to buf
It's not necessary to emphasize on the pointerness of the variable since
that's obvious from the context.
2020-09-27 16:59:02 +00:00
rillig
a7bebbf776 make(1): rename Buf_Size to Buf_Len
The new name better matches the field name Buffer.len as well as the
variables around the calls to this function.
2020-09-27 16:52:22 +00:00
rillig
886c644e5d make(1): prefer positive array index in Buf_AddByte
Ideally the condition for allocating more memory would have been
(old_len + 2 > bp->cap) since that's the actually intended wording.  But
GCC 5 neglected to generate good code for that on x86_64, so be it.
2020-09-27 16:38:32 +00:00
rillig
a549307932 make(1): rename Buffer fields
It was confusing to have a function Buf_Size that returns buf->count
even though there is also buf->size.
2020-09-27 16:21:06 +00:00
rillig
f139c2a2ab make(1): replace direct access to Buffer fields with inline function
This way, renaming the fields of the buffer is restricted to only buf.h
and buf.c.
2020-09-27 16:10:07 +00:00
rillig
60d7c828b9 make(1): inline Lst_ForEachUntil in Make_ExpandUse
The tricky detail here is that the current node from the iteration is
removed if it is no longer needed.

The Lst_FindDatum that has been removed was both inefficient and
misleading since it could never return null, yet there was a null check
for it.  The callback API from Lst_ForEachUntil would have required to
define a custom struct for passing this parameter to the callback
function, in addition to the parent node.

Inlining the whole Lst_ForEach and passing the list node as a parameter
is much more obvious.
2020-09-27 13:27:50 +00:00
rillig
234523181b 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.
2020-09-27 13:18:30 +00:00
rillig
bd99e52e66 make(1): inline Lst_ForEachUntil when parsing dependency lines
This avoids a few operations on void pointers.
2020-09-27 12:42:09 +00:00
rillig
fbb9ffc12c make(1): remove redundant null checks for the active targets
Before August 2020, the Lst library passed null pointers through.  This
was a confusing design pattern that has been removed since.  Now the Lst
functions fail fast on null pointers.

The 'targets' list is one of the few places where there is indeed an
optional list that may sometimes be null.  Back then, there was not
enough inline documentation to understand when the targets list was null
and when it wasn't.

Now that the documentation is there, the redundant and thereby
misleading null checks are no longer useful.
2020-09-27 12:26:23 +00:00
rillig
8cbf8c1227 make(1): inline PrintNode
Having a separate function had only been necessary for Lst_ForEachUntil.
2020-09-27 12:10:51 +00:00
rillig
8a70bc7074 make(1): inline Lst_ForEachUntil in ParseDoDependency 2020-09-27 12:05:04 +00:00
rillig
8f714173e8 make(1): inline Lst_ForEachUntil in Targ_PrintNodes
Printing a node does not modify the structure of the node, therefore the
additional housekeeping of Lst_ForEachUntil is not needed here.

Inlining the callback function also removes a lot of pointer stuff that
is more difficult to read than necessary.
2020-09-27 11:53:03 +00:00
rillig
405c56c525 make(1): inline Lst_ForEachUntil in Compat_Make
This avoids the extra local function and a few conversions to void
pointers, to gain additional type safety.

The code in Compat_RunCommand does not modify gn->commands structurally,
therefore it does not need the extra complexity of Lst_ForEachUntil.  It
does have access to a list node to exactly this list.  This list node is
only used to set the command to NULL after processing it, not for
removing the node from the list.
2020-09-27 11:43:46 +00:00
rillig
f393c9dcac make(1): rename local variable in MakeNodes
By convention, list nodes are named ln to distinguish them from GNodes,
which are called gn.
2020-09-27 11:39:02 +00:00
rillig
bdbb6e0ce2 make(1): make parameter of Compat_RunCommand const 2020-09-27 11:37:19 +00:00
rillig
1430a31b22 make(1): clean up comments in job.c and make.c 2020-09-27 11:14:03 +00:00
rillig
4ae53a3e65 make(1): fix CRLF line endings in unit tests 2020-09-27 09:53:41 +00:00
mrg
fd2e38eaf1 fix usr.bin/make build (which uses more warnings):
remove static only prototype TargPrintOnlySrc().
PrintOnlySources() does not return a value, make it void.
2020-09-27 01:07:12 +00:00
rillig
d449168a6a make(1): revert migration from Lst_ForEachUntil to Lst_ForEach
There is a crucial difference between these functions, in that
Lst_ForEachUntil can cope with a few concurrent modifications while
iterating over the list.  This is something that Lst_ForEach doesn't do.

This difference led to a crash very early in NetBSD's build.sh.
2020-09-26 17:39:45 +00:00
rillig
073f669ad5 make(1): inline and remove LstNode_Prev and LstNode_Next
These functions made the code larger than necessary.  The prev and next
fields are published intentionally since navigating in a doubly-linked
list is simple to do and there is no need to wrap this in a layer of
function calls, not even syntactically.  (On the execution level, the
function calls had been inlined anyway.)
2020-09-26 17:15:20 +00:00
rillig
5a9725dde8 make(1): inline Lst_ForEach in Targ_PrintGraph 2020-09-26 17:02:11 +00:00
rillig
d8a580cdaf make(1): replace a few Lst_ForEachUntil with simpler Lst_ForEach 2020-09-26 16:55:58 +00:00