summaryrefslogtreecommitdiff
path: root/usr.bin/make/cond.c
AgeCommit message (Collapse)Author
2023-06-23make: clean up variable and function namesrillig
No functional change.
2023-06-23make: warn about malformed patterns in ':M', ':N' and '.if make(...)'rillig
These patterns shouldn't occur in practice, as their results are tricky to predict. Generate a warning for now, and maybe an error later. Reviewed by sjg@.
2023-06-21Allow guard targets to use variables.sjg
I commonly use __${.PARSEDIR:tA}__ where a unique guard is needed, __${.PARSEDIR}__ is also useful in many cases. Combination of patch from rillig and mine
2023-06-20make: allow targets to be used as multiple-inclusion guardsrillig
This style is used by FreeBSD, among others.
2023-06-19make: add tests for full code coverage of multiple-inclusion guardsrillig
2023-06-19make: clean up code for skipping files with multiple-inclusion guardrillig
No functional change.
2023-06-19make: if a makefile is protected by a guard, only include it oncerillig
"looks reasonable" sjg@
2023-06-16make: remove parameter names from function declarationsrillig
No binary change.
2023-06-01make: shorten function names, clean up commentsrillig
No functional change.
2023-02-14make: reduce complexity of evaluating expressionsrillig
No functional change.
2023-02-14make: don't interpret the return value of Var_Parserillig
The return value of Var_Parse is largely redundant to the returned string. The idea behind the type VarParseResult was to migrate all call sites to checking this return value instead of the returned string, but that hasn't happened. Instead, the additional type only added more complexity. There was a single place where that return value was actually used, when parsing conditions. And even in that case, ignoring the VarParseResult added back an error message that previously hid bugs, in the test cond-token-plain.mk. Even though these error messages are redundant in the other tests, they don't hurt as they don't happen often.
2022-09-24make: clean up tracking of depth of nested .if directivesrillig
The variable cond_min_depth was redundant. It was only accessed while parsing the makefiles. Merging it into struct IncludedFile removes the possible confusion between cond_min_depth and including_cond_min_depth. No functional change.
2022-09-24make: fix variable and function names relating to .if nestingrillig
The previous names were confusing since they suggested that cond_depth instead of cond_min_depth would be saved and restored. No functional change.
2022-09-24make: move Cond_save_depth above Cond_restore_depthrillig
This puts the functions into chronological order, as saving happens before restoring. No functional change.
2022-09-24make: use assertion for internal error conditionrillig
When the nesting level of conditionals is restored to an unreasonably high value, the error message "0 open conditionals" doesn't make sense.
2022-09-23Cond_reset_depth just use cond_min_depthsjg
To avoid errors from unclosed conditionals on .break it is sufficient to just set cond_depth = cond_min_depth. Patch from rillig
2022-09-08make: list comparison operators in declaration orderrillig
This allows a tiny optimization in the switch statement. No functional change.
2022-09-04make: add more details to error message for numeric comparisonrillig
Before: String comparison operator must be either == or != After: Comparison with '>=' requires both operands 'no' and '10' to be numeric Noticed by martin@ in pkgsrc/textproc/py-pygments.
2022-09-02make: add .break to terminate .for loop earlysjg
When .break is encountered within a .for loop it causes immediate termination. Outside of a .for loop .break causes a parse error. Reviewed by: christos
2022-04-15tests/make: adjust expectations to actual behaviorrillig
The bug in deptgt-silent-jobs.mk has been fixed, the debug logging for comparing conditions and for deleting global variables has changed intentionally.
2022-03-03make: improve comments about parsing and evaluating conditionsrillig
No binary change.
2022-03-03make: improve local variable name in ParseWord in conditionsrillig
That function not only parses function arguments but also bare words, so the name argBuf didn't match anymore. No binary change.
2022-03-03make: make debug logging for comparisons less technicalrillig
2022-02-11make: simplify control flow in CondParser_Comparisonrillig
No functional change.
2022-02-09make: fix mistakes, spelling and typos in comments and manual pagerillig
No binary change for -DNDEBUG.
2022-02-09make: clean up variable namesrillig
No binary change.
2022-01-29make: rename labels in CondParser_Leafrillig
No binary change.
2022-01-15make: replace Var_Value with Var_Exists where applicablerillig
The latter function already existed in 1993, no idea why it was not used. No functional change.
2022-01-14make: inline EvalBarerillig
No functional change.
2022-01-07make: clean up function argument names and commentsrillig
No binary change except for assertion line numbers.
2022-01-07make: remove redundant initializer in CondParser_ComparisonOrLeafrillig
No binary change.
2022-01-02make: clean up nitpicksrillig
In ParseWord, the expressions '*p' and 'ch' are the same. In ParseDependencyTargetWord, clean up a wordy comment and join two conditions. In the test cond-token-number, clarify that make doesn't convert from hex to decimal but only from hex to internal representation. No functional change.
2021-12-30tests/make: demonstrate edge case that evaluates an expression twicerillig
2021-12-30make: remove redundant code from CondParser_ComparisonOrLeafrillig
No functional change.
2021-12-30make: split ParseWord into the actual ParseWord and ParseFuncArgrillig
Combining two similar but fundamentally different parsing tasks in a single function only increased the complexity, of the implementation as well as the call sites. The code makes it obvious now that a function argument is a bare word surrounded by parentheses. The special case of an empty word is only needed for the function argument, it cannot occur in a bare word. The code for that has been moved to the caller. Such an empty word not only occurs for 'defined()' but also for 'defined(${:U})'. No functional change.
2021-12-30make: make ParseWord in condition parser simplerrillig
Merge the two return values (bool, string) into a single return value. As before, the caller cannot observe the difference between a parse error and an empty word, both are handled in the same way. In CondParser_ComparisonOrLeaf, the word cannot be empty since the calling function CondParser_Token already handles all cases that could lead to an empty word. No functional change.
2021-12-30make: internally return false for irrelevant leaves in conditionsrillig
The result of irrelevant leaves is effectively ignored by CondParser_And and CondParser_Or. Use the 'doEval &&' pattern to make the code consistent with CondParser_Comparison and CondParser_FuncCall. No functional change.
2021-12-29make: in irrelevant function calls in conditions, return falserillig
When a condition contains an irrelevant function call, it doesn't matter whether the function call evaluates to true or to false, it will be discarded anyway by either CondParser_And or CondParser_Or. Returning false instead of true makes the code simpler, plus it is more common to return false for irrelevant results. No functional change.
2021-12-29make: use simpler return type for ParseWord in conditionsrillig
No functional change.
2021-12-29make: replace table for function lookup in conditions with simple coderillig
The code for looking up the function from the table forced the compiler to use a specific memory layout. Replacing the table with explicit code provides the compiler more opportunities to optimize the code. Another side effect is that there are fewer pointer operations. Previously, is_token checked that the character after the word does not continue the word, this is now done separately since for the function lookup, this check was unnecessary. The newly added skip_string provides a higher abstraction level, it is no longer necessary to pass the string length as a separate, redundant parameter. No functional change.
2021-12-29make: clean up condition parserrillig
No functional change.
2021-12-29make: merge duplicate types CondEvalResult and CondResultrillig
No binary change.
2021-12-29make: merge duplicate enum constants for CondEvalResult and CondResultrillig
No binary change.
2021-12-29make: remove redundant parameter for evaluating conditionsrillig
No functional change.
2021-12-29make: merge types CondResult and CondEvalResultrillig
No functional change.
2021-12-27make: rename local variables to be simplerrillig
No binary change.
2021-12-27make: clean up commentsrillig
2021-12-15make: format comments according to /usr/share/misc/stylerillig
Assisted by indent(1), with manual corrections due to its many remaining bugs. No functional change.
2021-12-15make: use consistent indentation for statements and continuationsrillig
No binary change, except for line numbers in assertions in suff.c.
2021-12-13make: condense CondParser_ComparisonOprillig
No functional change.