Commit Graph

16677 Commits

Author SHA1 Message Date
rillig
0e4ce27167 make(1): use FStr for memory management in Var_SetWithFlags 2020-12-20 15:31:29 +00:00
rillig
fa8bd88f04 make(1): extract SetVar from Var_SetWithFlags
SetVar contains the part that is not concerned about memory management
and expansion of the variable name.
2020-12-20 15:26:40 +00:00
rillig
eb277e70f2 make(1): fix memory leak in Var_Delete (since yesterday)
The memory leak had been introduced in var.c 1.736 from 2020-12-19
20:47:24.
2020-12-20 15:04:29 +00:00
rillig
80fba7d531 make(1): clean up memory handling in VarAssign_EvalShell 2020-12-20 14:52:16 +00:00
rillig
0b4b42e295 make(1): clean up memory handling in Parse_DoVar 2020-12-20 14:48:35 +00:00
rillig
431ba0ec4b make(1): remove constant parameter from MakeMode 2020-12-20 14:39:46 +00:00
rillig
0307413016 make(1): change return type of Var_Value to FStr 2020-12-20 14:32:13 +00:00
rillig
0462095db2 make(1): use FStr in VarNew 2020-12-20 13:50:10 +00:00
rillig
03f1822098 make(1): eliminate libName_freeIt from Arch_ParseArchive 2020-12-20 13:46:27 +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
49eb293fd6 make(1): clean up memory handling in CondParser_String 2020-12-20 13:03:48 +00:00
rillig
81b5e18281 make(1): export FStr and MFStr
These types are a replacement for the pattern "var + var_freeIt" that
enforces these two variables to be updated together.
2020-12-20 12:53:34 +00:00
rillig
37fbcac361 make(1): clean up memory handling in CondParser_String 2020-12-20 12:46:49 +00:00
rillig
8f72c319f5 make(1): document memory handling in ApplyModifiers 2020-12-20 11:38:51 +00:00
rillig
0af8f23f02 make(1): replace freeIt with FStr in EvalUndefined
Previously, the parameter out_freeIt was not guaranteed to be
initialized in every case, at least when looking only at EvalUndefined.
This contradicted the variable name.

Replace the two parameters with a single FStr to ensure that these
variables are always initialized together.
2020-12-20 10:59:21 +00:00
rillig
19824f4691 make(1): replace FStr_Assign with separate initialization functions
In GetVarnamesToUnexport, there is no need to free the local FStr since
the only place where it is assigned an allocated string is at the very
end.

Having separate functions for the two main use cases of a possibly
allocated string makes the calling code simpler.  This is a preparatory
commit for making the memory allocation in ApplyModifiers easier to
understand.
2020-12-20 00:57:29 +00:00
rillig
e0de850d21 make(1): extract string functions from ApplyModifier_To 2020-12-20 00:47:21 +00:00
rillig
ab975bef9f make(1): fix error message for .info/.warning/.error without argument
Previously, the error message was "Unknown directive", which was
obviously wrong.  The new error message is "Missing argument".
2020-12-19 22:33:11 +00:00
rillig
7772d52765 make(1): error out if .undef has not exactly 1 argument 2020-12-19 22:10:17 +00:00
rillig
715d1d3bec make(1): extract Var_DeleteVar from Var_Delete 2020-12-19 20:47:24 +00:00
rillig
f11ec78a23 make(1): add tests for undefining variables with exotic names 2020-12-19 20:35:39 +00:00
rillig
a4d0870803 make(1): extract Var_Undef from ParseDirective 2020-12-19 20:16:36 +00:00
rillig
863c2319ae make(1): rewrite tests for misspelled .elif directive
Put the simple tests at the top, demonstrating that there are already
some cases in which the misspelled directive is detected.  It's not
detected though if the surrounding conditional branch is skipped.
2020-12-19 19:49:01 +00:00
rillig
5df214d4aa make(1): extract ParseSkippedBranches from ParseReadLine 2020-12-19 17:54:29 +00:00
rillig
0cf31774e7 make(1): extract ParseForLoop from ParseReadLine 2020-12-19 17:49:11 +00:00
rillig
5ae56910c5 make(1): rename mode constants for ParseGetLine to be more expressive 2020-12-19 16:05:33 +00:00
rillig
8dfbff51e9 make(1): add test for null byte in .for loop body 2020-12-19 16:00:17 +00:00
rillig
5cd27da0e0 make(1): fix documentation of GetLineMode
ParseGetLine always returns a logical line, even for PARSE_RAW.
2020-12-19 15:29:28 +00:00
rillig
029d9ed461 make(1): improve comments for .for loops 2020-12-19 13:31:37 +00:00
rillig
ba24c12f6a make(1): reduce debugging details in Parse_SetInput
The address of readMoreArg is hardly useful when stepping through this
part of the code, therefore omit it.  Instead of mentioning the exact
function names of the data source, describe them in words, which helps
especially in the case of .for loops.
2020-12-19 13:30:00 +00:00
rillig
8b6f21ea9f make(1): rename ForIterate to ForReadMore 2020-12-19 13:20:17 +00:00
rillig
af7e852811 make(1): rename parameter line to lineno 2020-12-19 13:16:25 +00:00
rillig
4a31d445af make(1): document enum GetLineMode 2020-12-19 12:48:59 +00:00
rillig
959dba2f43 make(1): add test for backslash continuation lines in .for loops
This ensures that the line numbers for messages are the expected onces
in .for loops.

While experimenting with the backslash continuation lines, I noticed
that the reported line numbers for these are based on the number of
completely parsed physical lines, which nicely cancels out the + 1 that
has to be added for producing human-readable 1-based line numbers.  It
would be more correct to report the parse errors on the first affected
line.
2020-12-19 12:40:00 +00:00
rillig
c1c7380a9a make(1): fix line numbers in .for loops (since 2007-01-01) 2020-12-19 12:24:46 +00:00
rillig
e8319c8295 make(1): demonstrate wrong line numbers in .for loops, since 2007-01-01 2020-12-19 12:14:59 +00:00
rillig
44219d1a0a make(1): merge parameter of ParseRawLine into return value 2020-12-19 10:57:17 +00:00
rillig
89c1ddf072 make(1): clean up variable names in ParseGetLine and ParseRawLine 2020-12-19 10:49:36 +00:00
rillig
5ca350977a make(1): fix variable names in UnescapeBackslash
The previous variable names had been chosen at a time when compilers
didn't merge variables into the same registers.  Luckily, these times
are gone, and it's no longer necessary to use a variable for 2 or more
completely unrelated purposes.
2020-12-19 10:18:46 +00:00
rillig
ecc876b838 make(1): clean up ParseRawLine 2020-12-19 00:27:34 +00:00
rillig
0c5e588e71 make(1): extract ParseRawLine from ParseGetLine 2020-12-19 00:20:57 +00:00
rillig
e7a3ec57b0 make(1): clean up another local variable in ParseGetLine 2020-12-19 00:02:34 +00:00
rillig
7b504ab648 make(1): clean up UnescapeBackslash 2020-12-18 23:18:08 +00:00
rillig
419f399f4b make(1): remove unused parameter from UnescapeBackslash 2020-12-18 23:13:45 +00:00
rillig
effc4eb938 make(1): split ParseGetLine into separate functions 2020-12-18 19:02:37 +00:00
rillig
94e08101d9 make(1): separate ParseGetLine into paragraphs 2020-12-18 18:23:29 +00:00
rillig
b2ae71012b make(1): support using C99 bool for Boolean 2020-12-18 18:17:45 +00:00
rillig
6e84975ccd make(1): spell nonexistent consistently 2020-12-18 15:47:34 +00:00
rillig
d80c99b6f3 make(1): use symbolic time for 0 in Make_Recheck
This makes the test depsrc-optional independent from the current time
zone.
2020-12-18 14:46:44 +00:00
rillig
6e3f82b272 make(1): constify Targ_FmtTime 2020-12-18 14:36:46 +00:00
rillig
6357e11169 make(1): format function definitions consistently 2020-12-15 21:19:47 +00:00
rillig
a44c2b10bb make(1): indent nonints.h and util.c with tabs instead of spaces 2020-12-15 20:39:15 +00:00
rillig
b4c26ca2e4 make(1): indent make.c with tabs instead of spaces 2020-12-15 20:17:08 +00:00
rillig
cf28122d70 make(1): extract MakeChildren from MakeStartJobs 2020-12-15 19:47:02 +00:00
rillig
77e9059c21 make(1): indent job.h with tabs instead of spaces 2020-12-15 16:30:55 +00:00
rillig
6c432fc224 make(1): indent for.c using tabs instead of spaces 2020-12-15 16:24:17 +00:00
rillig
b1d7af486a make(1): clean up hash function for HashTable
Expressing a multiplication as a bit shifts and subtraction is the job
of the compiler.  For humans, a multiplication is easier to read.
2020-12-15 15:20:05 +00:00
rillig
4743be9ab6 make(1): indent hash.h and make_malloc.h with tabs instead of spaces 2020-12-15 01:23:55 +00:00
rillig
f779f26a46 make(1): document how to detect typos in .elif directives 2020-12-15 00:32:26 +00:00
rillig
623f275b16 make(1): clean up ParseReadLine
In function names, the word "get" was not used consistently to look up
or compute data, in several cases "get" was a synonym for "read", just
like in the standard C library (fgetc).

The really confusing part is that there are two functions now, called
ParseGetLine and ParseReadLine, and both were underdocumented.
2020-12-14 23:48:03 +00:00
rillig
a1af58d13b make(1): error out on .else with extraneous text 2020-12-14 22:17:11 +00:00
rillig
bb1cb5b505 make(1): error out if an '.endif' contains extraneous text 2020-12-14 21:56:17 +00:00
rillig
4d12251138 make(1): make structure of the code in Cond_EvalLine clearer 2020-12-14 21:35:21 +00:00
rillig
2f1b70eeeb make(1): add tests for parsing .if conditions 2020-12-14 21:02:25 +00:00
rillig
1eeb87db64 make(1): add more tests for parsing .endif 2020-12-14 20:57:31 +00:00
rillig
fa6ec3776b make(1): don't pretend to expand CondParser_Eval
At that point, the variable expression has already been expanded.  To
avoid the impression that the token might be relevant, pass FALSE
instead of TRUE.  No change of behavior.
2020-12-14 20:39:35 +00:00
rillig
da444aa84e make(1): add test for variable expressions after a parse error
These variable expressions don't need to be expanded, and they aren't.
2020-12-14 20:28:09 +00:00
rillig
22b3e4f8b0 make(1): add test for parsing the end of a condition 2020-12-14 20:23:49 +00:00
rillig
ed7166493f make(1): replace %zu with %u in printf calls
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-13 21:27:45 +00:00
rillig
ac4393a924 make(1): rename Vector.priv_cap to cap
There is no use case for accessing or even modifying the capacity of a
vector, therefore there is no need to hide it using the prefix "priv_".
This way, the member names are aligned between Buffer and Vector.
2020-12-13 20:57:17 +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
9ab63ee0aa make(1): constify progname 2020-12-13 20:09:02 +00:00
rillig
528c699500 make(1): fix .ERROR_TARGET in compat -k mode (since 2010-04-07) 2020-12-13 19:33:53 +00:00
rillig
95fe5be41c make(1): add tests for variable expansion in .ERROR handling 2020-12-13 19:08:20 +00:00
rillig
73287a0b22 make(1): document variable expansion in the .END node 2020-12-13 18:57:44 +00:00
christos
53f65f3d12 fix comment 2020-12-13 18:12:29 +00:00
rillig
6d3aa3c8ae make(1): demonstrate wrong error handling in compat mode 2020-12-13 17:44:31 +00:00
rillig
61121a11fe make(1): add comments for strange error handling in Compat_Run 2020-12-13 16:47:19 +00:00
rillig
a65a89393b make(1): extract InitSignals from Compat_Run 2020-12-13 16:32:57 +00:00
rillig
edc3918f88 make(1): extract MakeBeginNode from Compat_Run
The comment "execute the commands" had once been correct but not
anymore.  Since a few years, not only the commands of the .BEGIN and
.END nodes are executed, instead the nodes are made as usual, including
their dependencies.
2020-12-13 16:30:08 +00:00
rillig
67ff6c82cb make(1): extract UseShell from Compat_RunCommand 2020-12-13 16:14:40 +00:00
sjg
a39ab01a94 Prune job debug output that may appear out of order.
A race between child and parent means that we cannot
guarantee whether all child output is seen before we call
JobClosePipes, thus intervening debug output can appear
before or after the last child output.
2020-12-13 05:13:38 +00:00
rillig
2eebef5d2b make(1): remove dead code from GetVarnamesToUnexport
Now that the parsing of the directives is unified and strict, there is
no need anymore for the dispatched functions to check for unknown
directives.  These functions don't even get the information to decide
that since this decision is already done.
2020-12-13 02:15:49 +00:00
sjg
aefb247373 Avoid noise when csh does not exist 2020-12-13 02:09:55 +00:00
sjg
5f5af6046f Ensure we have a value for .MAKE.UID 2020-12-13 02:09:33 +00:00
rillig
e774dc5acc make(1): replace *line with line[0]
Since a line is not an iterator and since the expression *line typically
means "the current element", not "the first character", replacing *line
with line[0] more directly expresses the idea of accessing the first
character of a string.
2020-12-13 02:01:43 +00:00
rillig
40711a6e7b make(1): clean up comment for ParseDirective 2020-12-13 01:51:08 +00:00
rillig
b506ce346a make(1): clean up Var_Export 2020-12-13 01:41:12 +00:00
rillig
80fcd08175 make(1): replace bitset VarExportFlags with enum VarExportMode
The previous flags were not combined at all.
2020-12-13 01:33:17 +00:00
rillig
b02ee7708d make(1): adjust timestamps in unit tests
These could not be known before the previous commit.
2020-12-13 01:10:22 +00:00
rillig
f00bc469bf make(1): error out on misspelled directives
Before, make accepted misspellings like .warnings, .export-literally and
a few others, all of which are unlikely to occur in practice.  See the
test directive-misspellings.mk for further details.
2020-12-13 01:07:54 +00:00
rillig
7b010c3449 make(1): add test for misspelled directives
This test allows the other directive-* tests to focus on the purpose of
the individual directive, allowing these tests to continue after
parsing, without errors.
2020-12-13 00:46:25 +00:00
rillig
6188dab3ce make(1): reduce indentation of ParseDirective 2020-12-12 21:35:21 +00:00
rillig
ffcddf1eb1 make(1): eliminate boolean argument of Var_Export 2020-12-12 21:20:30 +00:00
rillig
63402ea177 make(1): extract ExportVarsExpand from Var_Export 2020-12-12 20:00:51 +00:00
rillig
d32acaa90f make(1): fix undefined behavior when exporting ${:U } 2020-12-12 19:39:34 +00:00
rillig
32590eee1b make(1): extract ExportVars from Var_Export 2020-12-12 19:31:17 +00:00
rillig
ab1d2fd5b0 make(1): remove redundant call to strlen in Str_Words 2020-12-12 19:13:47 +00:00
rillig
bd57be24af make(1): rename Var_ExportVars to Var_ReexportVars 2020-12-12 18:53:53 +00:00
rillig
6f740ba472 make(1): error out on misspelled .export directives 2020-12-12 18:11:42 +00:00