summaryrefslogtreecommitdiff
path: root/usr.bin/make/parse.c
AgeCommit message (Collapse)Author
2021-12-29make: merge duplicate enum constants for CondEvalResult and CondResultrillig
No binary change.
2021-12-28make: rename and constify SkipExtraTargetsrillig
No binary change.
2021-12-28make: clean up function names in parse.c, remove redundant commentsrillig
No functional change.
2021-12-28make: extract the non-parsing part from ParseDependencyTargetsrillig
No functional change.
2021-12-28make: clean up ParseDependencyrillig
No functional change.
2021-12-28make: remove redundant variable in ParseDependencyTargetsrillig
The idea of that variable was to work on constant strings as far as possible. For now it just blew up the code unnecessarily. No binary change.
2021-12-28make: remove redundant parameter from ParseDependencyTargetsrillig
No functional change.
2021-12-28make: remove redundant parameters in dependency parsing functionsrillig
Before 2020, there had been a huge function for parsing a dependency line, with lots of local variables that were reused for different purposes. When that function was split up into smaller functions, that was done mechanically, without eliminating redundant variables. No functional change.
2021-12-28make: remove redundant comments from ParseDependencyTargetsrillig
The large comment is already explained in the archive module.
2021-12-28make: reduce scope of the list of wildcard target namesrillig
The list is only used when a single target name is parsed, in case the name contains wildcards. There is no need to keep it any longer or reuse it. Clean up outdated and redundant comments. No functional change.
2021-12-28make: make ParseIsEscape simplerrillig
No functional change.
2021-12-28make: rename functions for handling dependency linesrillig
The prefix 'Parse' was ambiguous since it was both the module name and a verb. Rename those functions that don't actually parse anything. No functional change.
2021-12-28make: make debug logging for .ORDER more human-friendlyrillig
The interesting part of the .ORDER constraint is what is made before what, so reveal this information in the debug log. The debug output from the test looks a bit strange since it forces 'three' to be made before 'one', but that's because the test exercises the edge case of introducing a circular dependency.
2021-12-28make: make debug logging a bit more human-friendlyrillig
The previous log format "ParseReadLine (%d): '%s'" focused on the implementation, it was not immediately obvious to a casual reader that the number in parentheses was the line number. Additionally, having both a colon and quotes in a log message is uncommon. The quotes have been added in parse.c 1.127 from 2007-01-01. The new log format "Parsing line %d: %s" is meant to be easier readable by humans. The quotes are not needed since ParseReadLine always strips trailing whitespace, leaving no room for ambiguities. The other log messages follow common punctuation rules, which makes the beginning of the line equally unambiguous. Before var.c 1.911 from 2021-04-05, variable assignments were logged with the format "%s:%s = %s", without a space after the colon.
2021-12-28make: clean up variable names for parsing dependency linesrillig
Rename 'spec' to 'special', for consistency with the previous commits. Rename 'tOp' to 'targetAttr' since it is not an dependency operator like ':', it's an attribute like '.SILENT'. No binary change, except for the line number of the assertion in line 1618.
2021-12-28make: extract OP_NOTARGET into separate functionrillig
No binary change, except for line numbers in assertions.
2021-12-28make: remove redundant local variablerillig
The variable name 'end' suggested pointing to the end of the string, but instead it pointed to the last possible starting position of the word to be searched. Remove this possible misunderstanding. No functional change.
2021-12-27make: rename local variables to be simplerrillig
No binary change.
2021-12-27make: replace __func__ with actual stringsrillig
Make is supposed to be C90-compatible, and __func__ is from C99. No functional change.
2021-12-27make: clean up commentsrillig
2021-12-27make: remove unnecessary words from command line optionsrillig
Several years ago, the command line options were individual global variables. The global variable could therefore not be named 'silent' since that would have conflicted with local variables of the same name. After moving the global variable to the namespace 'struct CmdOpts', there is no conflict anymore. There doesn't seem to be any risk of naming collisions for the names 'touch' and 'query'. No functional change.
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: in ParseDependencyCheckSpec, move default branch to the bottomrillig
No functional change.
2021-12-14make: condense repetetive code in ParseDirectiverillig
No functional change.
2021-12-14make: remove dead code for handling traditional include directivesrillig
This code is not reached, a line containing only the word "include" is categorized as error before. No functional change.
2021-12-14make: clean up parsing of variable assignmentsrillig
Assign pairs of variables in a consistent order, as far as possible. Use string functions instead of raw byte access, to make the code more human-readable. GCC 10 optimizes the code reasonably. No functional change.
2021-12-14make: remove unreachable code for parsing the dependency operatorrillig
At the point where ParseDependencyOp is called, cp is guaranteed to point to either ':' or '!'. No functional change.
2021-12-13make: clean up loading of filesrillig
The call to Buf_DoneData was useless since ownership of the buffer data has already been passwed on to loadedfile_create and the local variable 'buf' goes out of scope after that statement. Except for cleaning up in debug mode, there is no reason to call Buf_DoneData and then discard the returned value. No functional change.
2021-12-13make: fix memory leak for filenames in .for loops (since 2013-06-18)rillig
Previously, each time a .for directive pushed its buffer on the input file stack, the current filename was duplicated. This was a waste of memory. The name of a file is typically only used while it is read in. There is one situation when the filename is needed for longer, which is when a target is defined. Since .for loops are implemented as a special form of included files, each .for loop duplicated the current filename as well. $ cat << EOF > for.mk .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .endfor .endfor .endfor .endfor .endfor .endfor .endfor all: @ps -o rsz -p ${.MAKE.PID} EOF $ make-2021.12.13.03.55.16 -r -f for.mk RSZ 10720 $ ./make -r -f for.mk RSZ 1716 The difference is 8 MB, which amounts to 1 million .for loops.
2021-12-13make: fix memory leak in IncludeFilerillig
Previously, each .include leaked a copy of the file name.
2021-12-12make: rename Parse_SetInput to Parse_PushInputrillig
The word 'set' sounded too much like it would replace the current file, but instead the file is pushed to the stack, and the previous file is continued later. No functional change.
2021-12-12make: remove unused loadedfile.pathrillig
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-12-07make: document that the input buffer is not null-terminatedrillig
2021-12-07make: inline common subexpression in ParseRawLinerillig
There is no need to load the buf_end from memory each time a character from a makefile is processed. The end of the buffer only changes when the file changes, not while reading a single line. No functional change.
2021-12-04make: merge duplicate code in ParseDirectiverillig
No functional change.
2021-12-03make: do not try to expand fixed variable namesrillig
The function SetFilenameVars is only called with fixed variable names, none of which contains a '$', so take a shortcut. No functional change.
2021-12-03make: only allocate the name of an included file if necessaryrillig
The string passed to IncludeFile is only used during that function call, it is not stored anywhere. No functional change.
2021-12-03make: clean up ParseIncluderillig
It was confusing to let the variable 'file' point to the '<' of the .include directive. In each parsing function, there should only be a single moving pointer, typically named 'p' or historically 'cp', even though the 'c' is redundant. No functional change.
2021-09-21make: reduce relocations, thereby reducing .text sizerillig
No functional change.
2021-09-21make: remove unnecessary const from parametersrillig
These were leftovers from earlier refactorings, when extracting code to separate functions. No functional change.
2021-08-14make: fix spelling of CVS and RCS in error messagerillig
2021-08-14make: rename ParseMark to be more expressiverillig
No functional change.
2021-08-14make: rename variable and function for handling parse errorsrillig
The word 'fatals' was an unnecessary abbreviation. No functional change.
2021-06-21make: document ParseDependencyOprillig
2021-06-21make: document where to find tests for the dependency linesrillig
2021-06-21make: extract ParseDependencySources from ParseDependencyrillig
No functional change.
2021-04-04make: convert VarEvalFlags back into an enum, but not a bit-setrillig
As was apparent in VarEvalFlags_ToString, a bit-set was not the best data type since most of the flags were not freely combinable. The two flags that could be combined were keepDollar and keepUndef, but even these have distinguished names in the debug log. The downside of struct bit-fields is that they need extra helper functions in C90 (see nonints.h). Exchange these for a few helper functions in var.c, to keep the code outside var.c simple. No functional change.
2021-04-04make: remove filler word 'Do' from function names for parsingrillig
No functional change, except for debug logging.
2021-04-04make: rename ambiguous functionsrillig
These two functions have counterparts that include the word 'Do' in their name, which is confusing. No functional change.