head 1.13; access; symbols netbsd-11-0-RC4:1.13 netbsd-11-0-RC3:1.13 netbsd-11-0-RC2:1.13 netbsd-11-0-RC1:1.13 perseant-exfatfs-base-20250801:1.13 netbsd-11:1.13.0.2 netbsd-11-base:1.13 netbsd-10-1-RELEASE:1.7 perseant-exfatfs-base-20240630:1.8 perseant-exfatfs:1.8.0.2 perseant-exfatfs-base:1.8 netbsd-10-0-RELEASE:1.7 netbsd-10-0-RC6:1.7 netbsd-10-0-RC5:1.7 netbsd-10-0-RC4:1.7 netbsd-10-0-RC3:1.7 netbsd-10-0-RC2:1.7 netbsd-10-0-RC1:1.7 netbsd-10:1.7.0.6 netbsd-10-base:1.7 cjep_sun2x-base1:1.7 cjep_sun2x:1.7.0.4 cjep_sun2x-base:1.7 cjep_staticlib_x-base1:1.7 cjep_staticlib_x:1.7.0.2 cjep_staticlib_x-base:1.7; locks; strict; comment @# @; 1.13 date 2025.06.12.20.07.59; author rillig; state Exp; branches; next 1.12; commitid TvXDsjyvKE04KDYF; 1.12 date 2025.06.12.19.02.32; author rillig; state Exp; branches; next 1.11; commitid KVFL0xqz3NxBnDYF; 1.11 date 2025.03.30.09.51.50; author rillig; state Exp; branches; next 1.10; commitid veGmSzVhPiW2G4PF; 1.10 date 2024.07.04.20.18.40; author rillig; state Exp; branches; next 1.9; commitid 75IS4XOhTa8VOygF; 1.9 date 2024.07.04.17.47.54; author rillig; state Exp; branches; next 1.8; commitid mjDGVMgldk7QYxgF; 1.8 date 2024.04.01.12.26.02; author rillig; state Exp; branches 1.8.2.1; next 1.7; commitid 6yJlbUI3gsuler4F; 1.7 date 2020.12.22.08.51.30; author rillig; state Exp; branches; next 1.6; commitid fE2rhEYpFDnjuIAC; 1.6 date 2020.12.22.08.05.08; author rillig; state Exp; branches; next 1.5; commitid rEwwsomO4O0L0IAC; 1.5 date 2020.12.07.00.53.30; author rillig; state Exp; branches; next 1.4; commitid gdHtmNFghgo1SJyC; 1.4 date 2020.12.06.20.33.44; author rillig; state Exp; branches; next 1.3; commitid qMxlPA9tbRCCQIyC; 1.3 date 2020.12.06.19.18.26; author rillig; state Exp; branches; next 1.2; commitid wsz3FbKFOgg3tIyC; 1.2 date 2020.12.06.19.00.48; author rillig; state Exp; branches; next 1.1; commitid VDtgxQOwp17knIyC; 1.1 date 2020.08.16.12.07.51; author rillig; state Exp; branches; next ; commitid coEgPk3hgfeYGhkC; 1.8.2.1 date 2025.08.02.05.58.36; author perseant; state Exp; branches; next ; commitid 23j6GFaDws3O875G; desc @@ 1.13 log @make: add program name to stack traces from sub-makes @ text @value value line-with-trailing-whitespace make: (stdin):1: Zero byte read from file in make[1] in directory "" *** Error code 2 (continuing) `all' not remade because of errors. Stop. make: stopped making "all" in unit-tests exit status 1 @ 1.12 log @make: add quotes to "in directory" line in stack traces The other lines in stack traces use quotes as well. @ text @d5 1 a5 1 in directory "" @ 1.11 log @make: use '"filename" line 123' for locations instead of 'filename:123' The format 'filename:123' is commonly used for identifying a location in a file. Text editors recognize it and allow quick navigation through it. The previous format was specific to make and would have required custom support in editors. The new format was already used in stack traces, except for the first line. Now all lines use the same format. @ text @d5 1 a5 1 in directory @ 1.10 log @make: on error, print the targets to be made This helps to understand situations with several nested sub-makes in varying directories. @ text @d4 1 a4 1 make: "(stdin)" line 1: Zero byte read from file @ 1.9 log @make: add more context information to error messages In case of a parse error or evaluation error, print the variable value in addition to the variable name, to see the effects of previous expression modifiers. In nested make calls, print the current directory at the bottom of a stack trace, as that information is otherwise hard to get in a parallel build spanning multiple directories. @ text @d10 1 a10 1 make: stopped in unit-tests @ 1.8 log @make: exit immediately after reading a null byte from a makefile The chance of other garbage bytes in such a file is just too high. @ text @d5 1 @ 1.8.2.1 log @Sync with HEAD @ text @d4 1 a4 2 make: (stdin):1: Zero byte read from file in make[1] in directory "" d9 1 a9 1 make: stopped making "all" in unit-tests @ 1.7 log @make(1): re-add improved assertion in ParseGetLine @ text @d5 1 a5 3 make: Fatal errors encountered -- cannot continue make: stopped in unit-tests *** Error code 1 (continuing) @ 1.6 log @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. @ text @d3 1 @ 1.5 log @make(1): fix exit status in -k mode if a dependency fails Whether in -k mode or not, the exit status tells whether all requested targets were made or not. If a dependency could not be made, the main target was not made as well, therefore the exit status must be nonzero in such a case. This part of the code lacked proper unit tests until today. The unit test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing to compare the output over time. In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed twice in a row, for whatever reason ... (40 minutes later) ... If I had just made the two commands for 'all' and '.END' more distinguishable. Back in 2003, the local variables for .END had not been initialized, instead the .END node was run with the local variables of the last preceding node. In this case, that node was 'all', therefore ${.TARGET} had obviously expanded to 'all'. Somewhere in 2004, the shell commands were no longer run with the -e flag, which resulted in the "exit status $?" line to be printed in cases that had stopped early before. Somewhere in 2005, the local variables for the .END node had been fixed. The variable ${.TARGET} now had the value '.END', just as expected. In addition, the dependencies for the .END node were made, although without getting their proper local variables. This resulted in the output "Making out of nothing" instead of the expected "Making end-dep out of nothing". Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR", the error code of the failed 'end-dep' was first reported as "*** Error code 1 (continuing)". To compensate for this improvement, a new bug had been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR" had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it exited with status 0, thereby ignoring errors in the .END node. Somewhere in 2008, some of the error messages (but not all) were directed to stderr instead of stdout. The actual output stayed the same though. Somewhere in 2011, the dependency of the .END node got its own local variables, and ${.TARGET} now expanded to 'end-dep', as expected. Somewhere in 2016, the two empty lines between the "*** Error code 1 (continuing)" and the "Stop." got compressed into a single empty line. On 2020-12-07 (that is, today), the exit status 1 has been restored in the error cases, after it had been wrong for at least 14 years. @ text @d2 1 @ 1.4 log @make(1): error out on null bytes in makefiles Makefiles are text files, they must not contain null bytes. The previous code in this area was rotten anyway. It assumed that buf_end could be NULL even if buf_ptr was a valid pointer, which is no longer true, probably since a few years already. Continuing parsing after a null byte does not make sense. If there's a null byte in a text file, that file is corrupted, and parsing it leads to unintended effects easily. Therefore the only sensible action is to stop parsing immediately. The check whether cf->readMore could be null was outdated as well, which previously made the fatal error impossible to reach. Because of the missing unit tests, nobody noticed this though. The "exit status 0" in opt-file.exp is worring but that's due to another bug and will be fixed in a follow-up commit. @ text @d7 4 a10 1 exit status 0 @ 1.3 log @make(1): add test for makefile containing null bytes @ text @d2 5 a6 3 make: "(stdin)" line 1: warning: Zero byte read from file, skipping rest of line. va VALUE2 @ 1.2 log @make(1): test parsing a makefile that ends in a backslash @ text @d2 3 @ 1.1 log @make(1): add dummies for fine-grained tests, one per single feature The test names have been derived from the current manual page. All these tests are dummies right now, and the code from the existing tests will be moved into the new tests step by step. This is done to prevent modmisc, escape, varmod-edge and varmisc from growing without any bounds, and to reduce the side-effects of one test to the others. @ text @d1 1 @