Commit Graph

15820 Commits

Author SHA1 Message Date
rillig b418af7851 make(1): fix manual page regarding numerical comparisons
Make uses double, not int, for comparing things.
2020-11-01 20:24:45 +00:00
rillig ad6e88dcd8 make(1): add more tests for the variable modifier :M
Despite its popularity and usefulness, the variable modifier :M is
implemented so weirdly that it's not surprising people get confused
about make's parsing and escaping rules.
2020-11-01 19:49:28 +00:00
rillig 623cfc02b8 make(1): add test for surprising parsing result of the :M modifier 2020-11-01 19:25:23 +00:00
rillig e24143bc70 make(1): move test flags to test varmod-match-escape.mk 2020-11-01 19:02:22 +00:00
rillig aebcc64d87 make(1): revert unintended change from previous commit 2020-11-01 18:48:13 +00:00
rillig b6c94d2092 make(1): fix indentation of source code 2020-11-01 18:45:49 +00:00
rillig 0735b81a78 make(1): rename JobMatchShell to FindShellByName
The word 'match' was too unspecific.
2020-11-01 17:58:17 +00:00
rillig 40014b1e5a make(1): negate NoExecute to GNode_ShouldExecute 2020-11-01 17:47:26 +00:00
rillig 0056a7c168 make(1): reduce amount of work in test job-output-long-lines.mk
The effect that some of the separator lines start at the end of another
line is still visible.
2020-11-01 17:29:13 +00:00
rillig 1cfab1491d make(1): extract EscapeShellDblQuot from JobPrintCommand 2020-11-01 17:07:03 +00:00
rillig d4af0258b7 make(1): extract ParseRunOptions from JobPrintCommand 2020-11-01 16:57:02 +00:00
wiz 878fe969c6 Properly quote '\;' in example. 2020-11-01 16:47:29 +00:00
kim c3c5cb3347 Document the -not operator 2020-11-01 16:34:02 +00:00
rillig 480f175d0a make(1): treat malformed :range, :ts and :[...] as errors
Before, integer overflow in the :[1..2] modifier had not been detected,
and the actual behavior varied between ILP64 and LP64I32 machines.

Before, the :ts modifier accepted character literals like \012345 and
\x1F600, which don't fit in a single character and were thus truncated.

Before, the :range modifier issued an "Unknown modifier" error message
for :range=x, which was not quite correct.  The error message in this
case is now "Invalid number".
2020-11-01 14:36:25 +00:00
rillig a1853aaad8 make(1): add tests for the variable modifiers :[words] and :range 2020-11-01 13:55:31 +00:00
rillig 9e39890f47 make(1): add tests for parsing errors in the :ts variable modifier 2020-11-01 13:28:50 +00:00
rillig dca12caf9b make(1): add more tests for the variable modifier :range, edge cases 2020-11-01 13:10:22 +00:00
rillig 9b24a7eb93 make(1): clean up comments in ApplyModifier_Words 2020-11-01 12:34:45 +00:00
rillig 13ce664461 make(1): add test for out-of-bounds separator in variable modifier :ts 2020-11-01 11:50:11 +00:00
rillig 4d77f4ef94 make(1): demonstrate parsing bugs in test moderrs.mk
When a malformed variable expression is parsed, the remaining part of
the expression is passed unmodified to the output.  This is unexpected
and wrong.
2020-11-01 10:56:08 +00:00
rillig e415fa14ba make(1): renumber the tests in moderrs.mk, remove duplicates 2020-11-01 10:53:58 +00:00
rillig 87f799f9fd make(1): make test names in moderrs.mk more descriptive 2020-11-01 10:52:09 +00:00
rillig 598a8d140a make(1): precisely describe the expected output in the test moderrs.mk
By making "want:" the same length as "make:", the remaining text in
these lines can be compared easily.
2020-11-01 10:50:22 +00:00
rillig 897c76e5e1 make(1): separate sections of moderrs.mk with empty lines 2020-11-01 10:46:34 +00:00
rillig 79ecbf9746 make(1): add section headings to the test moderrs.mk 2020-11-01 10:12:38 +00:00
mrg 947dbbbacf add support for '-not': GNU and thus worldly scripts compatibility. 2020-11-01 05:38:29 +00:00
rillig d9cc6ff4db make(1): in lint mode, exit with error status on errors
Calling Parse_Error during parsing has always led to a nonzero exit
status.  Calling Parse_Error later, when expanding the shell commands,
has had no effect on the exit status.  Neither had calling Error.

To make make a reliable tool, it has to report errors as they occur.
Enable this strict behavior in lint mode for now.  Lint mode has to be
enabled explicitly, preserving the default behavior.
2020-11-01 00:24:57 +00:00
rillig 8e37eea5e0 make(1): clean up StrContainsWord 2020-10-31 23:44:42 +00:00
rillig 3172a2f718 make(1): fix out-of-bounds pointer in ParseTrackInput 2020-10-31 23:39:01 +00:00
rillig 33a4a1ca23 make(1): rename parameter of Var_Value 2020-10-31 23:23:22 +00:00
rillig d5ef4ec39d make(1): improve local variable name in ParseTrackInput
By the way, the Address Sanitizer that ran over this code on 2015-11-26
didn't find the other out-of-bounds bug.  Most probably the Address
Sanitizer only detected obvious bugs in the actual test data, and there
was no test case in which .MAKE.MAKEFILES was shorter than the newly
added makefile.
2020-10-31 23:10:06 +00:00
rillig 31dbea1d44 make(1): fix off-by-one bug in ParseTrackInput (since 2015-11-26) 2020-10-31 23:01:23 +00:00
rillig 97ce2a0641 make(1): add test for off-by-one bug in ParseTrackInput 2020-10-31 22:55:35 +00:00
rillig 625b0ad57d make(1): document possible undefined behavior in trace.c with .CURDIR 2020-10-31 22:05:56 +00:00
rillig da69a0e26b make(1): document local variable in parse.c more precisely 2020-10-31 21:52:56 +00:00
rillig 819ecf5275 make(1): make parsing of the :gmtime and :localtime modifiers stricter
These variable modifiers accept an optional timestamp in seconds, to
select which date to print.  This feature is only used very rarely.  The
NetBSD build doesn't use it at all, and the FreeBSD build mainly uses
the plain modifiers :gmtime and :localtime, but not their optional
argument :gmtime=1500000000.

Therefore, this change is not going to affect many builds.  Those that
are indeed affected had been wrong all the time anyway.

At parse time, these errors stop the build, as intended.  After that,
when the actual shell commands of the targets are expanded and run,
these errors don't stop anything, the build just continues as if nothing
had happened.  This is a general problem with Var_Parse, see the many
"handle errors" markers in the code.  Another problem is that on parse
errors, parsing continues and spits out spurious strings of the form
"mtime" and "ocaltime".  This as well is a general problem with error
handling in make.

ok sjg
2020-10-31 21:40:20 +00:00
rillig 8ac215b8e4 make(1): add test for debug log for expansion of curly braces 2020-10-31 21:30:03 +00:00
rillig 48500bfeb0 make(1): mark the output in test dir.mk with a prefix
This is needed to distinguish it from the debug log, which will be added
in the next commit.
2020-10-31 21:12:36 +00:00
sjg 5b5c22709e Main_SetObjdir is first called for curdir which may be readonly
Skip access check if path is curdir.
This ensures that all proper initialization is done at least once.

If path is not curdir it should be writable to be useful.

Reviewed by: rillig
2020-10-31 21:09:22 +00:00
rillig d4b0b9ea9e make(1): add more tests for the variable modifier :localtime 2020-10-31 20:30:06 +00:00
rillig a6a1909faa make(1): add test for :gmtime with space before the number of seconds 2020-10-31 19:55:26 +00:00
rillig 102185fb1d make(1): add tests for error handling in the :gmtime variable modifier 2020-10-31 19:48:23 +00:00
rillig 70f61825b1 make(1): format #include directives consistently 2020-10-31 18:41:07 +00:00
rillig b58481850f make(1): remove unused code from needshell
Since usr.bin/xinstall no longer uses this code, there is no need to
keep the second parameter.
2020-10-31 18:20:00 +00:00
rillig be7ddd2cbe make(1): rename ismeta to is_shell_metachar
The old name was too broad.
2020-10-31 18:17:08 +00:00
rillig 3b9a5011ac make(1): remove debug logging for the :Q variable modifier
The same information is already logged in LogAfterApply.
2020-10-31 18:14:59 +00:00
rillig 3296a96508 make(1): fix local variable names in ParseModifierPart 2020-10-31 18:05:16 +00:00
rillig 090539ffb6 make(1): remove dead code for filename expansion using curly braces
Any string containing curly braces is already handled in the very first
if statement.
2020-10-31 17:39:20 +00:00
rillig 64e1789ba6 make(1): revert requiring a writable objdir
The change in main.c 1.413 broke the NetBSD build.sh if it uses a
read-only source tree, as in the daily builds.

Original commit:
https://mail-index.netbsd.org/source-changes/2020/10/31/msg123560.html

Build log:
make warning: /home/source/ab/HEAD/src: Permission denied.
[1]   Segmentation fault      "${make}" -m ${T...
2020-10-31 16:13:00 +00:00
rillig 818c0eaf62 make(1): rewrite VarIsDynamic to VarnameIsDynamic
The condition for the context is the same for both short and long names,
therefore move that condition to the only caller.

Clean up the comment and move its parts to the appropriate places.  The
"with the dollar sign escaped" part had been wrong already in 1993, and
it didn't get better over time.
2020-10-31 15:23:52 +00:00