summaryrefslogtreecommitdiff
path: root/usr.bin/make/suff.c
AgeCommit message (Collapse)Author
2023-02-14make: clean up calls to Var_Substrillig
None of the calls to Var_Subst used the return value, and the return value was always VPR_OK. No functional change.
2023-02-14make: reduce complexity of evaluating expressionsrillig
No functional change.
2022-03-04Fix some unused warningssjg
2022-03-03make: improve comments and a parameter namerillig
No binary change.
2022-01-07make: remove redundant function parameter in suffix handlingrillig
Now that mainNode is globally visible, there is no need to pass it through function parameters. No functional change.
2022-01-07make: merge duplicate variables for the main targetrillig
No functional change.
2022-01-01make: remove redundant comments from ParseDependencySourceSpecialrillig
2021-12-28make: extract OP_NOTARGET into separate functionrillig
No binary change, except for line numbers in assertions.
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: fix memory leak when evaluating ${.SUFFIX} (since yesterday)rillig
2021-12-12Add .SUFFIXES as read-only variable.sjg
References to ${.SUFFIXES} are handled dynamically in ParseVarnameLong by calling Suff_NamesStr. The variable cannot be set normally. Reviewed by: rillig
2021-12-09make: remove period from end of error messages and warningsrillig
The majority of the existing error messages and warnings does not include a period at the end. Follow this style consistently.
2021-11-28make: move duplicate function Buf_AddFlag to buf.crillig
It is used only for debug output, therefore performance doesn't matter. No functional change.
2021-11-28make: inline SuffixFlags_ToString into Suffix_Printrillig
This gets rid of the string literal "none" and the complicated memory handling. No functional change.
2021-11-28make: inline SuffixFlags into the Suffix itselfrillig
No functional change.
2021-11-28make: replace bloated bit-set-to-string code with simple coderillig
It was a nice idea to implement a bit-set using an enum type and have a generic ToString function for them. In the end, the implementation involved really heavy preprocessor magic and was probably difficult to understand. Replace all the code with a few bits of straight-forward preprocessor magic that can be readily understood by just looking 5 lines around, instead of digging through 130 lines of lengthy macro definitions. Curiously, this reduces the binary size even though the 3 ToString functions now have a few lines of duplicate code and there are more explicit function calls. The ToString functions are only seldom used, so the additional memory allocation is acceptable. No functional change.
2021-07-31make: fix lint warningsrillig
The string functions from str.h are declared as 'static __unused' when compiled with GCC, but lint explicitly undefines __GCC__ during preprocessing. Therefore, make those functions inline, to prevent warnings that they are unused. The macro UNCONST is used in a few places, and (again) since lint undefines __GCC__, that macro expanded to a simple type cast, which lint warned about. To prevent this warning, implement UNCONST as a function that works everywhere and hides the type cast. In filemon_open, the code for closing F->in was obviously unreachable. No functional change.
2021-04-04make: rename a few functions to be more descriptiverillig
No functional change.
2021-04-03make: use C99 bool type instead of defining its ownrillig
No functional change.
2021-03-15make: replace enum bit-field with struct bit-field for VarEvalFlagsrillig
This makes the code easier to read, especially in var.c. It also makes debugging sessions easier since some debuggers don't show enum bit-fields symbolically as soon as more than one bit is set. The code outside var.c is basically unchanged, except that instead of passing the individual flags, there are 4 predefined evaluation modes. These suffice for all practical use cases. Only in the implementation deep inside var.c, the value of the flags keepDollar and keepUndef differs. There is no way of passing the struct to EnumFlags_ToString, which means the ToString function has to be spelled out explicitly. This allows for fine-tuning the representation in the debug log, to reduce the amount of uppercae letters. No functional change.
2021-03-15make: rename VARE_NONE to VARE_PARSE_ONLYrillig
The name 'NONE' described the bit pattern, which was not useful to understand its meaning. Omitting VARE_WANTRES only parses the expression, without evaluating any part of it. No functional change, not even in debug mode since Enum_FlagsToString always returns "none" for all-bits-unset.
2021-02-23make: improve error message for unclosed modifierrillig
Replace "variable specification" with the more modern "variable expression", reduce the number of parentheses, output more than a single character for modifiers, make it obvious that in expressions such as ${:Serror}, the "" means a variable name.
2021-02-05make: in the Var_ functions, move the scope to the frontrillig
This change provides for a more natural reading order in the code. Placing the scope first makes it immediately clear in which context the remaining parameters are interpreted. No functional change.
2021-02-04make: rename context and ctxt to scoperillig
This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL and VAR_CMDLINE were renamed. Renaming the variable 'ctxt' was trivial since that word is used nowhere else. In the comments though, each occurrence of the word 'context' had to be checked individually since the word 'context' was not only used for referring to a variable scope. It is also used to distinguish different situations where characters are escaped in a certain way ('parsing context') and in a few other expressions.
2021-02-03make: replace Global_SetExpand with Global_Set for constant namesrillig
2021-02-03make: use shortcut functions Global_SetExpand and Global_AppendExpandrillig
There are many places where global variables are set or appended to. To reduce clutter and code size, encode the VAR_GLOBAL in the function name. The word Expand in the function names says that the variable name is expanded. In most of the cases, this is not necessary, but there are no corresponding functions Global_Set or Global_Append yet. Encoding the information whether the name is expanded or not in the function name will make inconsistencies obvious in future manual code reviews. Letting the compiler check this by using different types for unexpanded and expanded variable names is probably not worth the effort. There are still a few bugs to be fixed, such as in SetVar, which expands the variable name twice in a row.
2021-01-30make(1): reduce boilerplate for printing bit sets in debug moderillig
No functional change.
2021-01-24make(1): convert SearchPath to structrillig
This prepares for making dotLast a simple struct member instead of a fake CachedDir, which is easier to understand.
2021-01-23make(1): rename local variable in FindCmdsrillig
2021-01-23make(1): remove the remaining beasts from the commentsrillig
2021-01-23make(1): rename Dir_AddDir, reorder parameters of SearchPath_ToFlagsrillig
2021-01-23make(1): rename Dir_Expand to SearchPath_Expandrillig
The main subject of this function is the search path. In this search path the pattern is expanded.
2021-01-10make(1): consistently use boolean expressions in conditionsrillig
Most of the make code already followed the style of explicitly writing (ptr != NULL) instead of the shorter (ptr) in conditions. The remaining 50 instances have been found by an experimental, unpublished check in lint(1) that treats bool expressions as incompatible to any other scalar type, just as in Java, C#, Pascal and several other languages. The only unsafe operation on Boolean that is left over is (flags & FLAG), for an enum implementing a bit set. If Boolean is an ordinary integer type (the default), some high bits may get lost. But if Boolean is the same as _Bool (by compiling with -DUSE_C99_BOOLEAN), C99 6.3.1.2 defines that a conversion from any scalar to the type _Bool acts as a comparison to 0, which cannot lose any bits.
2021-01-09make(1): fix lint warningsrillig
2020-12-30make(1): format multi-line commentsrillig
2020-12-20make(1): return FStr from Var_Parserillig
This reduces the number of variable declarations at the call sites.
2020-12-18make(1): spell nonexistent consistentlyrillig
2020-12-13make(1): add str_basename to reduce duplicate coderillig
The function basename from POSIX has a few unfortunate properties, it is allowed to return a pointer to static memory. This is too unreliable, therefore this trivial own implementation.
2020-12-07make(1): actually fix the use-after-free bug and the double-freerillig
The use-after-free bug had been there since 2020-11-22, the double-free bug since a few minutes.
2020-12-07make(1): fix use-after-free in -DDEBUG_SRC mode (since 2020-11-22)rillig
2020-12-06make(1): inline macros for debug loggingrillig
No changes to the resulting binary, except for the line numbers in assertions.
2020-12-05make(1): define constants for enum zero-valuesrillig
2020-12-05make(1): extract ExpandChildrenRegular from ExpandChildrenrillig
2020-12-05make(1): indent suff.c with tabs instead of spacesrillig
ExpandChildren is way too deeply nested.
2020-11-29make(1): reduce memory allocation for dirSearchPathrillig
2020-11-29make(1): reduce memory allocations in suffix storagerillig
2020-11-29make(1): reduce memory allocations in suffix handlingrillig
2020-11-29make(1): reduce memory allocation in ExpandWildcards for suffixesrillig
2020-11-29make(1): reduce memory allocation in ExpandChildren for suffixesrillig