Commit Graph

16677 Commits

Author SHA1 Message Date
rillig
9be4bfa647 make(1): add test for missing error handling in .for loop 2020-12-27 09:58:35 +00:00
rillig
eb9a329939 make(1): re-export variables from the actual make process
Since make uses vfork if available, re-exporting the variables happens
in the address space of the main process anyway, so there is no point in
mentioning anything about "our client process" anywhere.
2020-12-27 05:16:26 +00:00
rillig
0134a24c0d make(1): add test for expansion errors in jobs mode
Since compat mode and jobs mode are implemented separately and vary in
lots of small details, each of them needs to be tested on its own.
2020-12-27 05:11:40 +00:00
rillig
ea8c5a40a4 make(1): align names of VarExportMode with the directives 2020-12-27 05:06:17 +00:00
sjg
a3aef1439d Use .MAKE.DEPENDFILE as makefiles set it 2020-12-26 03:54:48 +00:00
maya
70f2b24ae4 Update to 2021, hopefully less errors made in this year. 2020-12-25 09:02:41 +00:00
dholland
5a724c86b4 List calendar's known calendars explicitly, and only install those.
Prevents build failures caused by installing editor backups and other
such silliness.
2020-12-25 07:00:52 +00:00
rillig
50fdf93be0 make(1): fix a few lint warnings 2020-12-23 14:13:49 +00:00
rillig
f351ad51cc make(1): fix lint warnings for constant condition in DEBUG calls 2020-12-23 14:05:32 +00:00
rillig
ee045a8229 make(1): fix MAKE_RCSID for lint mode
Previously, running lint mode didn't define MAKE_RCSID at all, which
resulted in a syntax error.

While here, reduced the indentation and nesting of the preprocessor
directives.
2020-12-23 14:03:13 +00:00
rillig
dff2a68ecc make(1): rename CmdOpts.lint to strict
When running lint(1) on the code, it defines the preprocessor macro
"lint" to 1, which generated a syntax error in the declaration "Boolean
lint", as that became "Boolean 1".
2020-12-23 13:50:54 +00:00
rillig
b3b6e90160 make(1): remove trailing whitespace in manual page 2020-12-23 13:49:12 +00:00
rillig
060e7853a4 make(1): fix memory leak in Var_Undef (since 2020-12-22) 2020-12-23 13:11:27 +00:00
rillig
82632c2fd8 make(1): fix return type of macro DEBUG
This macro was supposed to return a boolean expression all the time, it
just hadn't been implemented this way.  This resulted in wrong output
for the test sh-flags, in compilation modes -DUSE_UCHAR_BOOLEAN and
-DUSE_CHAR_BOOLEAN, since in ParseCommandFlags, the expression
DEBUG(LOUD) didn't fit into a boolean.
2020-12-22 22:31:50 +00:00
rillig
a542a5a6b7 make(1): allow .undef to undefine multiple variables at once
Since make doesn't support variable names containing spaces, this edge
case is not enough reason to stop this feature.  Having multiple
variable names as arguments nicely aligns with other directives such as
.for and .export.
2020-12-22 20:10:21 +00:00
rillig
ad8b5377ca make(1): add test for undefined variable in dependency declaration 2020-12-22 19:38:44 +00:00
ginsbach
332df7ed8f nl(1): remove superfluous exit
Remove exit(3) call missed when errors were converted to errx(3).
2020-12-22 17:50:55 +00:00
rillig
bd691351f1 make(1): fix comment in test about null bytes in makefiles 2020-12-22 08:57:23 +00:00
rillig
e6d109f2d3 make(1): re-add improved assertion in ParseGetLine 2020-12-22 08:51:30 +00:00
rillig
9582eb4d33 make(1): remove assertion about lines ending with '\n'
It fails the NetBSD build.sh.
2020-12-22 08:31:13 +00:00
rillig
0c15097160 make(1): clean up after test opt-file 2020-12-22 08:23:12 +00:00
rillig
75fb9c6afb make(1): remove needless assignment to line_end in ParseGetLine 2020-12-22 08:10:39 +00:00
rillig
b46e8d7cf5 make(1): fix assertion failure for files without trailing newline
Previously, mmapped files didn't always have the final newline added.
Only those that ended at a page boundary did.

This confused ParseRawLine, which assumed (and since parse.c 1.510 from
moments ago also asserted) that every line ends with a newline, which
allows the code to assume that after a backslash, there is at least one
other character in the buffer, thereby preventing an out-of-bounds read.

This bug had been there at least since parse.c 1.170 from 2010-12-25
04:57:07, maybe even earlier, I didn't check.

Now line_end always points to the trailing newline, which allows
ParseGetLine to overwrite that character to end the string.
2020-12-22 08:05:08 +00:00
rillig
8a4190c0a5 make(1): fix commit number in tests for :gmtime and :localtime 2020-12-22 07:22:39 +00:00
rillig
9b03887383 make(1): prevent undefined behavior in loadfile_mmap
Reading a file without a trailing newline had resulted in an
out-of-bounds write, in the common case where the file is loaded via
mmap.
2020-12-22 06:48:33 +00:00
rillig
f2023805b3 make(1): remove excess newline from parse errors (since 2020-11-01)
For the modifiers :gmtime and :localtime, the excess newline had been
added in var.c 1.631 from 2020-10-31 21:40:20.

For the modifiers :range and :ts, the excess newline had been added in
var.c 1.635 from 2020-11-01 14:36:25.
2020-12-21 21:04:18 +00:00
rillig
ecb61f4a92 make(1): align tests for :localtime with those for :gmtime
These tests had been almost the same before, now they are as similar as
possible again.
2020-12-21 20:47:29 +00:00
rillig
23e24e814c make(1): move tests for :gmtime to parse time
It's easier to have both the expressions and the expected values in a
single file.  This also allows for flexible handling of multiple
acceptable outputs, in this case for 32-bit time_t.
2020-12-21 20:35:17 +00:00
sjg
2de15e97b5 Set default for .MAKE.OS once 2020-12-21 18:22:31 +00:00
rillig
8277081861 make(1): remove redundant parameters from ParseModifierPart 2020-12-21 02:38:57 +00:00
rillig
0743b63f41 make(1): fix garbled output for failed shell command (since 2020-12-20)
Passing a struct as printf argument for the %s conversion doesn't work.
On NetBSD-8.0-x86_64, the output looks normal, but on SunOS-5.9, the
output is garbled, containing bytes 0xFF and 0xFE.

This bug had been introduced in parse.c 1.507 from 2020-12-20 14:52:16.

Thanks to sjg for finding this bug so quickly.
2020-12-21 02:09:34 +00:00
rillig
fcd6900042 make(1): save a few memory allocations in variable expressions 2020-12-21 00:30:13 +00:00
rillig
e6694a528e make(1): switch memory handling from MFStr to FStr
This makes all intermediate strings constant.  For this simple
search-and-replace refactoring, all intermediate locations where the
"current value of the expression" was stored had to be of the type
MFStr.

Using FStr instead of MFStr allows to save a few memory allocations,
which will be done in the follow-up commits.
2020-12-21 00:20:58 +00:00
rillig
be2b5e4446 make(1): clean up memory management for expanding variable expressions
Previously, memory management had been split among several variables.
The general idea was very simple though.  The current value of the
expression needs to be kept in memory, and each modifier either keeps
that value or replaces it with its own newly allocated result, or
var_Error or varUndefined.

Using MFStr, it does not matter anymore that var_Error and varUndefined
are statically allocated since these are assigned using MFStr_InitRefer.

The complexity of the implementation is now closer to the actual
complexity.  Most probably the code can be simplified even more.
2020-12-21 00:11:29 +00:00
rillig
23688beebb make(1): add tests for :tW and :tw modifiers 2020-12-20 23:29:50 +00:00
rillig
b8f5741af7 make(1): use FStr for ApplyModifiersState.newVal
Memory management is still complicated in this area.  To clean this up,
the previous value of the expression needs to be converted to an MFStr
first, and later to an FStr.
2020-12-20 23:27:37 +00:00
rillig
26a72fc416 make(1): add tests for variable modifiers on trailing slashes 2020-12-20 22:57:40 +00:00
rillig
94f06ed7ea make(1): fix undefined behavior in meta_oodate
Do not increment a null pointer.

Do not assign to a variable twice in the same statement.  To be fair,
this may be safe because of the sequence point when the function is
called, but anyway, it looks too close to undefined behavior.
2020-12-20 22:36:40 +00:00
rillig
06ccd6ce96 make(1): reduce scope of cp in meta_oodate
That function is way too long (550 lines) and has too creative variable
names such as fname, fname1, fname2, fname3.
2020-12-20 22:12:36 +00:00
rillig
4b4d56707b make(1): fix declared variable type in printCMDs
No functional changes since StringListNode and GNodeListNode are both
typedefs of a simple generic ListNode.
2020-12-20 22:02:54 +00:00
rillig
5196cc55b0 make(1): omit linear search for command in Compat_RunCommand 2020-12-20 21:07:32 +00:00
rillig
7a800efcdb make(1): remove redundant assignment in ApplyModifier_SysV 2020-12-20 19:51:37 +00:00
rillig
00ba7da94c make(1): error out on unknown variable modifiers at parse time
Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such.  This "error message"
also did not influence the exit status in the default mode but only in
-dL mode.  The error message also didn't include any line number
information and was thus rude.
2020-12-20 19:47:34 +00:00
rillig
d52e9b267b make(1): include line numbers in output of test varmod-edge.mk
Suppressing the line numbers does not provide much benefit, given that
the test file doesn't change often.
2020-12-20 19:37:23 +00:00
rillig
374368e991 make(1): move tests for indirect modifiers around
The next commit will error out on unknown modifiers and influence the
exit status.  The test modmisc.mk contains both parse time tests and run
time tests.  To prevent the latter from being run, the parse error is
moved to varmod-indirect.mk, which only contains parse time tests.
2020-12-20 19:29:06 +00:00
rillig
b1b3d2f62b make(1): remove wrong error message for indirect modifier in lint mode 2020-12-20 19:10:53 +00:00
rillig
4938cf88d2 make(1): document that indirect modifiers fall back to SysV modifiers 2020-12-20 19:02:28 +00:00
rillig
9c42de2852 make(1): remove redundant const declarations for parameters 2020-12-20 18:23:24 +00:00
rillig
ffd320932f make(1): extract ApplySingleModifier from ApplyModifiers 2020-12-20 18:13:50 +00:00
rillig
e2fd21af29 make(1): turn ApplyModifiersState.val into a local variable
This reduces the scope and makes it more obvious at which places this
variable can be changed and how the memory management is done.
2020-12-20 17:22:10 +00:00