Commit Graph

366 Commits

Author SHA1 Message Date
sjg e56a2ae17f Fix some unused warnings 2022-03-04 23:17:16 +00:00
rillig 4f4e6f996b make: improve comments and a parameter name
No binary change.
2022-03-03 19:55:27 +00:00
rillig bccb6308ed make: remove redundant function parameter in suffix handling
Now that mainNode is globally visible, there is no need to pass it
through function parameters.

No functional change.
2022-01-07 20:54:45 +00:00
rillig 68291d4356 make: merge duplicate variables for the main target
No functional change.
2022-01-07 20:50:35 +00:00
rillig 45f3b8b58c make: remove redundant comments from ParseDependencySourceSpecial 2022-01-01 19:44:05 +00:00
rillig 62a0c54367 make: extract OP_NOTARGET into separate function
No binary change, except for line numbers in assertions.
2021-12-28 14:06:42 +00:00
rillig a8e14f3653 make: format comments according to /usr/share/misc/style
Assisted by indent(1), with manual corrections due to its many remaining
bugs.

No functional change.
2021-12-15 12:58:01 +00:00
rillig a53f37541a make: use consistent indentation for statements and continuations
No binary change, except for line numbers in assertions in suff.c.
2021-12-15 12:24:13 +00:00
rillig aba504eebb make: fix memory leak when evaluating ${.SUFFIX} (since yesterday) 2021-12-13 00:33:33 +00:00
sjg 4587900247 Add .SUFFIXES as read-only variable.
References to ${.SUFFIXES} are handled dynamically in
ParseVarnameLong by calling Suff_NamesStr.

The variable cannot be set normally.

Reviewed by: rillig
2021-12-12 20:45:48 +00:00
rillig 5734774c16 make: remove period from end of error messages and warnings
The majority of the existing error messages and warnings does not
include a period at the end.  Follow this style consistently.
2021-12-09 20:13:09 +00:00
rillig a3eb6a7f70 make: move duplicate function Buf_AddFlag to buf.c
It is used only for debug output, therefore performance doesn't matter.

No functional change.
2021-11-28 22:48:06 +00:00
rillig 64e3676e50 make: inline SuffixFlags_ToString into Suffix_Print
This gets rid of the string literal "none" and the complicated memory
handling.

No functional change.
2021-11-28 22:38:17 +00:00
rillig 2c14336b4d make: inline SuffixFlags into the Suffix itself
No functional change.
2021-11-28 22:27:35 +00:00
rillig f6612c3de4 make: replace bloated bit-set-to-string code with simple code
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-11-28 18:58:58 +00:00
rillig cc821a91f9 make: fix lint warnings
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-07-31 09:30:17 +00:00
rillig 730db1a03f make: rename a few functions to be more descriptive
No functional change.
2021-04-04 10:05:08 +00:00
rillig 244fd9f4c4 make: use C99 bool type instead of defining its own
No functional change.
2021-04-03 11:08:40 +00:00
rillig 2f8026b0e5 make: replace enum bit-field with struct bit-field for VarEvalFlags
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-15 12:15:03 +00:00
rillig 4fd3cf6eed make: rename VARE_NONE to VARE_PARSE_ONLY
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-03-15 11:41:07 +00:00
rillig 985b27d91a make: improve error message for unclosed modifier
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-23 15:56:29 +00:00
rillig 835b4db442 make: in the Var_ functions, move the scope to the front
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-05 05:15:12 +00:00
rillig 4dc2cd5c6f make: rename context and ctxt to scope
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-04 21:42:46 +00:00
rillig 87686000da make: replace Global_SetExpand with Global_Set for constant names 2021-02-03 08:08:18 +00:00
rillig 3ec10f8db6 make: use shortcut functions Global_SetExpand and Global_AppendExpand
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-02-03 08:00:36 +00:00
rillig 95ef2024c3 make(1): reduce boilerplate for printing bit sets in debug mode
No functional change.
2021-01-30 15:48:42 +00:00
rillig f1a32e5707 make(1): convert SearchPath to struct
This prepares for making dotLast a simple struct member instead of a
fake CachedDir, which is easier to understand.
2021-01-24 20:11:55 +00:00
rillig 7c9be8409a make(1): rename local variable in FindCmds 2021-01-23 12:35:22 +00:00
rillig c17fa239cb make(1): remove the remaining beasts from the comments 2021-01-23 12:25:35 +00:00
rillig c66282df08 make(1): rename Dir_AddDir, reorder parameters of SearchPath_ToFlags 2021-01-23 11:34:41 +00:00
rillig 34d4e06a16 make(1): rename Dir_Expand to SearchPath_Expand
The main subject of this function is the search path.  In this search
path the pattern is expanded.
2021-01-23 10:48:49 +00:00
rillig 31940a95cd make(1): consistently use boolean expressions in conditions
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-10 21:20:46 +00:00
rillig 462cbdfa37 make(1): fix lint warnings 2021-01-09 16:06:09 +00:00
rillig b754dcb0cc make(1): format multi-line comments 2020-12-30 10:03:16 +00:00
rillig 7b3d8cbe3a make(1): return FStr from Var_Parse
This reduces the number of variable declarations at the call sites.
2020-12-20 13:38:43 +00:00
rillig 6e84975ccd make(1): spell nonexistent consistently 2020-12-18 15:47:34 +00:00
rillig 7f604d4793 make(1): add str_basename to reduce duplicate code
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-13 20:14:48 +00:00
rillig 01c0fcab45 make(1): actually fix the use-after-free bug and the double-free
The use-after-free bug had been there since 2020-11-22, the double-free
bug since a few minutes.
2020-12-07 01:27:08 +00:00
rillig dc1759932a make(1): fix use-after-free in -DDEBUG_SRC mode (since 2020-11-22) 2020-12-07 01:24:41 +00:00
rillig 9df90c54cf make(1): inline macros for debug logging
No changes to the resulting binary, except for the line numbers in
assertions.
2020-12-06 10:49:02 +00:00
rillig ee9186d684 make(1): define constants for enum zero-values 2020-12-05 18:38:02 +00:00
rillig 1dc8f59fce make(1): extract ExpandChildrenRegular from ExpandChildren 2020-12-05 17:12:02 +00:00
rillig a4609fef81 make(1): indent suff.c with tabs instead of spaces
ExpandChildren is way too deeply nested.
2020-12-05 16:59:47 +00:00
rillig 6f66206a01 make(1): reduce memory allocation for dirSearchPath 2020-11-29 01:40:26 +00:00
rillig d9f6df7cec make(1): reduce memory allocations in suffix storage 2020-11-29 01:30:38 +00:00
rillig c91d221250 make(1): reduce memory allocations in suffix handling 2020-11-29 01:24:18 +00:00
rillig ddcc472c42 make(1): reduce memory allocation in ExpandWildcards for suffixes 2020-11-29 01:19:11 +00:00
rillig 26c51dd6fc make(1): reduce memory allocation in ExpandChildren for suffixes 2020-11-29 01:16:37 +00:00
rillig 4c46d4bd3d make(1): reduce memory allocation in suffix candidate search 2020-11-29 01:12:45 +00:00
rillig 4e0b769f19 make(1): reduce memory allocation in suffix rule handling 2020-11-29 01:10:08 +00:00