diff options
| author | rillig <rillig@NetBSD.org> | 2020-12-30 10:03:16 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2020-12-30 10:03:16 +0000 |
| commit | 3ba2f8a8af37a3d7e07dbe3217d8dd7fec18d3fc (patch) | |
| tree | 9d25248baefcde00a2dab9ff91f6b32f1111cfc1 /usr.bin | |
| parent | 3d19af2a101764f2f2dfbfb3972ab972e19551c2 (diff) | |
make(1): format multi-line comments
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/make/arch.c | 40 | ||||
| -rw-r--r-- | usr.bin/make/buf.c | 22 | ||||
| -rw-r--r-- | usr.bin/make/compat.c | 16 | ||||
| -rw-r--r-- | usr.bin/make/cond.c | 61 | ||||
| -rw-r--r-- | usr.bin/make/dir.c | 106 | ||||
| -rw-r--r-- | usr.bin/make/enum.c | 10 | ||||
| -rw-r--r-- | usr.bin/make/enum.h | 62 | ||||
| -rw-r--r-- | usr.bin/make/for.c | 31 | ||||
| -rw-r--r-- | usr.bin/make/hash.c | 28 | ||||
| -rw-r--r-- | usr.bin/make/job.c | 46 | ||||
| -rw-r--r-- | usr.bin/make/job.h | 8 | ||||
| -rw-r--r-- | usr.bin/make/lst.c | 46 | ||||
| -rw-r--r-- | usr.bin/make/lst.h | 14 | ||||
| -rw-r--r-- | usr.bin/make/main.c | 88 | ||||
| -rw-r--r-- | usr.bin/make/make.c | 43 | ||||
| -rw-r--r-- | usr.bin/make/make.h | 50 | ||||
| -rw-r--r-- | usr.bin/make/make_malloc.h | 8 | ||||
| -rw-r--r-- | usr.bin/make/parse.c | 91 | ||||
| -rw-r--r-- | usr.bin/make/str.c | 7 | ||||
| -rw-r--r-- | usr.bin/make/suff.c | 28 | ||||
| -rw-r--r-- | usr.bin/make/util.c | 7 | ||||
| -rw-r--r-- | usr.bin/make/var.c | 172 |
22 files changed, 643 insertions, 341 deletions
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index 34d662bb859..209589bf118 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.191 2020/12/20 13:46:27 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.192 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -68,7 +68,8 @@ * SUCH DAMAGE. */ -/* Manipulate libraries, archives and their members. +/* + * Manipulate libraries, archives and their members. * * The first time an archive is referenced, all of its members' headers are * read and cached and the archive closed again. All cached archives are kept @@ -125,7 +126,7 @@ #include "config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.191 2020/12/20 13:46:27 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.192 2020/12/30 10:03:16 rillig Exp $"); typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -387,7 +388,8 @@ Arch_ParseArchive(char **pp, GNodeList *gns, GNode *ctxt) return TRUE; } -/* Locate a member of an archive, given the path of the archive and the path +/* + * Locate a member of an archive, given the path of the archive and the path * of the desired member. * * Input: @@ -688,7 +690,8 @@ ArchiveMember_HasName(const struct ar_hdr *hdr, return FALSE; } -/* Locate a member of an archive, given the path of the archive and the path +/* + * Locate a member of an archive, given the path of the archive and the path * of the desired member. * * Input: @@ -832,7 +835,8 @@ ArchFindMember(const char *archive, const char *member, struct ar_hdr *out_arh, return NULL; } -/* Touch a member of an archive, on disk. +/* + * Touch a member of an archive, on disk. * The GNode's modification time is left as-is. * * The st_mtime of the entire archive is also changed. @@ -860,11 +864,13 @@ Arch_Touch(GNode *gn) fclose(f); /* TODO: handle errors */ } -/* Given a node which represents a library, touch the thing, making sure that +/* + * Given a node which represents a library, touch the thing, making sure that * the table of contents is also touched. * * Both the modification time of the library and of the RANLIBMAG member are - * set to 'now'. */ + * set to 'now'. + */ void Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED) { @@ -886,8 +892,10 @@ Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED) #endif } -/* Update the mtime of the GNode with the mtime from the archive member on - * disk (or in the cache). */ +/* + * Update the mtime of the GNode with the mtime from the archive member on + * disk (or in the cache). + */ void Arch_UpdateMTime(GNode *gn) { @@ -900,8 +908,10 @@ Arch_UpdateMTime(GNode *gn) gn->mtime = 0; } -/* Given a nonexistent archive member's node, update gn->mtime from its - * archived form, if it exists. */ +/* + * Given a nonexistent archive member's node, update gn->mtime from its + * archived form, if it exists. + */ void Arch_UpdateMemberMTime(GNode *gn) { @@ -939,7 +949,8 @@ Arch_UpdateMemberMTime(GNode *gn) } } -/* Search for a library along the given search path. +/* + * Search for a library along the given search path. * * The node's 'path' field is set to the found path (including the * actual file name, not -l...). If the system can handle the -L @@ -967,7 +978,8 @@ Arch_FindLib(GNode *gn, SearchPath *path) #endif } -/* Decide if a node with the OP_LIB attribute is out-of-date. Called from +/* + * Decide if a node with the OP_LIB attribute is out-of-date. Called from * GNode_IsOODate to make its life easier. * The library is cached if it hasn't been already. * diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c index 4f12a5779d4..b6a2e9192b6 100644 --- a/usr.bin/make/buf.c +++ b/usr.bin/make/buf.c @@ -1,4 +1,4 @@ -/* $NetBSD: buf.c,v 1.46 2020/12/28 15:42:53 rillig Exp $ */ +/* $NetBSD: buf.c,v 1.47 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -75,7 +75,7 @@ #include "make.h" /* "@(#)buf.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: buf.c,v 1.46 2020/12/28 15:42:53 rillig Exp $"); +MAKE_RCSID("$NetBSD: buf.c,v 1.47 2020/12/30 10:03:16 rillig Exp $"); /* Make space in the buffer for adding at least 16 more bytes. */ void @@ -135,11 +135,13 @@ Buf_AddInt(Buffer *buf, int n) Buf_AddBytes(buf, str, len); } -/* Get the data (usually a string) from the buffer. +/* + * Get the data (usually a string) from the buffer. * The returned data is valid until the next modifying operation * on the buffer. * - * Returns the data and optionally the length of the data. */ + * Returns the data and optionally the length of the data. + */ char * Buf_GetAll(Buffer *buf, size_t *out_len) { @@ -172,9 +174,11 @@ Buf_Init(Buffer *buf) Buf_InitSize(buf, 256); } -/* Reset the buffer. +/* + * Reset the buffer. * If freeData is TRUE, the data from the buffer is freed as well. - * Otherwise it is kept and returned. */ + * Otherwise it is kept and returned. + */ char * Buf_Destroy(Buffer *buf, Boolean freeData) { @@ -195,10 +199,12 @@ Buf_Destroy(Buffer *buf, Boolean freeData) # define BUF_COMPACT_LIMIT 128 /* worthwhile saving */ #endif -/* Reset the buffer and return its data. +/* + * Reset the buffer and return its data. * * If the buffer size is much greater than its content, - * a new buffer will be allocated and the old one freed. */ + * a new buffer will be allocated and the old one freed. + */ char * Buf_DestroyCompact(Buffer *buf) { diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index 6a3d21cf52a..893a64f0747 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.217 2020/12/27 05:16:26 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.218 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -96,7 +96,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.217 2020/12/27 05:16:26 rillig Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.218 2020/12/30 10:03:16 rillig Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -118,7 +118,8 @@ CompatDeleteTarget(GNode *gn) } } -/* Interrupt the creation of the current target and remove it if it ain't +/* + * Interrupt the creation of the current target and remove it if it ain't * precious. Then exit. * * If .INTERRUPT exists, its commands are run first WITH INTERRUPTS IGNORED. @@ -206,7 +207,8 @@ UseShell(const char *cmd MAKE_ATTR_UNUSED) #endif } -/* Execute the next command for a target. If the command returns an error, +/* + * Execute the next command for a target. If the command returns an error, * the node's made field is set to ERROR and creation stops. * * Input: @@ -624,7 +626,8 @@ MakeOther(GNode *gn, GNode *pgn) } } -/* Make a target. +/* + * Make a target. * * If an error is detected and not being ignored, the process exits. * @@ -693,7 +696,8 @@ InitSignals(void) bmake_signal(SIGQUIT, CompatInterrupt); } -/* Initialize this module and start making. +/* + * Initialize this module and start making. * * Input: * targs The target nodes to re-create diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index 701179832ca..2f28852c284 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.232 2020/12/27 10:53:23 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.233 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -69,7 +69,8 @@ * SUCH DAMAGE. */ -/* Handling of conditionals in a makefile. +/* + * Handling of conditionals in a makefile. * * Interface: * Cond_EvalLine Evaluate the conditional directive, such as @@ -94,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.232 2020/12/27 10:53:23 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.233 2020/12/30 10:03:16 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -198,7 +199,8 @@ CondParser_SkipWhitespace(CondParser *par) cpp_skip_whitespace(&par->p); } -/* Parse the argument of a built-in function. +/* + * Parse the argument of a built-in function. * * Arguments: * *pp initially points at the '(', @@ -209,7 +211,8 @@ CondParser_SkipWhitespace(CondParser *par) * func says whether the argument belongs to an actual function, or * whether the parsed argument is passed to the default function. * - * Return the length of the argument, or 0 on error. */ + * Return the length of the argument, or 0 on error. + */ static size_t ParseFuncArg(const char **pp, Boolean doEval, const char *func, char **out_arg) @@ -327,8 +330,10 @@ FuncTarget(size_t argLen MAKE_ATTR_UNUSED, const char *arg) return gn != NULL && GNode_IsTarget(gn); } -/* See if the given node exists and is an actual target with commands - * associated with it. */ +/* + * See if the given node exists and is an actual target with commands + * associated with it. + */ static Boolean FuncCommands(size_t argLen MAKE_ATTR_UNUSED, const char *arg) { @@ -532,8 +537,10 @@ If_Eval(const struct If *if_info, const char *arg, size_t arglen) return if_info->doNot ? !res : res; } -/* Evaluate a "comparison without operator", such as in ".if ${VAR}" or - * ".if 0". */ +/* + * Evaluate a "comparison without operator", such as in ".if ${VAR}" or + * ".if 0". + */ static Boolean EvalNotEmpty(CondParser *par, const char *value, Boolean quoted) { @@ -616,7 +623,8 @@ EvalCompare(const char *lhs, Boolean lhsQuoted, const char *op, return EvalCompareStr(lhs, op, rhs); } -/* Parse a comparison condition such as: +/* + * Parse a comparison condition such as: * * 0 * ${VAR:Mpattern} @@ -685,8 +693,10 @@ done_lhs: return t; } -/* The argument to empty() is a variable name, optionally followed by - * variable modifiers. */ +/* + * The argument to empty() is a variable name, optionally followed by + * variable modifiers. + */ static size_t ParseEmptyArg(const char **pp, Boolean doEval, const char *func MAKE_ATTR_UNUSED, char **out_arg) @@ -779,8 +789,10 @@ CondParser_Func(CondParser *par, Boolean doEval, Token *out_token) return FALSE; } -/* Parse a function call, a number, a variable expression or a string - * literal. */ +/* + * Parse a function call, a number, a variable expression or a string + * literal. + */ static Token CondParser_LeafToken(CondParser *par, Boolean doEval) { @@ -889,7 +901,8 @@ CondParser_Token(CondParser *par, Boolean doEval) } } -/* Parse a single term in the expression. This consists of a terminal symbol +/* + * Parse a single term in the expression. This consists of a terminal symbol * or TOK_NOT and a term (not including the binary operators): * * T -> defined(variable) | make(target) | exists(file) | symbol @@ -932,7 +945,8 @@ CondParser_Term(CondParser *par, Boolean doEval) return t; } -/* Parse a conjunctive factor (nice name, wot?) +/* + * Parse a conjunctive factor (nice name, wot?) * * F -> T && F | T * @@ -972,7 +986,8 @@ CondParser_Factor(CondParser *par, Boolean doEval) return l; } -/* Main expression production. +/* + * Main expression production. * * E -> F || E | F * @@ -1032,7 +1047,8 @@ CondParser_Eval(CondParser *par, Boolean *value) return COND_PARSE; } -/* Evaluate the condition, including any side effects from the variable +/* + * Evaluate the condition, including any side effects from the variable * expressions in the condition. The condition consists of &&, ||, !, * function(arg), comparisons and parenthetical groupings thereof. * @@ -1066,8 +1082,10 @@ CondEvalExpression(const struct If *info, const char *cond, Boolean *value, return rval; } -/* Evaluate a condition in a :? modifier, such as - * ${"${VAR}" == value:?yes:no}. */ +/* + * Evaluate a condition in a :? modifier, such as + * ${"${VAR}" == value:?yes:no}. + */ CondEvalResult Cond_EvalCondition(const char *cond, Boolean *out_value) { @@ -1081,7 +1099,8 @@ IsEndif(const char *p) p[3] == 'i' && p[4] == 'f' && !ch_isalpha(p[5]); } -/* Evaluate the conditional directive in the line, which is one of: +/* + * Evaluate the conditional directive in the line, which is one of: * * .if <cond> * .ifmake <cond> diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index 596477ac4e5..2636d625322 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.253 2020/12/27 11:47:04 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.254 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -69,7 +69,8 @@ * SUCH DAMAGE. */ -/* Directory searching using wildcards and/or normal names. +/* + * Directory searching using wildcards and/or normal names. * Used both for source wildcarding in the makefile and for finding * implicit sources. * @@ -136,9 +137,10 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.253 2020/12/27 11:47:04 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.254 2020/12/30 10:03:16 rillig Exp $"); -/* A search path is a list of CachedDir structures. A CachedDir has in it the +/* + * A search path is a list of CachedDir structures. A CachedDir has in it the * name of the directory and the names of all the files in the directory. * This is used to cut down on the number of system calls necessary to find * implicit dependents and their like. Since these searches are made before @@ -270,13 +272,15 @@ static CachedDir *cur = NULL; /* A fake path entry indicating we need to look for '.' last. */ static CachedDir *dotLast = NULL; -/* Results of doing a last-resort stat in Dir_FindFile -- if we have to go to +/* + * Results of doing a last-resort stat in Dir_FindFile -- if we have to go to * the system to find the file, we might as well have its mtime on record. * * XXX: If this is done way early, there's a chance other rules will have * already updated the file, in which case we'll update it again. Generally, * there won't be two rules to update a single file, so this should be ok, - * but... */ + * but... + */ static HashTable mtimes; static HashTable lmtimes; /* same as mtimes but for lstat */ @@ -408,8 +412,10 @@ OpenDirs_Remove(OpenDirs *odirs, const char *name) Lst_Remove(&odirs->list, ln); } -/* Returns 0 and the result of stat(2) or lstat(2) in *out_cst, - * or -1 on error. */ +/* + * Returns 0 and the result of stat(2) or lstat(2) in *out_cst, + * or -1 on error. + */ static int cached_stats(const char *pathname, struct cached_stat *out_cst, CachedStatsFlags flags) @@ -496,8 +502,10 @@ Dir_InitCur(const char *cdname) CachedDir_Assign(&cur, dir); } -/* (Re)initialize "dot" (current/object directory) path hash. - * Some directories may be cached. */ +/* + * (Re)initialize "dot" (current/object directory) path hash. + * Some directories may be cached. + */ void Dir_InitDot(void) { @@ -574,7 +582,8 @@ Dir_SetPATH(void) } } -/* See if the given name has any wildcard characters in it and all braces and +/* + * See if the given name has any wildcard characters in it and all braces and * brackets are properly balanced. * * XXX: This code is not 100% correct ([^]] fails etc.). I really don't think @@ -617,7 +626,8 @@ Dir_HasWildcards(const char *name) return wild && brackets == 0 && braces == 0; } -/* See if any files match the pattern and add their names to the 'expansions' +/* + * See if any files match the pattern and add their names to the 'expansions' * list if they do. * * This is incomplete -- wildcards are only expanded in the final path @@ -671,8 +681,10 @@ DirMatchFiles(const char *pattern, CachedDir *dir, StringList *expansions) } } -/* Find the next closing brace in the string, taking nested braces into - * account. */ +/* + * Find the next closing brace in the string, taking nested braces into + * account. + */ static const char * closing_brace(const char *p) { @@ -689,8 +701,10 @@ closing_brace(const char *p) return p; } -/* Find the next closing brace or comma in the string, taking nested braces - * into account. */ +/* + * Find the next closing brace or comma in the string, taking nested braces + * into account. + */ static const char * separator_comma(const char *p) { @@ -735,7 +749,8 @@ concat3(const char *a, size_t a_len, const char *b, size_t b_len, return s; } -/* Expand curly braces like the C shell. Brace expansion by itself is purely +/* + * Expand curly braces like the C shell. Brace expansion by itself is purely * textual, the expansions are not looked up in the file system. But if an * expanded word contains wildcard characters, it is expanded further, * matching only the actually existing files. @@ -818,7 +833,8 @@ PrintExpansions(StringList *expansions) debug_printf("\n"); } -/* Expand the given word into a list of words by globbing it, looking in the +/* + * Expand the given word into a list of words by globbing it, looking in the * directories on the given search path. * * Input: @@ -931,8 +947,10 @@ done: PrintExpansions(expansions); } -/* Find if the file with the given name exists in the given path. - * Return the freshly allocated path to the file, or NULL. */ +/* + * Find if the file with the given name exists in the given path. + * Return the freshly allocated path to the file, or NULL. + */ static char * DirLookup(CachedDir *dir, const char *base) { @@ -951,8 +969,10 @@ DirLookup(CachedDir *dir, const char *base) } -/* Find if the file with the given name exists in the given directory. - * Return the freshly allocated path to the file, or NULL. */ +/* + * Find if the file with the given name exists in the given directory. + * Return the freshly allocated path to the file, or NULL. + */ static char * DirLookupSubdir(CachedDir *dir, const char *name) { @@ -970,7 +990,8 @@ DirLookupSubdir(CachedDir *dir, const char *name) return NULL; } -/* Find if the file with the given name exists in the given path. +/* + * Find if the file with the given name exists in the given path. * Return the freshly allocated path to the file, the empty string, or NULL. * Returning the empty string means that the search should be terminated. */ @@ -1005,8 +1026,10 @@ DirLookupAbs(CachedDir *dir, const char *name, const char *cp) return bmake_strdup(name); } -/* Find the file given on "." or curdir. - * Return the freshly allocated path to the file, or NULL. */ +/* + * Find the file given on "." or curdir. + * Return the freshly allocated path to the file, or NULL. + */ static char * DirFindDot(const char *name, const char *base) { @@ -1028,7 +1051,8 @@ DirFindDot(const char *name, const char *base) return NULL; } -/* Find the file with the given name along the given search path. +/* + * Find the file with the given name along the given search path. * * If the file is found in a directory that is not on the path * already (either 'name' is absolute or it is a relative path @@ -1281,7 +1305,8 @@ Dir_FindFile(const char *name, SearchPath *path) } -/* Search for a path starting at a given directory and then working our way +/* + * Search for a path starting at a given directory and then working our way * up towards the root. * * Input: @@ -1404,10 +1429,12 @@ ResolveFullName(GNode *gn) return fullName; } -/* Search gn along dirSearchPath and store its modification time in gn->mtime. +/* + * Search gn along dirSearchPath and store its modification time in gn->mtime. * If no file is found, store 0 instead. * - * The found file is stored in gn->path, unless the node already had a path. */ + * The found file is stored in gn->path, unless the node already had a path. + */ void Dir_UpdateMTime(GNode *gn, Boolean recheck) { @@ -1488,7 +1515,8 @@ CacheNewDir(const char *name, SearchPath *path) return dir; } -/* Read the list of filenames in the directory and store the result +/* + * Read the list of filenames in the directory and store the result * in openDirs. * * If a path is given, append the directory to that path. @@ -1535,8 +1563,10 @@ Dir_AddDir(SearchPath *path, const char *name) return CacheNewDir(name, path); } -/* Return a copy of dirSearchPath, incrementing the reference counts for - * the contained directories. */ +/* + * Return a copy of dirSearchPath, incrementing the reference counts for + * the contained directories. + */ SearchPath * Dir_CopyDirSearchPath(void) { @@ -1596,8 +1626,10 @@ SearchPath_Free(SearchPath *path) Lst_Free(path); } -/* Clear out all elements from the given search path. - * The path is set to the empty list but is not destroyed. */ +/* + * Clear out all elements from the given search path. + * The path is set to the empty list but is not destroyed. + */ void SearchPath_Clear(SearchPath *path) { @@ -1608,8 +1640,10 @@ SearchPath_Clear(SearchPath *path) } -/* Concatenate two paths, adding the second to the end of the first, - * skipping duplicates. */ +/* + * Concatenate two paths, adding the second to the end of the first, + * skipping duplicates. + */ void SearchPath_AddAll(SearchPath *dst, SearchPath *src) { diff --git a/usr.bin/make/enum.c b/usr.bin/make/enum.c index cce98690541..9ce6af26dc3 100644 --- a/usr.bin/make/enum.c +++ b/usr.bin/make/enum.c @@ -1,4 +1,4 @@ -/* $NetBSD: enum.c,v 1.12 2020/10/05 19:27:47 rillig Exp $ */ +/* $NetBSD: enum.c,v 1.13 2020/12/30 10:03:16 rillig Exp $ */ /* Copyright (c) 2020 Roland Illig <rillig@NetBSD.org> @@ -29,13 +29,15 @@ #include "make.h" -MAKE_RCSID("$NetBSD: enum.c,v 1.12 2020/10/05 19:27:47 rillig Exp $"); +MAKE_RCSID("$NetBSD: enum.c,v 1.13 2020/12/30 10:03:16 rillig Exp $"); -/* Convert a bitset into a string representation, showing the names of the +/* + * Convert a bitset into a string representation, showing the names of the * individual bits. * * Optionally, shortcuts for groups of bits can be added. To have an effect, - * they need to be listed before their individual bits. */ + * they need to be listed before their individual bits. + */ const char * Enum_FlagsToString(char *buf, size_t buf_size, int value, const EnumToStringSpec *spec) diff --git a/usr.bin/make/enum.h b/usr.bin/make/enum.h index baff91a26ec..6707214e8b0 100644 --- a/usr.bin/make/enum.h +++ b/usr.bin/make/enum.h @@ -1,4 +1,4 @@ -/* $NetBSD: enum.h,v 1.13 2020/12/28 00:46:24 rillig Exp $ */ +/* $NetBSD: enum.h,v 1.14 2020/12/30 10:03:16 rillig Exp $ */ /* Copyright (c) 2020 Roland Illig <rillig@NetBSD.org> @@ -45,8 +45,10 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *); /* For Enum_FlagsToString, the separator between flags. */ #define ENUM__SEP "|" -/* Generate the string that joins all possible flags, to see how large the - * buffer must be. */ +/* + * Generate the string that joins all possible flags, to see how large the + * buffer must be. + */ #define ENUM__JOIN_STR_1(v1) \ #v1 #define ENUM__JOIN_STR_2(v1, v2) \ @@ -107,8 +109,10 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *); static const EnumToStringSpec typnam ## _ ## ToStringSpecs[] = specs; \ enum { typnam ## _ ## ToStringSize = sizeof joined } -/* Declare the necessary data structures for calling Enum_FlagsToString - * for an enum with 2 flags. */ +/* + * Declare the necessary data structures for calling Enum_FlagsToString + * for an enum with 2 flags. + */ #define ENUM_FLAGS_RTTI_2(typnam, v1, v2) \ ENUM__FLAGS_RTTI(typnam, \ ENUM__SPECS_2( \ @@ -118,8 +122,10 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *); ENUM__JOIN_STR_1(v1), \ ENUM__JOIN_STR_1(v2))) -/* Declare the necessary data structures for calling Enum_FlagsToString - * for an enum with 3 flags. */ +/* + * Declare the necessary data structures for calling Enum_FlagsToString + * for an enum with 3 flags. + */ #define ENUM_FLAGS_RTTI_3(typnam, v1, v2, v3) \ ENUM__FLAGS_RTTI(typnam, \ ENUM__SPECS_2( \ @@ -129,8 +135,10 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *); ENUM__JOIN_STR_2(v1, v2), \ ENUM__JOIN_STR_1(v3))) -/* Declare the necessary data structures for calling Enum_FlagsToString - * for an enum with 4 flags. */ +/* + * Declare the necessary data structures for calling Enum_FlagsToString + * for an enum with 4 flags. + */ #define ENUM_FLAGS_RTTI_4(typnam, v1, v2, v3, v4) \ ENUM__FLAGS_RTTI(typnam, \ ENUM__SPECS_2( \ @@ -140,8 +148,10 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *); ENUM__JOIN_STR_2(v1, v2), \ ENUM__JOIN_STR_2(v3, v4))) -/* Declare the necessary data structures for calling Enum_FlagsToString - * for an enum with 6 flags. */ +/* + * Declare the necessary data structures for calling Enum_FlagsToString + * for an enum with 6 flags. + */ #define ENUM_FLAGS_RTTI_6(typnam, v1, v2, v3, v4, v5, v6) \ ENUM__FLAGS_RTTI(typnam, \ ENUM__SPECS_2( \ @@ -151,8 +161,10 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *); ENUM__JOIN_STR_4(v1, v2, v3, v4), \ ENUM__JOIN_STR_2(v5, v6))) -/* Declare the necessary data structures for calling Enum_FlagsToString - * for an enum with 8 flags. */ +/* + * Declare the necessary data structures for calling Enum_FlagsToString + * for an enum with 8 flags. + */ #define ENUM_FLAGS_RTTI_8(typnam, v1, v2, v3, v4, v5, v6, v7, v8) \ ENUM__FLAGS_RTTI(typnam, \ ENUM__SPECS_2( \ @@ -162,16 +174,20 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *); ENUM__JOIN_STR_4(v1, v2, v3, v4), \ ENUM__JOIN_STR_4(v5, v6, v7, v8))) -/* Declare the necessary data structures for calling Enum_ValueToString - * for an enum with 8 constants. */ +/* + * Declare the necessary data structures for calling Enum_ValueToString + * for an enum with 8 constants. + */ #define ENUM_VALUE_RTTI_8(typnam, v1, v2, v3, v4, v5, v6, v7, v8) \ ENUM__VALUE_RTTI(typnam, \ ENUM__SPECS_2( \ ENUM__SPEC_4(v1, v2, v3, v4), \ ENUM__SPEC_4(v5, v6, v7, v8))) -/* Declare the necessary data structures for calling Enum_FlagsToString - * for an enum with 10 flags. */ +/* + * Declare the necessary data structures for calling Enum_FlagsToString + * for an enum with 10 flags. + */ #define ENUM_FLAGS_RTTI_10(typnam, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) \ ENUM__FLAGS_RTTI(typnam, \ ENUM__SPECS_2( \ @@ -181,8 +197,10 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *); ENUM__JOIN_STR_8(v1, v2, v3, v4, v5, v6, v7, v8), \ ENUM__JOIN_STR_2(v9, v10))) -/* Declare the necessary data structures for calling Enum_FlagsToString - * for an enum with 31 flags. */ +/* + * Declare the necessary data structures for calling Enum_FlagsToString + * for an enum with 31 flags. + */ #define ENUM_FLAGS_RTTI_31(typnam, \ v01, v02, v03, v04, v05, v06, v07, v08, \ v09, v10, v11, v12, v13, v14, v15, v16, \ @@ -204,8 +222,10 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *); ENUM__JOIN_STR_2(v29, v30), \ ENUM__JOIN_STR_1(v31))) -/* Declare the necessary data structures for calling Enum_FlagsToString - * for an enum with 32 flags. */ +/* + * Declare the necessary data structures for calling Enum_FlagsToString + * for an enum with 32 flags. + */ #define ENUM_FLAGS_RTTI_32(typnam, \ v01, v02, v03, v04, v05, v06, v07, v08, \ v09, v10, v11, v12, v13, v14, v15, v16, \ diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index 78d9d54c39d..b4f5c4740df 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.121 2020/12/27 10:04:32 rillig Exp $ */ +/* $NetBSD: for.c,v 1.122 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include "make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.121 2020/12/27 10:04:32 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.122 2020/12/30 10:03:16 rillig Exp $"); static int forLevel = 0; /* Nesting level */ @@ -125,7 +125,8 @@ IsEndfor(const char *p) (p[6] == '\0' || ch_isspace(p[6])); } -/* Evaluate the for loop in the passed line. The line looks like this: +/* + * Evaluate the for loop in the passed line. The line looks like this: * .for <varname...> in <value...> * * Input: @@ -303,8 +304,10 @@ for_var_len(const char *var) return 0; } -/* The .for loop substitutes the items as ${:U<value>...}, which means - * that characters that break this syntax must be backslash-escaped. */ +/* + * The .for loop substitutes the items as ${:U<value>...}, which means + * that characters that break this syntax must be backslash-escaped. + */ static Boolean NeedsEscapes(const char *word, char endc) { @@ -317,10 +320,12 @@ NeedsEscapes(const char *word, char endc) return FALSE; } -/* While expanding the body of a .for loop, write the item in the ${:U...} +/* + * While expanding the body of a .for loop, write the item in the ${:U...} * expression, escaping characters as needed. * - * The result is later unescaped by ApplyModifier_Defined. */ + * The result is later unescaped by ApplyModifier_Defined. + */ static void Buf_AddEscaped(Buffer *cmds, const char *item, char ech) { @@ -348,8 +353,10 @@ Buf_AddEscaped(Buffer *cmds, const char *item, char ech) } } -/* While expanding the body of a .for loop, replace expressions like - * ${i}, ${i:...}, $(i) or $(i:...) with their ${:U...} expansion. */ +/* + * While expanding the body of a .for loop, replace expressions like + * ${i}, ${i:...}, $(i) or $(i:...) with their ${:U...} expansion. + */ static void SubstVarLong(For *f, const char **pp, const char **inout_mark, char ech) { @@ -382,8 +389,10 @@ SubstVarLong(For *f, const char **pp, const char **inout_mark, char ech) *pp = p; } -/* While expanding the body of a .for loop, replace single-character - * variable expressions like $i with their ${:U...} expansion. */ +/* + * While expanding the body of a .for loop, replace single-character + * variable expressions like $i with their ${:U...} expansion. + */ static void SubstVarShort(For *f, char ch, const char **pp, const char **inout_mark) { diff --git a/usr.bin/make/hash.c b/usr.bin/make/hash.c index 65a0b16be16..82735f59c6f 100644 --- a/usr.bin/make/hash.c +++ b/usr.bin/make/hash.c @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.59 2020/12/15 15:20:05 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.60 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -74,7 +74,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.59 2020/12/15 15:20:05 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.60 2020/12/30 10:03:16 rillig Exp $"); /* * The ratio of # entries to # buckets at which we rebuild the table to @@ -180,8 +180,10 @@ HashTable_FindValue(HashTable *t, const char *key) return he != NULL ? he->value : NULL; } -/* Find the value corresponding to the key and the precomputed hash, - * or return NULL. */ +/* + * Find the value corresponding to the key and the precomputed hash, + * or return NULL. + */ void * HashTable_FindValueHash(HashTable *t, const char *key, unsigned int h) { @@ -189,8 +191,10 @@ HashTable_FindValueHash(HashTable *t, const char *key, unsigned int h) return he != NULL ? he->value : NULL; } -/* Make the hash table larger. Any bucket numbers from the old table become - * invalid; the hash codes stay valid though. */ +/* + * Make the hash table larger. Any bucket numbers from the old table become + * invalid; the hash codes stay valid though. + */ static void HashTable_Enlarge(HashTable *t) { @@ -224,8 +228,10 @@ HashTable_Enlarge(HashTable *t) t->maxchain = 0; } -/* Find or create an entry corresponding to the key. - * Return in out_isNew whether a new entry has been created. */ +/* + * Find or create an entry corresponding to the key. + * Return in out_isNew whether a new entry has been created. + */ HashEntry * HashTable_CreateEntry(HashTable *t, const char *key, Boolean *out_isNew) { @@ -291,8 +297,10 @@ HashIter_Init(HashIter *hi, HashTable *t) hi->entry = NULL; } -/* Return the next entry in the hash table, or NULL if the end of the table - * is reached. */ +/* + * Return the next entry in the hash table, or NULL if the end of the table + * is reached. + */ HashEntry * HashIter_Next(HashIter *hi) { diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index dcc08875029..72117fc498d 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.390 2020/12/27 05:16:26 rillig Exp $ */ +/* $NetBSD: job.c,v 1.391 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.390 2020/12/27 05:16:26 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.391 2020/12/30 10:03:16 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -399,8 +399,10 @@ static Shell shells[] = { } }; -/* This is the shell to which we pass all commands in the Makefile. - * It is set by the Job_ParseShell function. */ +/* + * This is the shell to which we pass all commands in the Makefile. + * It is set by the Job_ParseShell function. + */ static Shell *shell = &shells[DEFSHELL_INDEX]; const char *shellPath = NULL; /* full pathname of executable image */ const char *shellName = NULL; /* last component of shellPath */ @@ -1231,10 +1233,12 @@ TouchRegular(GNode *gn) (void)close(fd); /* XXX: What about propagating the error? */ } -/* Touch the given target. Called by JobStart when the -t flag was given. +/* + * Touch the given target. Called by JobStart when the -t flag was given. * * The modification date of the file is changed. - * If the file did not exist, it is created. */ + * If the file did not exist, it is created. + */ void Job_Touch(GNode *gn, Boolean echo) { @@ -1264,7 +1268,8 @@ Job_Touch(GNode *gn, Boolean echo) TouchRegular(gn); } -/* Make sure the given node has all the commands it needs. +/* + * Make sure the given node has all the commands it needs. * * The node will have commands from the .DEFAULT rule added to it if it * needs them. @@ -1345,9 +1350,11 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...)) return FALSE; } -/* Execute the shell for the given job. +/* + * Execute the shell for the given job. * - * See Job_CatchOutput for handling the output of the shell. */ + * See Job_CatchOutput for handling the output of the shell. + */ static void JobExec(Job *job, char **argv) { @@ -1948,7 +1955,8 @@ JobRun(GNode *targ) #endif } -/* Handle the exit of a child. Called from Make_Make. +/* + * Handle the exit of a child. Called from Make_Make. * * The job descriptor is removed from the list of children. * @@ -2025,10 +2033,12 @@ JobReapChild(pid_t pid, int status, Boolean isJobs) JobFinish(job, status); } -/* Catch the output from our children, if we're using pipes do so. Otherwise +/* + * Catch the output from our children, if we're using pipes do so. Otherwise * just block time until we get a signal(most likely a SIGCHLD) since there's * no point in just spinning when there's nothing to do and the reaping of a - * child can wait for a while. */ + * child can wait for a while. + */ void Job_CatchOutput(void) { @@ -2097,8 +2107,10 @@ Job_CatchOutput(void) } } -/* Start the creation of a target. Basically a front-end for JobStart used by - * the Make module. */ +/* + * Start the creation of a target. Basically a front-end for JobStart used by + * the Make module. + */ void Job_Make(GNode *gn) { @@ -2741,8 +2753,10 @@ readyfd(Job *job) return (job->inPollfd->revents & POLLIN) != 0; } -/* Put a token (back) into the job pipe. - * This allows a make process to start a build job. */ +/* + * Put a token (back) into the job pipe. + * This allows a make process to start a build job. + */ static void JobTokenAdd(void) { diff --git a/usr.bin/make/job.h b/usr.bin/make/job.h index 77e9d25f214..9bb5f149766 100644 --- a/usr.bin/make/job.h +++ b/usr.bin/make/job.h @@ -1,4 +1,4 @@ -/* $NetBSD: job.h,v 1.70 2020/12/15 16:30:55 rillig Exp $ */ +/* $NetBSD: job.h,v 1.71 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -125,7 +125,8 @@ typedef enum JobStatus { JOB_ST_FINISHED = 4 /* Job is done (ie after SIGCHILD) */ } JobStatus; -/* A Job manages the shell commands that are run to create a single target. +/* + * A Job manages the shell commands that are run to create a single target. * Each job is run in a separate subprocess by a shell. Several jobs can run * in parallel. * @@ -135,7 +136,8 @@ typedef enum JobStatus { * * When a job is finished, Make_Update updates all parents of the node * that was just remade, marking them as ready to be made next if all - * other dependencies are finished as well. */ + * other dependencies are finished as well. + */ typedef struct Job { /* The process ID of the shell running the commands */ int pid; diff --git a/usr.bin/make/lst.c b/usr.bin/make/lst.c index 53315876b09..8d660b37ff5 100644 --- a/usr.bin/make/lst.c +++ b/usr.bin/make/lst.c @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.101 2020/12/13 20:57:17 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.102 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -34,7 +34,7 @@ #include "make.h" -MAKE_RCSID("$NetBSD: lst.c,v 1.101 2020/12/13 20:57:17 rillig Exp $"); +MAKE_RCSID("$NetBSD: lst.c,v 1.102 2020/12/30 10:03:16 rillig Exp $"); static ListNode * LstNodeNew(ListNode *prev, ListNode *next, void *datum) @@ -89,8 +89,10 @@ Lst_Free(List *list) free(list); } -/* Destroy a list and free all its resources. The freeProc is called with the - * datum from each node in turn before the node is freed. */ +/* + * Destroy a list and free all its resources. The freeProc is called with the + * datum from each node in turn before the node is freed. + */ void Lst_Destroy(List *list, LstFreeProc freeProc) { @@ -154,8 +156,10 @@ Lst_Append(List *list, void *datum) } } -/* Remove the given node from the given list. - * The datum stored in the node must be freed by the caller, if necessary. */ +/* + * Remove the given node from the given list. + * The datum stored in the node must be freed by the caller, if necessary. + */ void Lst_Remove(List *list, ListNode *ln) { @@ -181,17 +185,21 @@ LstNode_Set(ListNode *ln, void *datum) ln->datum = datum; } -/* Replace the datum in the given node with NULL. - * Having NULL values in a list is unusual though. */ +/* + * Replace the datum in the given node with NULL. + * Having NULL values in a list is unusual though. + */ void LstNode_SetNull(ListNode *ln) { ln->datum = NULL; } -/* Return the first node that contains the given datum, or NULL. +/* + * Return the first node that contains the given datum, or NULL. * - * Time complexity: O(length(list)) */ + * Time complexity: O(length(list)) + */ ListNode * Lst_FindDatum(List *list, const void *datum) { @@ -206,8 +214,10 @@ Lst_FindDatum(List *list, const void *datum) return NULL; } -/* Move all nodes from src to the end of dst. - * The source list becomes empty but is not freed. */ +/* + * Move all nodes from src to the end of dst. + * The source list becomes empty but is not freed. + */ void Lst_MoveAll(List *dst, List *src) { @@ -261,8 +271,10 @@ Vector_Init(Vector *v, size_t itemSize) v->items = bmake_malloc(v->cap * v->itemSize); } -/* Add space for a new item to the vector and return a pointer to that space. - * The returned data is valid until the next modifying operation. */ +/* + * Add space for a new item to the vector and return a pointer to that space. + * The returned data is valid until the next modifying operation. + */ void * Vector_Push(Vector *v) { @@ -274,8 +286,10 @@ Vector_Push(Vector *v) return Vector_Get(v, v->len - 1); } -/* Return the pointer to the last item in the vector. - * The returned data is valid until the next modifying operation. */ +/* + * Return the pointer to the last item in the vector. + * The returned data is valid until the next modifying operation. + */ void * Vector_Pop(Vector *v) { diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h index 48a346a5332..4e87b273378 100644 --- a/usr.bin/make/lst.h +++ b/usr.bin/make/lst.h @@ -1,4 +1,4 @@ -/* $NetBSD: lst.h,v 1.93 2020/12/13 20:57:17 rillig Exp $ */ +/* $NetBSD: lst.h,v 1.94 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -169,8 +169,10 @@ Lst_Enqueue(List *list, void *datum) { /* Remove the head node of the queue and return its datum. */ void *Lst_Dequeue(List *); -/* A vector is an ordered collection of items, allowing for fast indexed - * access. */ +/* + * A vector is an ordered collection of items, allowing for fast indexed + * access. + */ typedef struct Vector { void *items; /* memory holding the items */ size_t itemSize; /* size of a single item */ @@ -180,8 +182,10 @@ typedef struct Vector { void Vector_Init(Vector *, size_t); -/* Return the pointer to the given item in the vector. - * The returned data is valid until the next modifying operation. */ +/* + * Return the pointer to the given item in the vector. + * The returned data is valid until the next modifying operation. + */ MAKE_INLINE void * Vector_Get(Vector *v, size_t i) { diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 1e2a00493d3..54d3629de17 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.506 2020/12/28 00:46:24 rillig Exp $ */ +/* $NetBSD: main.c,v 1.507 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -68,7 +68,8 @@ * SUCH DAMAGE. */ -/* The main file for this entire program. Exit routines etc. reside here. +/* + * The main file for this entire program. Exit routines etc. reside here. * * Utility functions defined in this file: * @@ -109,7 +110,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.506 2020/12/28 00:46:24 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.507 2020/12/30 10:03:16 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -572,13 +573,15 @@ MainParseArg(char c, const char *argvalue) return TRUE; } -/* Parse the given arguments. Called from main() and from +/* + * Parse the given arguments. Called from main() and from * Main_ParseArgLine() when the .MAKEFLAGS target is used. * * The arguments must be treated as read-only and will be freed after the * call. * - * XXX: Deal with command line overriding .MAKEFLAGS in makefile */ + * XXX: Deal with command line overriding .MAKEFLAGS in makefile + */ static void MainParseArgs(int argc, char **argv) { @@ -670,10 +673,12 @@ noarg: usage(); } -/* Break a line of arguments into words and parse them. +/* + * Break a line of arguments into words and parse them. * * Used when a .MFLAGS or .MAKEFLAGS target is encountered during parsing and - * by main() when reading the MAKEFLAGS environment variable. */ + * by main() when reading the MAKEFLAGS environment variable. + */ void Main_ParseArgLine(const char *line) { @@ -773,8 +778,10 @@ SetVarObjdir(Boolean writable, const char *var, const char *suffix) return TRUE; } -/* Splits str into words, adding them to the list. - * The string must be kept alive as long as the list. */ +/* + * Splits str into words, adding them to the list. + * The string must be kept alive as long as the list. + */ int str2Lst_Append(StringList *lp, char *str) { @@ -1134,11 +1141,13 @@ CmdOpts_Init(void) Lst_Init(&opts.create); } -/* Initialize MAKE and .MAKE to the path of the executable, so that it can be +/* + * Initialize MAKE and .MAKE to the path of the executable, so that it can be * found by execvp(3) and the shells, even after a chdir. * * If it's a relative path and contains a '/', resolve it to an absolute path. - * Otherwise keep it as is, assuming it will be found in the PATH. */ + * Otherwise keep it as is, assuming it will be found in the PATH. + */ static void InitVarMake(const char *argv0) { @@ -1157,8 +1166,10 @@ InitVarMake(const char *argv0) Var_Set(".MAKE", make, VAR_GLOBAL); } -/* Add the directories from the colon-separated syspath to defSysIncPath. - * After returning, the contents of syspath is unspecified. */ +/* + * Add the directories from the colon-separated syspath to defSysIncPath. + * After returning, the contents of syspath is unspecified. + */ static void InitDefSysIncPath(char *syspath) { @@ -1321,9 +1332,11 @@ ReadFirstDefaultMakefile(void) free(prefs); } -/* Initialize variables such as MAKE, MACHINE, .MAKEFLAGS. +/* + * Initialize variables such as MAKE, MACHINE, .MAKEFLAGS. * Initialize a few modules. - * Parse the arguments from MAKEFLAGS and the command line. */ + * Parse the arguments from MAKEFLAGS and the command line. + */ static void main_Init(int argc, char **argv) { @@ -1510,8 +1523,10 @@ main_Init(int argc, char **argv) InitDefSysIncPath(syspath); } -/* Read the system makefile followed by either makefile, Makefile or the - * files given by the -f option. Exit on parse errors. */ +/* + * Read the system makefile followed by either makefile, Makefile or the + * files given by the -f option. Exit on parse errors. + */ static void main_ReadFiles(void) { @@ -1587,9 +1602,11 @@ main_PrepareMaking(void) Targ_PrintGraph(1); } -/* Make the targets. +/* + * Make the targets. * If the -v or -V options are given, print variables instead. - * Return whether any of the targets is out-of-date. */ + * Return whether any of the targets is out-of-date. + */ static Boolean main_Run(void) { @@ -1662,7 +1679,8 @@ main(int argc, char **argv) return main_Exit(outOfDate); } -/* Open and parse the given makefile, with all its side effects. +/* + * Open and parse the given makefile, with all its side effects. * * Results: * 0 if ok. -1 if couldn't open file. @@ -1845,10 +1863,12 @@ bad: return bmake_strdup(""); } -/* Print a printf-style error message. +/* + * Print a printf-style error message. * * In default mode, this error message has no consequences, in particular it - * does not affect the exit status. Only in lint mode (-dL) it does. */ + * does not affect the exit status. Only in lint mode (-dL) it does. + */ void Error(const char *fmt, ...) { @@ -1873,11 +1893,13 @@ Error(const char *fmt, ...) main_errors++; } -/* Wait for any running jobs to finish, then produce an error message, +/* + * Wait for any running jobs to finish, then produce an error message, * finally exit immediately. * * Exiting immediately differs from Parse_Error, which exits only after the - * current top-level makefile has been parsed completely. */ + * current top-level makefile has been parsed completely. + */ void Fatal(const char *fmt, ...) { @@ -1901,8 +1923,10 @@ Fatal(const char *fmt, ...) exit(2); /* Not 1 so -q can distinguish error */ } -/* Major exception once jobs are being created. - * Kills all jobs, prints a message and exits. */ +/* + * Major exception once jobs are being created. + * Kills all jobs, prints a message and exits. + */ void Punt(const char *fmt, ...) { @@ -1933,9 +1957,11 @@ DieHorribly(void) exit(2); /* Not 1 so -q can distinguish error */ } -/* Called when aborting due to errors in child shell to signal abnormal exit. +/* + * Called when aborting due to errors in child shell to signal abnormal exit. * The program exits. - * Errors is the number of errors encountered in Make_Make. */ + * Errors is the number of errors encountered in Make_Make. + */ void Finish(int errs) { @@ -2092,8 +2118,10 @@ SetErrorVars(GNode *gn) } } -/* Print some helpful information in case of an error. - * The caller should exit soon after calling this function. */ +/* + * Print some helpful information in case of an error. + * The caller should exit soon after calling this function. + */ void PrintOnError(GNode *gn, const char *msg) { diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index 72d6f4b7314..b58bb07bd6e 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.232 2020/12/19 13:16:25 rillig Exp $ */ +/* $NetBSD: make.c,v 1.233 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -68,7 +68,8 @@ * SUCH DAMAGE. */ -/* Examination of targets and their suitability for creation. +/* + * Examination of targets and their suitability for creation. * * Interface: * Make_Run Initialize things for the module. Returns TRUE if @@ -102,14 +103,16 @@ #include "job.h" /* "@(#)make.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: make.c,v 1.232 2020/12/19 13:16:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: make.c,v 1.233 2020/12/30 10:03:16 rillig Exp $"); /* Sequence # to detect recursion. */ static unsigned int checked_seqno = 1; -/* The current fringe of the graph. +/* + * The current fringe of the graph. * These are nodes which await examination by MakeOODate. - * It is added to by Make_Update and subtracted from by MakeStartJobs */ + * It is added to by Make_Update and subtracted from by MakeStartJobs + */ static GNodeList toBeMade = LST_INIT; @@ -214,7 +217,8 @@ IsOODateRegular(GNode *gn) return FALSE; } -/* See if the node is out of date with respect to its sources. +/* + * See if the node is out of date with respect to its sources. * * Used by Make_Run when deciding which nodes to place on the * toBeMade queue initially and by Make_Update to screen out .USE and @@ -359,7 +363,8 @@ PretendAllChildrenAreMade(GNode *pgn) } } -/* Called by Make_Run and SuffApplyTransform on the downward pass to handle +/* + * Called by Make_Run and SuffApplyTransform on the downward pass to handle * .USE and transformation nodes, by copying the child node's commands, type * flags and children to the parent node. * @@ -429,7 +434,8 @@ Make_HandleUse(GNode *cgn, GNode *pgn) cgn->type & ~(OP_OPMASK | OP_USE | OP_USEBEFORE | OP_TRANSFORM); } -/* Used by Make_Run on the downward pass to handle .USE nodes. Should be +/* + * Used by Make_Run on the downward pass to handle .USE nodes. Should be * called before the children are enqueued to be looked at by MakeAddChild. * * For a .USE child, the commands, type flags and children are copied to the @@ -476,8 +482,10 @@ HandleUseNodes(GNode *gn) } -/* Check the modification time of a gnode, and update it if necessary. - * Return 0 if the gnode does not exist, or its filesystem time if it does. */ +/* + * Check the modification time of a gnode, and update it if necessary. + * Return 0 if the gnode does not exist, or its filesystem time if it does. + */ time_t Make_Recheck(GNode *gn) { @@ -606,7 +614,8 @@ ScheduleOrderSuccessors(GNode *gn) break; } -/* Perform update on the parents of a node. Used by JobFinish once +/* + * Perform update on the parents of a node. Used by JobFinish once * a node has been dealt with and by MakeStartJobs if it finds an * up-to-date node. * @@ -779,7 +788,8 @@ UnmarkChildren(GNode *gn) } } -/* Add a child's name to the ALLSRC and OODATE variables of the given +/* + * Add a child's name to the ALLSRC and OODATE variables of the given * node, but only if it has not been given the .EXEC, .USE or .INVISIBLE * attributes. .EXEC and .USE children are very rarely going to be files, * so... @@ -847,7 +857,8 @@ MakeAddAllSrc(GNode *cgn, GNode *pgn) } } -/* Set up the ALLSRC and OODATE variables. Sad to say, it must be +/* + * Set up the ALLSRC and OODATE variables. Sad to say, it must be * done separately, rather than while traversing the graph. This is * because Make defined OODATE to contain all sources whose modification * times were later than that of the target, *not* those sources that @@ -951,7 +962,8 @@ MakeChildren(GNode *gn) break; } -/* Start as many jobs as possible, taking them from the toBeMade queue. +/* + * Start as many jobs as possible, taking them from the toBeMade queue. * * If the -q option was given, no job will be started, * but as soon as an out-of-date target is found, this function @@ -1181,7 +1193,8 @@ ExamineLater(GNodeList *examine, GNodeList *toBeExamined) } } -/* Expand .USE nodes and create a new targets list. +/* + * Expand .USE nodes and create a new targets list. * * Input: * targs the initial list of targets diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index 82a94b779e4..23590f62e20 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.240 2020/12/28 00:46:24 rillig Exp $ */ +/* $NetBSD: make.h,v 1.241 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -147,14 +147,18 @@ typedef double Boolean; #define TRUE 1.0 #define FALSE 0.0 #elif defined(USE_UCHAR_BOOLEAN) -/* During development, to find code that depends on the exact value of TRUE or - * that stores other values in Boolean variables. */ +/* + * During development, to find code that depends on the exact value of TRUE or + * that stores other values in Boolean variables. + */ typedef unsigned char Boolean; #define TRUE ((unsigned char)0xFF) #define FALSE ((unsigned char)0x00) #elif defined(USE_CHAR_BOOLEAN) -/* During development, to find code that uses a boolean as array index, via - * -Wchar-subscripts. */ +/* + * During development, to find code that uses a boolean as array index, via + * -Wchar-subscripts. + */ typedef char Boolean; #define TRUE ((char)-1) #define FALSE ((char)0x00) @@ -221,11 +225,13 @@ typedef enum GNodeMade { ABORTED } GNodeMade; -/* The OP_ constants are used when parsing a dependency line as a way of +/* + * The OP_ constants are used when parsing a dependency line as a way of * communicating to other parts of the program the way in which a target * should be made. * - * Some of the OP_ constants can be combined, others cannot. */ + * Some of the OP_ constants can be combined, others cannot. + */ typedef enum GNodeType { OP_NONE = 0, @@ -357,8 +363,10 @@ typedef struct ListNode GNodeListNode; typedef struct List /* of CachedDir */ SearchPath; -/* A graph node represents a target that can possibly be made, including its - * relation to other targets and a lot of other details. */ +/* + * A graph node represents a target that can possibly be made, including its + * relation to other targets and a lot of other details. + */ typedef struct GNode { /* The target's name, such as "clean" or "make.c" */ char *name; @@ -481,28 +489,36 @@ extern Boolean doing_depend; /* .DEFAULT rule */ extern GNode *defaultNode; -/* Variables defined internally by make which should not override those set - * by makefiles. */ +/* + * Variables defined internally by make which should not override those set + * by makefiles. + */ extern GNode *VAR_INTERNAL; /* Variables defined in a global context, e.g in the Makefile itself. */ extern GNode *VAR_GLOBAL; /* Variables defined on the command line. */ extern GNode *VAR_CMDLINE; -/* Value returned by Var_Parse when an error is encountered. It actually - * points to an empty string, so naive callers needn't worry about it. */ +/* + * Value returned by Var_Parse when an error is encountered. It actually + * points to an empty string, so naive callers needn't worry about it. + */ extern char var_Error[]; /* The time at the start of this whole process */ extern time_t now; -/* The list of directories to search when looking for targets (set by the - * special target .PATH). */ +/* + * The list of directories to search when looking for targets (set by the + * special target .PATH). + */ extern SearchPath dirSearchPath; /* Used for .include "...". */ extern SearchPath *parseIncPath; -/* Used for .include <...>, for the built-in sys.mk and makefiles from the - * command line arguments. */ +/* + * Used for .include <...>, for the built-in sys.mk and makefiles from the + * command line arguments. + */ extern SearchPath *sysIncPath; /* The default for sysIncPath. */ extern SearchPath *defSysIncPath; diff --git a/usr.bin/make/make_malloc.h b/usr.bin/make/make_malloc.h index 2bee99a4492..4dacc924c40 100644 --- a/usr.bin/make/make_malloc.h +++ b/usr.bin/make/make_malloc.h @@ -1,4 +1,4 @@ -/* $NetBSD: make_malloc.h,v 1.14 2020/12/15 01:23:55 rillig Exp $ */ +/* $NetBSD: make_malloc.h,v 1.15 2020/12/30 10:03:16 rillig Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -41,11 +41,13 @@ char *bmake_strldup(const char *, size_t); char *bmake_strsedup(const char *, const char *); -/* Thin wrapper around free(3) to avoid the extra function call in case +/* + * Thin wrapper around free(3) to avoid the extra function call in case * p is NULL, to save a few machine instructions. * * The case of a NULL pointer happens especially often after Var_Value, - * since only environment variables need to be freed, but not others. */ + * since only environment variables need to be freed, but not others. + */ MAKE_INLINE void bmake_free(void *p) { diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 2c2fc183095..c4e21466208 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.523 2020/12/28 15:42:53 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.524 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.523 2020/12/28 15:42:53 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.524 2020/12/30 10:03:16 rillig Exp $"); /* types and constants */ @@ -190,18 +190,22 @@ static GNode *mainNode; /* eval state */ -/* During parsing, the targets from the left-hand side of the currently +/* + * During parsing, the targets from the left-hand side of the currently * active dependency line, or NULL if the current line does not belong to a * dependency line, for example because it is a variable assignment. * - * See unit-tests/deptgt.mk, keyword "parse.c:targets". */ + * See unit-tests/deptgt.mk, keyword "parse.c:targets". + */ static GNodeList *targets; #ifdef CLEANUP -/* All shell commands for all targets, in no particular order and possibly +/* + * All shell commands for all targets, in no particular order and possibly * with duplicates. Kept in a separate list since the commands from .USE or * .USEBEFORE nodes are shared with other GNodes, thereby giving up the - * easily understandable ownership over the allocated strings. */ + * easily understandable ownership over the allocated strings. + */ static StringList targCmds = LST_INIT; #endif @@ -220,7 +224,8 @@ static int fatals = 0; * Variables for doing includes */ -/* The include chain of makefiles. At the bottom is the top-level makefile +/* + * The include chain of makefiles. At the bottom is the top-level makefile * from the command line, and on top of that, there are the included files or * .for loops, up to and including the current file. * @@ -504,8 +509,10 @@ ParseIsEscaped(const char *line, const char *c) } } -/* Add the filename and lineno to the GNode so that we remember where it - * was first defined. */ +/* + * Add the filename and lineno to the GNode so that we remember where it + * was first defined. + */ static void ParseMark(GNode *gn) { @@ -514,8 +521,10 @@ ParseMark(GNode *gn) gn->lineno = curFile->lineno; } -/* Look in the table of keywords for one matching the given string. - * Return the index of the keyword, or -1 if it isn't there. */ +/* + * Look in the table of keywords for one matching the given string. + * Return the index of the keyword, or -1 if it isn't there. + */ static int ParseFindKeyword(const char *str) { @@ -613,12 +622,14 @@ ParseErrorInternal(const char *fname, size_t lineno, } } -/* Print a parse error message, including location information. +/* + * Print a parse error message, including location information. * * If the level is PARSE_FATAL, continue parsing until the end of the * current top-level makefile, then exit (see Parse_File). * - * Fmt is given without a trailing newline. */ + * Fmt is given without a trailing newline. + */ void Parse_Error(ParseErrorLevel type, const char *fmt, ...) { @@ -649,8 +660,10 @@ Parse_Error(ParseErrorLevel type, const char *fmt, ...) } -/* Parse and handle a .info, .warning or .error directive. - * For an .error directive, immediately exit. */ +/* + * Parse and handle a .info, .warning or .error directive. + * For an .error directive, immediately exit. + */ static void ParseMessage(ParseErrorLevel level, const char *levelName, const char *umsg) { @@ -674,11 +687,13 @@ ParseMessage(ParseErrorLevel level, const char *levelName, const char *umsg) } } -/* Add the child to the parent's children. +/* + * Add the child to the parent's children. * * Additionally, add the parent to the child's parents, but only if the * target is not special. An example for such a special target is .END, - * which does not need to be informed once the child target has been made. */ + * which does not need to be informed once the child target has been made. + */ static void LinkSource(GNode *pgn, GNode *cgn, Boolean isSpecial) { @@ -1542,7 +1557,8 @@ ParseDoDependencySourcesMundane(char *start, char *end, return TRUE; } -/* Parse a dependency line consisting of targets, followed by a dependency +/* + * Parse a dependency line consisting of targets, followed by a dependency * operator, optionally followed by sources. * * The nodes of the sources are linked as children to the nodes of the @@ -1900,14 +1916,16 @@ VarAssign_EvalShell(const char *name, const char *uvalue, GNode *ctxt, FStr_Done(&cmd); } -/* Perform a variable assignment. +/* + * Perform a variable assignment. * * The actual value of the variable is returned in *out_avalue and * *out_avalue_freeIt. Especially for VAR_SUBST and VAR_SHELL this can differ * from the literal value. * * Return whether the assignment was actually done. The assignment is only - * skipped if the operator is '?=' and the variable already exists. */ + * skipped if the operator is '?=' and the variable already exists. + */ static Boolean VarAssign_Eval(const char *name, VarAssignOp op, const char *uvalue, GNode *ctxt, FStr *out_TRUE_avalue) @@ -1967,8 +1985,10 @@ Parse_DoVar(VarAssign *var, GNode *ctxt) } -/* See if the command possibly calls a sub-make by using the variable - * expressions ${.MAKE}, ${MAKE} or the plain word "make". */ +/* + * See if the command possibly calls a sub-make by using the variable + * expressions ${.MAKE}, ${MAKE} or the plain word "make". + */ static Boolean MaybeSubMake(const char *cmd) { @@ -2006,10 +2026,12 @@ MaybeSubMake(const char *cmd) return FALSE; } -/* Append the command to the target node. +/* + * Append the command to the target node. * * The node may be marked as a submake node if the command is determined to - * be that. */ + * be that. + */ static void ParseAddCmd(GNode *gn, char *cmd) { @@ -2052,7 +2074,8 @@ Parse_AddIncludeDir(const char *dir) (void)Dir_AddDir(parseIncPath, dir); } -/* Handle one of the .[-ds]include directives by remembering the current file +/* + * Handle one of the .[-ds]include directives by remembering the current file * and pushing the included file on the stack. After the included file has * finished, parsing continues with the including file; see Parse_SetInput * and ParseEOF. @@ -2217,8 +2240,10 @@ ParseDoInclude(char *line /* XXX: bad name */) free(file); } -/* Split filename into dirname + basename, then assign these to the - * given variables. */ +/* + * Split filename into dirname + basename, then assign these to the + * given variables. + */ static void SetFilenameVars(const char *filename, const char *dirvar, const char *filevar) { @@ -2318,11 +2343,13 @@ VarContainsWord(const char *varname, const char *word) return found; } -/* Track the makefiles we read - so makefiles can set dependencies on them. +/* + * Track the makefiles we read - so makefiles can set dependencies on them. * Avoid adding anything more than once. * * Time complexity: O(n) per call, in total O(n^2), where n is the number - * of makefiles that have been loaded. */ + * of makefiles that have been loaded. + */ static void ParseTrackInput(const char *name) { @@ -3031,8 +3058,10 @@ FindSemicolon(char *p) return p; } -/* dependency -> target... op [source...] - * op -> ':' | '::' | '!' */ +/* + * dependency -> target... op [source...] + * op -> ':' | '::' | '!' + */ static void ParseDependency(char *line) { diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c index e92de92bff9..e65ffeece3a 100644 --- a/usr.bin/make/str.c +++ b/usr.bin/make/str.c @@ -1,4 +1,4 @@ -/* $NetBSD: str.c,v 1.75 2020/12/12 19:13:47 rillig Exp $ */ +/* $NetBSD: str.c,v 1.76 2020/12/30 10:03:16 rillig Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -71,7 +71,7 @@ #include "make.h" /* "@(#)str.c 5.8 (Berkeley) 6/1/90" */ -MAKE_RCSID("$NetBSD: str.c,v 1.75 2020/12/12 19:13:47 rillig Exp $"); +MAKE_RCSID("$NetBSD: str.c,v 1.76 2020/12/30 10:03:16 rillig Exp $"); /* Return the concatenation of s1 and s2, freshly allocated. */ char * @@ -115,7 +115,8 @@ str_concat4(const char *s1, const char *s2, const char *s3, const char *s4) return result; } -/* Fracture a string into an array of words (as delineated by tabs or spaces) +/* + * Fracture a string into an array of words (as delineated by tabs or spaces) * taking quotation marks into account. * * If expand is TRUE, quotes are removed and escape sequences such as \r, \t, diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index e27f9b29967..1576ea8bf4d 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.332 2020/12/20 13:38:43 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.333 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -114,7 +114,7 @@ #include "dir.h" /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ -MAKE_RCSID("$NetBSD: suff.c,v 1.332 2020/12/20 13:38:43 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.333 2020/12/30 10:03:16 rillig Exp $"); typedef List SuffixList; typedef ListNode SuffixListNode; @@ -423,8 +423,10 @@ SuffixList_Remove(SuffixList *list, Suffix *suff) } } -/* Insert the suffix into the list, keeping the list ordered by suffix - * number. */ +/* + * Insert the suffix into the list, keeping the list ordered by suffix + * number. + */ static void SuffixList_Insert(SuffixList *list, Suffix *suff) { @@ -502,7 +504,8 @@ Suff_ClearSuffixes(void) nullSuff->flags = SUFF_NULL; } -/* Parse a transformation string such as ".c.o" to find its two component +/* + * Parse a transformation string such as ".c.o" to find its two component * suffixes (the source ".c" and the target ".o"). If there are no such * suffixes, try a single-suffix transformation as well. * @@ -671,7 +674,8 @@ Suff_EndTransform(GNode *gn) SuffixList_Remove(srcSuffParents, targSuff); } -/* Called from Suff_AddSuffix to search through the list of +/* + * Called from Suff_AddSuffix to search through the list of * existing transformation rules and rebuild the transformation graph when * it has been destroyed by Suff_ClearSuffixes. If the given rule is a * transformation involving this suffix and another, existing suffix, the @@ -813,7 +817,8 @@ UpdateTargets(GNode **inout_main, Suffix *suff) } } -/* Add the suffix to the end of the list of known suffixes. +/* + * Add the suffix to the end of the list of known suffixes. * Should we restructure the suffix graph? Make doesn't. * * A GNode is created for the suffix (XXX: this sounds completely wrong) and @@ -1478,7 +1483,8 @@ Suff_FindPath(GNode *gn) } } -/* Apply a transformation rule, given the source and target nodes and +/* + * Apply a transformation rule, given the source and target nodes and * suffixes. * * The source and target are linked and the commands from the transformation @@ -1565,7 +1571,8 @@ ExpandMember(GNode *gn, const char *eoarch, GNode *mem, Suffix *memSuff) static void FindDeps(GNode *, CandidateSearcher *); -/* Locate dependencies for an OP_ARCHV node. +/* + * Locate dependencies for an OP_ARCHV node. * * Input: * gn Node for which to locate dependencies @@ -2003,7 +2010,8 @@ CandidateSearcher_CleanUp(CandidateSearcher *cs) } -/* Find implicit sources for the target. +/* + * Find implicit sources for the target. * * Nodes are added to the graph as children of the passed-in node. The nodes * are marked to have their IMPSRC variable filled in. The PREFIX variable diff --git a/usr.bin/make/util.c b/usr.bin/make/util.c index e908468d6be..aebcc878996 100644 --- a/usr.bin/make/util.c +++ b/usr.bin/make/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.72 2020/12/15 20:39:15 rillig Exp $ */ +/* $NetBSD: util.c,v 1.73 2020/12/30 10:03:16 rillig Exp $ */ /* * Missing stuff from OS's @@ -15,7 +15,7 @@ #include "make.h" -MAKE_RCSID("$NetBSD: util.c,v 1.72 2020/12/15 20:39:15 rillig Exp $"); +MAKE_RCSID("$NetBSD: util.c,v 1.73 2020/12/30 10:03:16 rillig Exp $"); #if !defined(MAKE_NATIVE) && !defined(HAVE_STRERROR) extern int errno, sys_nerr; @@ -154,7 +154,8 @@ main(int argc, char *argv[]) #endif #if defined(__hpux__) || defined(__hpux) -/* strrcpy(): +/* + * strrcpy(): * Like strcpy, going backwards and returning the new pointer */ static char * diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index ca7a9979c79..e4eac780839 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.777 2020/12/29 03:21:09 rillig Exp $ */ +/* $NetBSD: var.c,v 1.778 2020/12/30 10:03:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,7 +131,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.777 2020/12/29 03:21:09 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.778 2020/12/30 10:03:16 rillig Exp $"); typedef enum VarFlags { VAR_NONE = 0, @@ -174,7 +174,8 @@ typedef enum VarFlags { VAR_READONLY = 0x80 } VarFlags; -/* Variables are defined using one of the VAR=value assignments. Their +/* + * Variables are defined using one of the VAR=value assignments. Their * value can be queried by expressions such as $V, ${VAR}, or with modifiers * such as ${VAR:S,from,to,g:Q}. * @@ -253,15 +254,19 @@ ENUM_FLAGS_RTTI_4(VarEvalFlags, */ char **savedEnv = NULL; -/* Special return value for Var_Parse, indicating a parse error. It may be +/* + * Special return value for Var_Parse, indicating a parse error. It may be * caused by an undefined variable, a syntax error in a modifier or - * something entirely different. */ + * something entirely different. + */ char var_Error[] = ""; -/* Special return value for Var_Parse, indicating an undefined variable in +/* + * Special return value for Var_Parse, indicating an undefined variable in * a case where VARE_UNDEFERR is not set. This undefined variable is * typically a dynamic variable such as ${.TARGET}, whose expansion needs to - * be deferred until it is defined in an actual target. */ + * be deferred until it is defined in an actual target. + */ static char varUndefined[] = ""; /* @@ -364,7 +369,8 @@ GNode_FindVar(GNode *ctxt, const char *varname, unsigned int hash) return HashTable_FindValueHash(&ctxt->vars, varname, hash); } -/* Find the variable in the context, and maybe in other contexts as well. +/* + * Find the variable in the context, and maybe in other contexts as well. * * Input: * name name to find, is not expanded any further @@ -433,7 +439,8 @@ VarFind(const char *name, GNode *ctxt, Boolean elsewhere) return var; } -/* If the variable is an environment variable, free it. +/* + * If the variable is an environment variable, free it. * * Input: * v the variable @@ -454,8 +461,10 @@ VarFreeEnv(Var *v, Boolean freeValue) return TRUE; } -/* Add a new variable of the given name and value to the given context. - * The name and val arguments are duplicated so they may safely be freed. */ +/* + * Add a new variable of the given name and value to the given context. + * The name and val arguments are duplicated so they may safely be freed. + */ static void VarAdd(const char *name, const char *val, GNode *ctxt, VarSetFlags flags) { @@ -494,8 +503,10 @@ Var_DeleteVar(const char *varname, GNode *ctxt) free(v); } -/* Remove a variable from a context, freeing all related memory as well. - * The variable name is expanded once. */ +/* + * Remove a variable from a context, freeing all related memory as well. + * The variable name is expanded once. + */ void Var_Delete(const char *name, GNode *ctxt) { @@ -1094,7 +1105,8 @@ Var_Append(const char *name, const char *val, GNode *ctxt) free(name_freeIt); } -/* See if the given variable exists, in the given context or in other +/* + * See if the given variable exists, in the given context or in other * fallback contexts. * * Input: @@ -1151,8 +1163,10 @@ Var_Value(const char *name, GNode *ctxt) : FStr_InitRefer(value); } -/* Return the unexpanded variable value from this node, without trying to look - * up the variable in any other context. */ +/* + * Return the unexpanded variable value from this node, without trying to look + * up the variable in any other context. + */ const char * Var_ValueDirect(const char *name, GNode *ctxt) { @@ -1206,17 +1220,21 @@ SepBuf_Destroy(SepBuf *buf, Boolean free_buf) } -/* This callback for ModifyWords gets a single word from a variable expression +/* + * This callback for ModifyWords gets a single word from a variable expression * and typically adds a modification of this word to the buffer. It may also * do nothing or add several words. * * For example, in ${:Ua b c:M*2}, the callback is called 3 times, once for - * each word of "a b c". */ + * each word of "a b c". + */ typedef void (*ModifyWordsCallback)(const char *word, SepBuf *buf, void *data); -/* Callback for ModifyWords to implement the :H modifier. - * Add the dirname of the given word to the buffer. */ +/* + * Callback for ModifyWords to implement the :H modifier. + * Add the dirname of the given word to the buffer. + */ static void ModifyWord_Head(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) { @@ -1227,16 +1245,20 @@ ModifyWord_Head(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) SepBuf_AddStr(buf, "."); } -/* Callback for ModifyWords to implement the :T modifier. - * Add the basename of the given word to the buffer. */ +/* + * Callback for ModifyWords to implement the :T modifier. + * Add the basename of the given word to the buffer. + */ static void ModifyWord_Tail(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) { SepBuf_AddStr(buf, str_basename(word)); } -/* Callback for ModifyWords to implement the :E modifier. - * Add the filename suffix of the given word to the buffer, if it exists. */ +/* + * Callback for ModifyWords to implement the :E modifier. + * Add the filename suffix of the given word to the buffer, if it exists. + */ static void ModifyWord_Suffix(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) { @@ -1245,8 +1267,10 @@ ModifyWord_Suffix(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) SepBuf_AddStr(buf, lastDot + 1); } -/* Callback for ModifyWords to implement the :R modifier. - * Add the basename of the given word to the buffer. */ +/* + * Callback for ModifyWords to implement the :R modifier. + * Add the basename of the given word to the buffer. + */ static void ModifyWord_Root(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) { @@ -1255,8 +1279,10 @@ ModifyWord_Root(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) SepBuf_AddBytes(buf, word, len); } -/* Callback for ModifyWords to implement the :M modifier. - * Place the word in the buffer if it matches the given pattern. */ +/* + * Callback for ModifyWords to implement the :M modifier. + * Place the word in the buffer if it matches the given pattern. + */ static void ModifyWord_Match(const char *word, SepBuf *buf, void *data) { @@ -1266,8 +1292,10 @@ ModifyWord_Match(const char *word, SepBuf *buf, void *data) SepBuf_AddStr(buf, word); } -/* Callback for ModifyWords to implement the :N modifier. - * Place the word in the buffer if it doesn't match the given pattern. */ +/* + * Callback for ModifyWords to implement the :N modifier. + * Place the word in the buffer if it doesn't match the given pattern. + */ static void ModifyWord_NoMatch(const char *word, SepBuf *buf, void *data) { @@ -1278,7 +1306,8 @@ ModifyWord_NoMatch(const char *word, SepBuf *buf, void *data) #ifdef SYSVVARSUB -/* Check word against pattern for a match (% is a wildcard). +/* + * Check word against pattern for a match (% is a wildcard). * * Input: * word Word to examine @@ -1394,8 +1423,10 @@ struct ModifyWord_SubstArgs { Boolean matched; }; -/* Callback for ModifyWords to implement the :S,from,to, modifier. - * Perform a string substitution on the given word. */ +/* + * Callback for ModifyWords to implement the :S,from,to, modifier. + * Perform a string substitution on the given word. + */ static void ModifyWord_Subst(const char *word, SepBuf *buf, void *data) { @@ -1476,8 +1507,10 @@ struct ModifyWord_SubstRegexArgs { Boolean matched; }; -/* Callback for ModifyWords to implement the :C/from/to/ modifier. - * Perform a regex substitution on the given word. */ +/* + * Callback for ModifyWords to implement the :C/from/to/ modifier. + * Perform a regex substitution on the given word. + */ static void ModifyWord_SubstRegex(const char *word, SepBuf *buf, void *data) { @@ -1593,8 +1626,10 @@ ModifyWord_Loop(const char *word, SepBuf *buf, void *data) } -/* The :[first..last] modifier selects words from the expression. - * It can also reverse the words. */ +/* + * The :[first..last] modifier selects words from the expression. + * It can also reverse the words. + */ static char * VarSelectWords(char sep, Boolean oneBigWord, const char *str, int first, int last) @@ -1651,8 +1686,10 @@ VarSelectWords(char sep, Boolean oneBigWord, const char *str, int first, } -/* Callback for ModifyWords to implement the :tA modifier. - * Replace each word with the result of realpath() if successful. */ +/* + * Callback for ModifyWords to implement the :tA modifier. + * Replace each word with the result of realpath() if successful. + */ static void ModifyWord_Realpath(const char *word, SepBuf *buf, void *data MAKE_ATTR_UNUSED) { @@ -1751,8 +1788,10 @@ VarUniq(const char *str) } -/* Quote shell meta-characters and space characters in the string. - * If quoteDollar is set, also quote and double any '$' characters. */ +/* + * Quote shell meta-characters and space characters in the string. + * If quoteDollar is set, also quote and double any '$' characters. + */ static char * VarQuote(const char *str, Boolean quoteDollar) { @@ -1777,8 +1816,10 @@ VarQuote(const char *str, Boolean quoteDollar) return Buf_Destroy(&buf, FALSE); } -/* Compute the 32-bit hash of the given string, using the MurmurHash3 - * algorithm. Output is encoded as 8 hex digits, in Little Endian order. */ +/* + * Compute the 32-bit hash of the given string, using the MurmurHash3 + * algorithm. Output is encoded as 8 hex digits, in Little Endian order. + */ static char * VarHash(const char *str) { @@ -2473,8 +2514,10 @@ ApplyModifier_ShellCommand(const char **pp, ApplyModifiersState *st) return AMR_OK; } -/* The :range modifier generates an integer sequence as long as the words. - * The :range=7 modifier generates an integer sequence from 1 to 7. */ +/* + * The :range modifier generates an integer sequence as long as the words. + * The :range=7 modifier generates an integer sequence from 1 to 7. + */ static ApplyModifierResult ApplyModifier_Range(const char **pp, const char *val, ApplyModifiersState *st) { @@ -3207,8 +3250,10 @@ ok: return AMR_OK; } -/* :_=... - * remember current value */ +/* + * :_=... + * remember current value + */ static ApplyModifierResult ApplyModifier_Remember(const char **pp, const char *val, ApplyModifiersState *st) @@ -3231,8 +3276,10 @@ ApplyModifier_Remember(const char **pp, const char *val, return AMR_OK; } -/* Apply the given function to each word of the variable value, - * for a single-letter modifier such as :H, :T. */ +/* + * Apply the given function to each word of the variable value, + * for a single-letter modifier such as :H, :T. + */ static ApplyModifierResult ApplyModifier_WordFunc(const char **pp, const char *val, ApplyModifiersState *st, ModifyWordsCallback modifyWord) @@ -3658,8 +3705,10 @@ cleanup: return FStr_InitRefer(var_Error); } -/* Only four of the local variables are treated specially as they are the - * only four that will be set when dynamic sources are expanded. */ +/* + * Only four of the local variables are treated specially as they are the + * only four that will be set when dynamic sources are expanded. + */ static Boolean VarnameIsDynamic(const char *name, size_t len) { @@ -3711,8 +3760,10 @@ UndefinedShortVarValue(char varname, const GNode *ctxt) return NULL; } -/* Parse a variable name, until the end character or a colon, whichever - * comes first. */ +/* + * Parse a variable name, until the end character or a colon, whichever + * comes first. + */ static char * ParseVarname(const char **pp, char startc, char endc, GNode *ctxt, VarEvalFlags eflags, @@ -3781,8 +3832,10 @@ ValidShortVarname(char varname, const char *start) return VPR_ERR; } -/* Parse a single-character variable name such as $V or $@. - * Return whether to continue parsing. */ +/* + * Parse a single-character variable name such as $V or $@. + * Return whether to continue parsing. + */ static Boolean ParseVarnameShort(char startc, const char **pp, GNode *ctxt, VarEvalFlags eflags, @@ -3906,10 +3959,12 @@ EvalUndefined(Boolean dynamic, const char *start, const char *p, char *varname, return VPR_OK; } -/* Parse a long variable name enclosed in braces or parentheses such as $(VAR) +/* + * Parse a long variable name enclosed in braces or parentheses such as $(VAR) * or ${VAR}, up to the closing brace or parenthesis, or in the case of * ${VAR:Modifiers}, up to the ':' that starts the modifiers. - * Return whether to continue parsing. */ + * Return whether to continue parsing. + */ static Boolean ParseVarnameLong( const char *p, @@ -4274,7 +4329,8 @@ VarSubstPlain(const char **pp, Buffer *res) *pp = p; } -/* Expand all variable expressions like $V, ${VAR}, $(VAR:Modifiers) in the +/* + * Expand all variable expressions like $V, ${VAR}, $(VAR:Modifiers) in the * given string. * * Input: |
