summaryrefslogtreecommitdiff
path: root/usr.bin/make/meta.c
AgeCommit message (Collapse)Author
2023-03-28make: declare all common symbols in headers, unexport othersrillig
No functional change.
2023-02-28Use inline function rather that macro BMsjg
2023-02-25meta.c: use macro to access job->bmsjg
and if job is NULL use Mybm. No functional change.
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.
2022-09-28Don't ignore return from snprintf or getcwdsjg
2022-04-15make: do not use __CONCAT and __STRING in meta_neededrillig
Using __CONCAT for identifiers makes it impossible to find their usages easily, as could be seen in targ.c 1.22 from 2001-07-03. It also requires that the parts of the identifier are not macros themselves. No binary change.
2022-03-04Fix some unused warningssjg
2022-02-09make: remove redundant conditionsrillig
A line starting with '======' is parsed as a variable assignment, with an empty variable name and a value starting with '=====', making that condition unreachable. No functional change.
2022-02-08Use a variable to store command line to be filtered.sjg
This avoids any nasty side effects from content of command line. Reviewed by: rillig
2022-02-04make: use unsigned int for line numbers everywhererillig
Previously, some line numbers were stored as signed int while others were stored as size_t. Since line numbers are never negative, use an unsigned type. Since the maximum file size for makefiles is 1 GB (see loadfile), unsigned int is large enough even on 64-bit platforms. Using a single data types reduces the number of type conversions. Using unsigned int improves compatibility with C90 (printf %u instead of %zu), which is needed by bmake, which is derived from usr.bin/make. No functional change.
2022-01-27Allow local variable assignments in dependency linessjg
The variable is set in the context of the target. This syntax has been supported by gmake for ~ever. If necessary a makefile can set .MAKE.TARGET_LOCAL_VARIABLES=false to disable this. Expose GetBooleanExpr so parse.c can use it.
2022-01-26make: clean up eat_dots for meta mode, part 2rillig
At least on OpenBSD, "If the src and dst strings overlap, the behavior is undefined" (since 2013-09-25), so rather use memmove instead. Keep all other bugs for now, for example "/a/b//../" is reduced to "/a/b/" instead of the correct "/a/", and for repeated "/././././" in long paths, the performance is quadratic instead of linear. Inline the two calls to eat_dots, turning the first into a two-liner.
2022-01-26make: clean up eat_dots for meta moderillig
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-15make: remove unnecessary functions for expanding variable namesrillig
In meta mode, the affected variable patterns do not contain a '$'. Outside of meta mode, Global_SetExpand was only called a single time, so inline that call. No functional change.
2022-01-15make: merge duplicate code for expanding variable expressionsrillig
No functional change.
2022-01-15make: remove trailing whitespace in meta.crillig
2022-01-14meta_cmd_cmp: use bool for oncesjg
Just use Buf_Init() some mallocs will be inevitable.
2022-01-13meta.c: add .MAKE.META.CMP_FILTERsjg
On rare occasions it is useful to be able to filter command lines before comparison.
2021-12-13make: fix indentation in meta.crillig
2021-11-27make: remove CONSTCOND comments, lint no longer needs themrillig
2021-10-24Do not ignore write failures.sjg
We should not ignore failure to write to cmdFILE, meta files and filemon. Reviewed by: rillig
2021-08-19make: fix lint warning about strrchr discarding 'const'rillig
No functional change.
2021-08-14make: fix lint warning about strchr removing 'const'rillig
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-02-22make: remove freestanding freeIt variablesrillig
These variables all belong to a string variable. Connect them using FStr, which reduces the number of variables to keep track of. No functional change.
2021-02-05Avoid strdup in mkTempFilesjg
Require caller to pass a buffer and size if they want the tempfile not unlinked. Add Job_TempFile to handle blocking signals around call to mkTempFile, so that meta_open_filemon can use it in jobs mode.
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 some VAR constants to SCOPErillig
The word "context" does not fit perfectly to the variables that are associate with a GNode, as the context is usually something from the outside and the variables are more like properties inherent to the GNode. The term "global context" fits even less. Since the thing where variables are looked up is commonly named a scope, use that term instead. This commit only renames the global variables VAR_GLOBAL, VAR_INTERNAL and VAR_CMDLINE, plus a few very closely related comments. These are: GNode.vars (because of line breaks) GNode_Free (dito) varname-make_print_var_on_error.mk varname-make_print_var_on_error-jobs.mk The debug message in Var_Stats is left as-is since there is no unit test for it yet. The other renamings (variable names "context", "ctxt", as well as further comments) will be done in a follow-up commit.
2021-02-03make: rename Var_Delete to Var_DeleteExpand, Var_DeleteVar to Var_Deleterillig
The function names now follow the naming scheme from the other functions that handle variables. There are several calls that remain syntactically unchanged but that omit the call to strchr('$') now. Since all these calls use constant variable names, there is no functional change.
2021-02-03make: replace Global_AppendExpand with Global_Appendrillig
All callers with a variable name that is guaranteed to not contain a dollar sign have been converted to call Global_Append instead of the previous Global_AppendExpand. After that, Global_AppendExpand was unused, therefore it was effectively just renamed.
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-02-01make: clean up commentsrillig
2021-01-16make(1): fix a few inconsistencies for lint's strict bool moderillig
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-31make(1): replace pointers in controlling conditions with booleansrillig
2020-12-22make(1): fix return type of macro DEBUGrillig
This macro was supposed to return a boolean expression all the time, it just hadn't been implemented this way. This resulted in wrong output for the test sh-flags, in compilation modes -DUSE_UCHAR_BOOLEAN and -DUSE_CHAR_BOOLEAN, since in ParseCommandFlags, the expression DEBUG(LOUD) didn't fit into a boolean.
2020-12-20make(1): fix undefined behavior in meta_oodaterillig
Do not increment a null pointer. Do not assign to a variable twice in the same statement. To be fair, this may be safe because of the sequence point when the function is called, but anyway, it looks too close to undefined behavior.
2020-12-20make(1): reduce scope of cp in meta_oodaterillig
That function is way too long (550 lines) and has too creative variable names such as fname, fname1, fname2, fname3.
2020-12-20make(1): fix declared variable type in printCMDsrillig
No functional changes since StringListNode and GNodeListNode are both typedefs of a simple generic ListNode.
2020-12-20make(1): change return type of Var_Value to FStrrillig
2020-12-13make(1): replace %zu with %u in printf callsrillig
This is needed to compile bmake with GCC 2.8.1 on SunOS 5.9. To support ancient systems like this, the whole code of usr.bin/make is supposed to use only ISO C90 features, except for filemon, which is not used on these systems.
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-10make(1): split JobFlags into separate fieldsrillig
Having all these flags in a single bitmask makes it harder to see where exactly they can possibly be used since their state could also be modified using the unsuspicious job->flags = 0. Using individual names just leaves the single memset, and that is only used during initialization.
2020-12-05make(1): remove unused parameter from meta_neededrillig
2020-11-29make(1): reduce memory allocation in meta_oodaterillig