Commit Graph

2246 Commits

Author SHA1 Message Date
rillig
30109ee17c make(1): fix comment in test for the || operator in conditions
Thanks to wiz for discovering this.
2020-09-11 06:51:38 +00:00
rillig
56350d0e74 make(1): add tests for really strange edge cases in conditions 2020-09-11 06:47:42 +00:00
rillig
b1c40cfb87 make(1): reorder parameters of condition parsing functions
First the subject, then the options, then the output parameters.
2020-09-11 06:08:10 +00:00
rillig
e3ff571cdb make(1): add missing space in source code 2020-09-11 05:37:40 +00:00
rillig
4f76601a57 make(1): add rationale for evaluating expression after parse error 2020-09-11 05:29:46 +00:00
rillig
32213c9dd0 make(1): fix line numbers from test result of the previous commit 2020-09-11 05:14:21 +00:00
rillig
7233424f15 make(1): add test for evaluation of condition after parse error 2020-09-11 05:12:08 +00:00
rillig
9df3b7b65d make(1): reduce code size in CondParser_Eval 2020-09-11 05:03:20 +00:00
rillig
7ed2c478c5 make(1): use consistent naming scheme for condition parsing functions 2020-09-11 04:57:15 +00:00
rillig
8714c6fe6e make(1): rename CondGetString to CondParser_String
This describes the function's effect more accurately.  The verb "get" is
not commonly associated to having side effects.
2020-09-11 04:40:26 +00:00
rillig
f9beff981e make(1): rename GNodeSuff.gn to gnp
It was confusing to have a field called "gn" that was not a pointer to a
GNode, but a double-pointer to GNode instead.
2020-09-11 04:36:12 +00:00
rillig
fc3e32ef07 make(1): replace *a->b with a->b[0]
This allows the code to be read strictly from left to right.  In most
places this style was already used.
2020-09-11 04:32:39 +00:00
rillig
aa1ee0301b make(1): replace *par->p with par->p[0]
It's a few characters more code than before but can be read strictly
from left to right, which was not possible before.
2020-09-11 04:22:22 +00:00
rillig
f031863371 make(1): rename CondParser.condExpr to p
The prefix "cond" was needed when this struct field was a global
variable.  The main name "expr" was not precise enough since this code is
about parsing a condition, not an expression.

During parsing, this variable does not contain the whole expression but
a pointer to the remaining part of the condition, therefore the name
"expr" had been confusing.
2020-09-11 04:18:44 +00:00
rillig
c69f7fe123 make(1): rename CondLexer to CondParser
The name CondLexer was wrong since this type is about parsing conditions
that can be arbitrarily nested.
2020-09-11 04:07:44 +00:00
rillig
6d5d05ff0f make(1): reduce code size in CondGetString
The pattern is now the usual "test the character, then increment the
pointer", throughout the whole function.
2020-09-10 23:37:54 +00:00
rillig
6ddbc03f29 make(1): skip redundant condExpr-- in CondGetString 2020-09-10 23:27:27 +00:00
rillig
2bf492c8b8 make(1): reduce code size for parsing the || or && operators
On x86_64, accessing [0] generates less code than [1].
2020-09-10 22:47:22 +00:00
rillig
949eb7fd83 make(1): add tests for the |, ||, ||| operators 2020-09-10 22:44:08 +00:00
rillig
89d5f8aeda make(1): add test for the &, && and &&& operators 2020-09-10 22:38:57 +00:00
rillig
1aa23ac7b9 make(1): add test for .SILENT 2020-09-10 21:40:50 +00:00
rillig
fb492da4a2 make(1): add test for .MAKEFLAGS 2020-09-10 21:22:07 +00:00
rillig
aa448ea91d make(1): clean up comments in cond.c 2020-09-08 18:51:23 +00:00
rillig
76c80899be make(1): add CondLexer_SkipWhitespace 2020-09-08 18:10:34 +00:00
rillig
9b7d994754 make(1): rename CondLexer.condPushBack to curr
This variable has some context information from the struct now,
therefore its name can be shorter.
2020-09-08 18:06:27 +00:00
rillig
be4d8db544 make(1): group the condition parsing state into a struct
Instead of having 3 global variables, the struct clearly communicates
that the 3 variables belong together. During debugging, it's easy to
just "p *lex" instead of remembering the names of the 3 former global
variables.

Converting the global variables into a local variable makes it
immediately clear that the functions in this file operate on this
struct.  Keeping the global variables in mind is more difficult.  Having
a local variable also gets rid of the 3 sv_* variables in
Cond_EvalExpression, which were also a sign that these "global
variables" were not that global at all.

This commit only contains the minimal code changes for converting the
variables into a local struct.  It was tempting to add functions like
CondLexer_SkipWhitespace, but this is better left for a follow-up
commit.
2020-09-08 17:55:23 +00:00
rillig
9f6b7470f7 make(1): in CondGetString, replace repeated Buf_Add with Buf_AddStr 2020-09-08 14:51:43 +00:00
rillig
d8bc78b637 make(1): add test for wildcards in dependency declarations 2020-09-08 05:33:05 +00:00
rillig
112c95a538 make(1): fix off-by-one error in SuffExpandChildren
In suff.c r1.144 from yesterday, in the line "cp += nested_p - cp", I
accidentally removed the "- 1".  Since these "- 1" lines lead to slow
execution, each branch now increments the pointer separately by the
actually needed amount.

Fixing this bug posed way more new questions than it answered, and it
revealed an inconsistency in the parser about how characters are to be
escaped, and missing details in the documentation of Var_Parse, as well
as a parse error that unexpectedly doesn't stop make from continuing.
2020-09-08 05:26:21 +00:00
rillig
3bb127c1bf make(1): document that nested braces work as expected now 2020-09-07 19:48:08 +00:00
rillig
db958a8ce2 make(1): extend and explain the test for comments 2020-09-07 19:17:36 +00:00
rillig
107d144dad make(1): explain why each test is run in a sub-make 2020-09-07 18:49:15 +00:00
rillig
1d8529b09b make(1): use consistent spelling for postprocessing 2020-09-07 18:43:59 +00:00
rillig
4144affb22 make(1): add test for the .WAIT dependency source 2020-09-07 18:40:32 +00:00
rillig
cf16582094 make(1): with -dp, print name of the function instead of its address
This makes the output a bit more reproducible.  There are still the file
descriptors, which may differ between different runs, but at least the
nextbuf function is printed using a symbolic name instead of a meaningless address.
Besides loadedfile_nextbuf, the only other function is ForIterate.
2020-09-07 18:37:09 +00:00
rillig
c7c417c4f1 make(1): migrate SuffExpandChildren to Var_ParsePP 2020-09-07 07:15:26 +00:00
rillig
11dcb9bdaf make(1): migrate to Var_ParsePP in Var_Parse and Var_Subst 2020-09-07 07:10:56 +00:00
rillig
11af043635 make(1): migrate ApplyModifiers to Var_ParsePP 2020-09-07 07:04:30 +00:00
rillig
193b2ca5f4 make(1): migrate Var_Parse to Var_ParsePP in ParseDoDependency 2020-09-07 06:58:02 +00:00
rillig
163aaa9b04 make(1): migrate Var_Parse to Var_ParsePP in archive handling 2020-09-07 06:51:05 +00:00
rillig
a41c30d038 make(1): remove unnecessary cp-- from Arch_ParseArchive 2020-09-07 06:44:53 +00:00
rillig
40b40038da make(1): save a strlen call in ForIterate 2020-09-07 06:28:22 +00:00
rillig
83915ab45f make(1): constify local variables in ForIterate 2020-09-07 06:27:29 +00:00
rillig
ae6eb8a7cc make(1): split local variable in ForIterate 2020-09-07 06:26:18 +00:00
rillig
953112797d make(1): remove redundant includes 2020-09-07 06:20:07 +00:00
rillig
28d4e7745c make(1): convert ForEscapes from #define to enum 2020-09-07 06:01:11 +00:00
rillig
ca751b452a make(1): add local variable for escapes to for_substitute
Just for debugging.  No change in code size.
2020-09-07 05:58:08 +00:00
rillig
4186926f7b make(1): clean up comments in job.c 2020-09-07 05:32:12 +00:00
rillig
3f25d2876e make(1): fix archive test when .CURDIR != .PARSEDIR 2020-09-07 05:16:32 +00:00
rillig
fa00c797c6 make(1): add const for Parse_IsVar 2020-09-06 19:34:36 +00:00