summaryrefslogtreecommitdiff
path: root/usr.bin/make/parse.c
AgeCommit message (Collapse)Author
2020-12-20make(1): return FStr from Var_Parserillig
This reduces the number of variable declarations at the call sites.
2020-12-19make(1): fix error message for .info/.warning/.error without argumentrillig
Previously, the error message was "Unknown directive", which was obviously wrong. The new error message is "Missing argument".
2020-12-19make(1): extract Var_Undef from ParseDirectiverillig
2020-12-19make(1): extract ParseSkippedBranches from ParseReadLinerillig
2020-12-19make(1): extract ParseForLoop from ParseReadLinerillig
2020-12-19make(1): rename mode constants for ParseGetLine to be more expressiverillig
2020-12-19make(1): fix documentation of GetLineModerillig
ParseGetLine always returns a logical line, even for PARSE_RAW.
2020-12-19make(1): reduce debugging details in Parse_SetInputrillig
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-19make(1): rename parameter line to linenorillig
2020-12-19make(1): document enum GetLineModerillig
2020-12-19make(1): fix line numbers in .for loops (since 2007-01-01)rillig
2020-12-19make(1): merge parameter of ParseRawLine into return valuerillig
2020-12-19make(1): clean up variable names in ParseGetLine and ParseRawLinerillig
2020-12-19make(1): fix variable names in UnescapeBackslashrillig
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-19make(1): clean up ParseRawLinerillig
2020-12-19make(1): extract ParseRawLine from ParseGetLinerillig
2020-12-19make(1): clean up another local variable in ParseGetLinerillig
2020-12-18make(1): clean up UnescapeBackslashrillig
2020-12-18make(1): remove unused parameter from UnescapeBackslashrillig
2020-12-18make(1): split ParseGetLine into separate functionsrillig
2020-12-18make(1): separate ParseGetLine into paragraphsrillig
2020-12-15make(1): document how to detect typos in .elif directivesrillig
2020-12-14make(1): clean up ParseReadLinerillig
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-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-13make(1): remove dead code from GetVarnamesToUnexportrillig
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-13make(1): replace *line with line[0]rillig
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-13make(1): clean up comment for ParseDirectiverillig
2020-12-13make(1): clean up Var_Exportrillig
2020-12-13make(1): error out on misspelled directivesrillig
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-12make(1): reduce indentation of ParseDirectiverillig
2020-12-12make(1): eliminate boolean argument of Var_Exportrillig
2020-12-06make(1): error out on null bytes in makefilesrillig
Makefiles are text files, they must not contain null bytes. The previous code in this area was rotten anyway. It assumed that buf_end could be NULL even if buf_ptr was a valid pointer, which is no longer true, probably since a few years already. Continuing parsing after a null byte does not make sense. If there's a null byte in a text file, that file is corrupted, and parsing it leads to unintended effects easily. Therefore the only sensible action is to stop parsing immediately. The check whether cf->readMore could be null was outdated as well, which previously made the fatal error impossible to reach. Because of the missing unit tests, nobody noticed this though. The "exit status 0" in opt-file.exp is worring but that's due to another bug and will be fixed in a follow-up commit.
2020-12-06make(1): rename IFile.nextbuf to readMorerillig
The previous name sounded too much like a noun, which was too confusing. See unit-tests/opt-file.mk for the history of this part of the code.
2020-12-06make(1): fix undefined behavior in ParseEOFrillig
Adding a number to a null pointer should have been caught by any Undefined Behavior Sanitizer, but apparently neither GCC nor Clang do this.
2020-12-05make(1): indent parse.c with tabs instead of spacesrillig
2020-12-05make(1): reduce indentation in ParseDependencySourceKeywordrillig
2020-12-05make(1): extract ParseDependencySourceWaitrillig
2020-12-05make(1): define constants for enum zero-valuesrillig
2020-12-05make(1): remove redundant assignmentsrillig
2020-12-04make(1): rename parse functionsrillig
The word "Do" was not necessary.
2020-11-29make(1): reduce memory allocation for dirSearchPathrillig
2020-11-29make(1): reduce memory allocations for parsing dependenciesrillig
2020-11-29make(1): reduce memory allocation for targetsrillig
This change moves the initialization and finalization of the list of targets to the same function. They had been split before.
2020-11-28make(1): reduce memory allocation for CmdOpts.createrillig
2020-11-28make(1): replace Dir_Destroy with SearchPath_Freerillig
The function Dir_Destroy is an implementation detail of the cached directories, and it should not be exported to the other modules. The search paths, on the other hand, are the high-level API that may be used by the other modules, as the concept of search paths is documented in the manual page.
2020-11-28make(1): rename some Dir functions to SearchPathrillig
These functions have the search path as their main subject.
2020-11-28make(1): reduce pointer indirection for GNode.cohortsrillig
2020-11-28make(1): reduce pointer indirection for GNode.order_pred and order_succrillig
2020-11-28make(1): reduce memory allocation for GNode.parents and GNode.childrenrillig