Module Name:    src
Committed By:   rillig
Date:           Tue Dec 19 19:33:40 UTC 2023

Modified Files:
        src/usr.bin/make: buf.c buf.h compat.c cond.c dir.c hash.c hash.h job.c
            job.h parse.c suff.c var.c
        src/usr.bin/make/unit-tests: cond-func-empty.mk dep-var.mk dir.mk
            directive-for-errors.mk opt-debug-loud.mk

Log Message:
make: clean up comments

No binary change, except for line numbers in assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/make/buf.c
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/make/buf.h
cvs rdiff -u -r1.247 -r1.248 src/usr.bin/make/compat.c
cvs rdiff -u -r1.356 -r1.357 src/usr.bin/make/cond.c
cvs rdiff -u -r1.284 -r1.285 src/usr.bin/make/dir.c
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/make/hash.c
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/make/hash.h
cvs rdiff -u -r1.460 -r1.461 src/usr.bin/make/job.c
cvs rdiff -u -r1.77 -r1.78 src/usr.bin/make/job.h
cvs rdiff -u -r1.711 -r1.712 src/usr.bin/make/parse.c
cvs rdiff -u -r1.371 -r1.372 src/usr.bin/make/suff.c
cvs rdiff -u -r1.1083 -r1.1084 src/usr.bin/make/var.c
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/cond-func-empty.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/dep-var.mk \
    src/usr.bin/make/unit-tests/dir.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-for-errors.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-debug-loud.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/buf.c
diff -u src/usr.bin/make/buf.c:1.56 src/usr.bin/make/buf.c:1.57
--- src/usr.bin/make/buf.c:1.56	Thu Jun  1 07:44:10 2023
+++ src/usr.bin/make/buf.c	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.56 2023/06/01 07:44:10 rillig Exp $	*/
+/*	$NetBSD: buf.c,v 1.57 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -69,13 +69,13 @@
  * SUCH DAMAGE.
  */
 
-/* Automatically-expanding null-terminated character buffers. */
+/* Automatically growing null-terminated buffers of characters. */
 
 #include <limits.h>
 #include "make.h"
 
 /*	"@(#)buf.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: buf.c,v 1.56 2023/06/01 07:44:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: buf.c,v 1.57 2023/12/19 19:33:39 rillig Exp $");
 
 /* Make space in the buffer for adding at least 16 more bytes. */
 void

Index: src/usr.bin/make/buf.h
diff -u src/usr.bin/make/buf.h:1.48 src/usr.bin/make/buf.h:1.49
--- src/usr.bin/make/buf.h:1.48	Thu Jun  1 07:44:10 2023
+++ src/usr.bin/make/buf.h	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.h,v 1.48 2023/06/01 07:44:10 rillig Exp $	*/
+/*	$NetBSD: buf.h,v 1.49 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@ Buf_Clear(Buffer *buf)
 	buf->data[0] = '\0';
 }
 
-/* Buf_AddByte adds a single byte to a buffer. */
+/* Adds a single byte to a buffer. */
 MAKE_INLINE void
 Buf_AddByte(Buffer *buf, char byte)
 {

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.247 src/usr.bin/make/compat.c:1.248
--- src/usr.bin/make/compat.c:1.247	Thu May  4 22:31:17 2023
+++ src/usr.bin/make/compat.c	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.247 2023/05/04 22:31:17 sjg Exp $	*/
+/*	$NetBSD: compat.c,v 1.248 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.247 2023/05/04 22:31:17 sjg Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.248 2023/12/19 19:33:39 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -129,9 +129,7 @@ CompatInterrupt(int signo)
 	CompatDeleteTarget(curTarg);
 
 	if (curTarg != NULL && !GNode_IsPrecious(curTarg)) {
-		/*
-		 * Run .INTERRUPT only if hit with interrupt signal
-		 */
+		/* Run .INTERRUPT only if hit with interrupt signal. */
 		if (signo == SIGINT) {
 			GNode *gn = Targ_FindNode(".INTERRUPT");
 			if (gn != NULL) {
@@ -289,37 +287,22 @@ Compat_RunCommand(const char *cmdp, GNod
 
 	while (ch_isspace(*cmd))
 		cmd++;
-
-	/*
-	 * If we did not end up with a command, just skip it.
-	 */
 	if (cmd[0] == '\0')
 		return true;
 
 	useShell = UseShell(cmd);
-	/*
-	 * Print the command before echoing if we're not supposed to be quiet
-	 * for this one. We also print the command if -n given.
-	 */
+
 	if (!silent || !GNode_ShouldExecute(gn)) {
 		printf("%s\n", cmd);
 		fflush(stdout);
 	}
 
-	/*
-	 * If we're not supposed to execute any commands, this is as far as
-	 * we go...
-	 */
 	if (!doIt && !GNode_ShouldExecute(gn))
 		return true;
 
 	DEBUG1(JOB, "Execute: '%s'\n", cmd);
 
 	if (useShell) {
-		/*
-		 * We need to pass the command off to the shell, typically
-		 * because the command contains a "meta" character.
-		 */
 		static const char *shargv[5];
 
 		/* The following work for any of the builtin shell specs. */
@@ -334,11 +317,6 @@ Compat_RunCommand(const char *cmdp, GNod
 		bp = NULL;
 		mav = NULL;
 	} else {
-		/*
-		 * No meta-characters, so no need to exec a shell. Break the
-		 * command into words to form an argument vector we can
-		 * execute.
-		 */
 		Words words = Str_Words(cmd, false);
 		mav = words.words;
 		bp = words.freeIt;
@@ -377,9 +355,7 @@ Compat_RunCommand(const char *cmdp, GNod
 		meta_compat_parent(cpid);
 #endif
 
-	/*
-	 * The child is off and running. Now all we can do is wait...
-	 */
+	/* The child is off and running. Now all we can do is wait... */
 	while ((retstat = wait(&reason)) != cpid) {
 		if (retstat > 0)
 			JobReapChild(retstat, reason, false); /* not ours? */
@@ -392,9 +368,9 @@ Compat_RunCommand(const char *cmdp, GNod
 		Fatal("error in wait: %d: %s", retstat, strerror(errno));
 
 	if (WIFSTOPPED(reason)) {
-		status = WSTOPSIG(reason);	/* stopped */
+		status = WSTOPSIG(reason);
 	} else if (WIFEXITED(reason)) {
-		status = WEXITSTATUS(reason);	/* exited */
+		status = WEXITSTATUS(reason);
 #if defined(USE_META) && defined(USE_FILEMON_ONCE)
 		if (useMeta)
 			meta_cmd_finish(NULL);
@@ -405,7 +381,7 @@ Compat_RunCommand(const char *cmdp, GNod
 			printf("*** Error code %d", status);
 		}
 	} else {
-		status = WTERMSIG(reason);	/* signaled */
+		status = WTERMSIG(reason);
 		printf("*** Signal %d", status);
 	}
 
@@ -591,10 +567,6 @@ MakeUnmade(GNode *gn, GNode *pgn)
 		gn->type |= OP_SILENT;
 
 	if (Job_CheckCommands(gn, Fatal)) {
-		/*
-		 * Our commands are ok, but we still have to worry about
-		 * the -t flag.
-		 */
 		if (!opts.touch || (gn->type & OP_MAKE)) {
 			curTarg = gn;
 #ifdef USE_META
@@ -778,7 +750,6 @@ Compat_MakeAll(GNodeList *targs)
 			errorNode = gn;
 	}
 
-	/* If the user has defined a .END target, run its commands. */
 	if (errorNode == NULL) {
 		GNode *endNode = Targ_GetEndNode();
 		Compat_Make(endNode, endNode);

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.356 src/usr.bin/make/cond.c:1.357
--- src/usr.bin/make/cond.c:1.356	Sun Dec 17 08:53:54 2023
+++ src/usr.bin/make/cond.c	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.356 2023/12/17 08:53:54 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.357 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -81,8 +81,7 @@
  *			of one of the .if directives or the condition in a
  *			':?then:else' variable modifier.
  *
- *	Cond_EndFile
- *			At the end of reading a makefile, ensure that the
+ *	Cond_EndFile	At the end of reading a makefile, ensure that the
  *			conditional directives are well-balanced.
  */
 
@@ -92,7 +91,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.356 2023/12/17 08:53:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.357 2023/12/19 19:33:39 rillig Exp $");
 
 /*
  * Conditional expressions conform to this grammar:
@@ -635,7 +634,6 @@ CondParser_Comparison(CondParser *par, b
 	CondParser_SkipWhitespace(par);
 
 	if (!CondParser_ComparisonOp(par, &op)) {
-		/* Unknown operator, compare against an empty string or 0. */
 		t = ToToken(doEval && EvalTruthy(par, lhs.str, lhsQuoted));
 		goto done_lhs;
 	}
@@ -752,8 +750,8 @@ CondParser_ComparisonOrLeaf(CondParser *
 
 	/*
 	 * Most likely we have a naked token to apply the default function to.
-	 * However ".if a == b" gets here when the "a" is unquoted and doesn't
-	 * start with a '$'. This surprises people.
+	 * However, ".if a == b" gets here when the "a" is unquoted and
+	 * doesn't start with a '$'. This surprises people.
 	 * If what follows the function argument is a '=' or '!' then the
 	 * syntax would be invalid if we did "defined(a)" - so instead treat
 	 * as an expression.
@@ -773,7 +771,7 @@ CondParser_ComparisonOrLeaf(CondParser *
 	 * Evaluate the argument using the default function.
 	 * This path always treats .if as .ifdef. To get here, the character
 	 * after .if must have been taken literally, so the argument cannot
-	 * be empty - even if it contained a variable expansion.
+	 * be empty - even if it contained an expression.
 	 */
 	t = ToToken(doEval && par->evalBare(arg) != par->negateEvalBare);
 	free(arg);
@@ -1034,12 +1032,6 @@ DetermineKindOfConditional(const char **
 	return true;
 
 unknown_directive:
-	/*
-	 * TODO: Add error message about unknown directive, since there is no
-	 * other known directive that starts with 'el' or 'if'.
-	 *
-	 * Example: .elifx 123
-	 */
 	return false;
 }
 
@@ -1068,7 +1060,7 @@ unknown_directive:
  *			conditional (when <cond> evaluates to true)
  *	CR_FALSE	to skip the lines after the conditional
  *			(when <cond> evaluates to false, or when a previous
- *			branch has already been taken)
+ *			branch was already taken)
  *	CR_ERROR	if the conditional was not valid, either because of
  *			a syntax error or because some variable was undefined
  *			or because the condition could not be evaluated
@@ -1115,7 +1107,7 @@ Cond_EvalLine(const char *line)
 	p++;			/* skip the leading '.' */
 	cpp_skip_hspace(&p);
 
-	if (IsEndif(p)) {	/* It is an '.endif'. */
+	if (IsEndif(p)) {
 		if (p[5] != '\0') {
 			Parse_Error(PARSE_FATAL,
 			    "The .endif directive does not take arguments");
@@ -1135,14 +1127,8 @@ Cond_EvalLine(const char *line)
 
 	/* Parse the name of the directive, such as 'if', 'elif', 'endif'. */
 	if (p[0] == 'e') {
-		if (p[1] != 'l') {
-			/*
-			 * Unknown directive.  It might still be a
-			 * transformation rule like '.err.txt',
-			 * therefore no error message here.
-			 */
+		if (p[1] != 'l')
 			return CR_ERROR;
-		}
 
 		/* Quite likely this is 'else' or 'elif' */
 		p += 2;
@@ -1176,13 +1162,8 @@ Cond_EvalLine(const char *line)
 	} else
 		isElif = false;
 
-	if (p[0] != 'i' || p[1] != 'f') {
-		/*
-		 * Unknown directive.  It might still be a transformation rule
-		 * like '.elisp.scm', therefore no error message here.
-		 */
-		return CR_ERROR;	/* Not an ifxxx or elifxxx line */
-	}
+	if (p[0] != 'i' || p[1] != 'f')
+		return CR_ERROR;
 
 	if (!DetermineKindOfConditional(&p, &plain, &evalBare, &negate))
 		return CR_ERROR;
@@ -1219,16 +1200,11 @@ Cond_EvalLine(const char *line)
 		state = cond_states[cond_depth];
 		cond_depth++;
 		if (!(state & IFS_ACTIVE)) {
-			/*
-			 * If we aren't parsing the data,
-			 * treat as always false.
-			 */
 			cond_states[cond_depth] = IFS_WAS_ACTIVE;
 			return CR_FALSE;
 		}
 	}
 
-	/* And evaluate the conditional expression */
 	res = CondEvalExpression(p, plain, evalBare, negate, true, false);
 	if (res == CR_ERROR) {
 		/* Syntax error, error message already output. */

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.284 src/usr.bin/make/dir.c:1.285
--- src/usr.bin/make/dir.c:1.284	Sun Dec 17 08:53:54 2023
+++ src/usr.bin/make/dir.c	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.284 2023/12/17 08:53:54 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.285 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -132,7 +132,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.284 2023/12/17 08:53:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.285 2023/12/19 19:33:39 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -463,9 +463,7 @@ Dir_Init(void)
 	CachedDir_Assign(&dotLast, CachedDir_New(".DOTLAST"));
 }
 
-/*
- * Called by Dir_InitDir and whenever .CURDIR is assigned to.
- */
+/* Called by Dir_InitDir and whenever .CURDIR is assigned to. */
 void
 Dir_InitCur(const char *newCurdir)
 {
@@ -676,10 +674,7 @@ DirMatchFiles(const char *pattern, Cache
 	}
 }
 
-/*
- * Find the next closing brace in the string, taking nested braces into
- * account.
- */
+/* Find the next closing brace in 'p', taking nested braces into account. */
 static const char *
 closing_brace(const char *p)
 {
@@ -767,7 +762,7 @@ DirExpandCurly(const char *word, const c
 	const char *prefix, *middle, *piece, *middle_end, *suffix;
 	size_t prefix_len, suffix_len;
 
-	/* Split the word into prefix '{' middle '}' suffix. */
+	/* Split the word into prefix, '{', middle, '}' and suffix. */
 
 	middle = brace + 1;
 	middle_end = closing_brace(middle);
@@ -898,9 +893,7 @@ SearchPath_Expand(SearchPath *path, cons
 
 	slash = strchr(pattern, '/');
 	if (slash == NULL) {
-		/* First the files in dot. */
 		DirMatchFiles(pattern, dot, expansions);
-		/* Then the files in every other directory on the path. */
 		DirExpandPath(pattern, path, expansions);
 		goto done;
 	}

Index: src/usr.bin/make/hash.c
diff -u src/usr.bin/make/hash.c:1.73 src/usr.bin/make/hash.c:1.74
--- src/usr.bin/make/hash.c:1.73	Sun Dec 17 08:53:55 2023
+++ src/usr.bin/make/hash.c	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.73 2023/12/17 08:53:55 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.74 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -69,12 +69,12 @@
  * SUCH DAMAGE.
  */
 
-/* Hash tables with string keys. */
+/* Hash tables with string keys and pointer values. */
 
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.73 2023/12/17 08:53:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.74 2023/12/19 19:33:39 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -207,7 +207,7 @@ HashTable_FindValueBySubstringHash(HashT
 
 /*
  * Make the hash table larger. Any bucket numbers from the old table become
- * invalid; the hash codes stay valid though.
+ * invalid; the hash values stay valid though.
  */
 static void
 HashTable_Enlarge(HashTable *t)

Index: src/usr.bin/make/hash.h
diff -u src/usr.bin/make/hash.h:1.47 src/usr.bin/make/hash.h:1.48
--- src/usr.bin/make/hash.h:1.47	Sun Dec 17 08:53:55 2023
+++ src/usr.bin/make/hash.h	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.h,v 1.47 2023/12/17 08:53:55 rillig Exp $	*/
+/*	$NetBSD: hash.h,v 1.48 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -72,7 +72,7 @@
  *	from: @(#)hash.h	8.1 (Berkeley) 6/6/93
  */
 
-/* Hash tables with strings as keys and arbitrary pointers as values. */
+/* Hash tables with string keys and pointer values. */
 
 #ifndef MAKE_HASH_H
 #define MAKE_HASH_H
@@ -88,12 +88,11 @@ typedef struct HashEntry {
 
 /* The hash table containing the entries. */
 typedef struct HashTable {
-	HashEntry **buckets;	/* Pointers to HashEntry, one for each bucket
-				 * in the table. */
+	HashEntry **buckets;
 	unsigned int bucketsSize;
-	unsigned int numEntries; /* Number of entries in the table. */
+	unsigned int numEntries;
 	unsigned int bucketsMask; /* Used to select the bucket for a hash. */
-	unsigned int maxchain;	/* max length of chain detected */
+	unsigned int maxchain;	/* Maximum length of chain seen. */
 } HashTable;
 
 /* State of an iteration over all entries in a table. */

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.460 src/usr.bin/make/job.c:1.461
--- src/usr.bin/make/job.c:1.460	Sun Dec 17 08:53:55 2023
+++ src/usr.bin/make/job.c	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.460 2023/12/17 08:53:55 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.461 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,12 +70,11 @@
  */
 
 /*
- * job.c --
- *	handle the creation etc. of our child processes.
+ * Create child processes and collect their output.
  *
  * Interface:
  *	Job_Init	Called to initialize this module. In addition,
- *			the .BEGIN target is made including all of its
+ *			the .BEGIN target is made, including all of its
  *			dependencies before this function returns.
  *			Hence, the makefiles must have been parsed
  *			before this function is called.
@@ -142,7 +141,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.460 2023/12/17 08:53:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.461 2023/12/19 19:33:39 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -245,9 +244,7 @@ typedef struct ShellWriter {
 
 } ShellWriter;
 
-/*
- * error handling variables
- */
+/* error handling variables */
 static int job_errors = 0;	/* number of errors reported */
 static enum {			/* Why is the make aborting? */
 	ABORT_NONE,
@@ -257,9 +254,7 @@ static enum {			/* Why is the make abort
 } aborting = ABORT_NONE;
 #define JOB_TOKENS "+EI+"	/* Token to requeue for each abort state */
 
-/*
- * this tracks the number of tokens currently "out" to build jobs.
- */
+/* Tracks the number of tokens currently "out" to build jobs. */
 int jobTokensRunning = 0;
 
 typedef enum JobStartResult {
@@ -288,15 +283,15 @@ typedef enum JobStartResult {
 #define DEFSHELL_INDEX_SH     1
 #define DEFSHELL_INDEX_KSH    2
 #define DEFSHELL_INDEX_CSH    3
-#else /* !DEFSHELL_CUSTOM */
+#else
 #define DEFSHELL_INDEX_SH     0
 #define DEFSHELL_INDEX_KSH    1
 #define DEFSHELL_INDEX_CSH    2
-#endif /* !DEFSHELL_CUSTOM */
+#endif
 
 #ifndef DEFSHELL_INDEX
 #define DEFSHELL_INDEX 0	/* DEFSHELL_INDEX_CUSTOM or DEFSHELL_INDEX_SH */
-#endif /* !DEFSHELL_INDEX */
+#endif
 
 static Shell shells[] = {
 #ifdef DEFSHELL_CUSTOM
@@ -412,7 +407,7 @@ static char *shell_freeIt = NULL; /* All
 
 static Job *job_table;		/* The structures that describe them */
 static Job *job_table_end;	/* job_table + maxJobs */
-static unsigned int wantToken;	/* we want a token */
+static unsigned int wantToken;
 static bool lurking_children = false;
 static bool make_suspended = false; /* Whether we've seen a SIGTSTP (etc) */
 
@@ -547,7 +542,7 @@ JobCreatePipe(Job *job, int minfd)
 		Punt("Cannot create pipe: %s", strerror(errno));
 
 	for (i = 0; i < 2; i++) {
-		/* Avoid using low numbered fds */
+		/* Avoid using low-numbered fds */
 		fd = fcntl(pipe_fds[i], F_DUPFD, minfd);
 		if (fd != -1) {
 			close(pipe_fds[i]);
@@ -558,7 +553,6 @@ JobCreatePipe(Job *job, int minfd)
 	job->inPipe = pipe_fds[0];
 	job->outPipe = pipe_fds[1];
 
-	/* Set close-on-exec flag for both */
 	if (fcntl(job->inPipe, F_SETFD, FD_CLOEXEC) == -1)
 		Punt("Cannot set close-on-exec: %s", strerror(errno));
 	if (fcntl(job->outPipe, F_SETFD, FD_CLOEXEC) == -1)
@@ -681,10 +675,10 @@ JobPassSig_suspend(int signo)
 	/*
 	 * We've been continued.
 	 *
-	 * A whole host of signals continue to happen!
+	 * A whole host of signals is going to happen!
 	 * SIGCHLD for any processes that actually suspended themselves.
-	 * SIGCHLD for any processes that exited while we were alseep.
-	 * The SIGCONT that actually caused us to wakeup.
+	 * SIGCHLD for any processes that exited while we were asleep.
+	 * The SIGCONT that actually caused us to wake up.
 	 *
 	 * Since we defer passing the SIGCONT on to our children until
 	 * the main processing loop, we can be sure that all the SIGCHLD
@@ -733,7 +727,7 @@ ParseCommandFlags(char **pp, CommandFlag
 		else if (*p == '+')
 			out_cmdFlags->always = true;
 		else if (!ch_isspace(*p))
-			/* Ignore whitespace for compatibility with gnu make */
+			/* Ignore whitespace for compatibility with GNU make */
 			break;
 		p++;
 	}
@@ -1418,7 +1412,7 @@ JobExec(Job *job, char **argv)
 	}
 
 	/*
-	 * Some jobs produce no output and it's disconcerting to have
+	 * Some jobs produce no output, and it's disconcerting to have
 	 * no feedback of their running (since they produce no output, the
 	 * banner with their name in it never appears). This is an attempt to
 	 * provide that feedback, even if nothing follows it.
@@ -1470,9 +1464,7 @@ JobExec(Job *job, char **argv)
 			execDie("lseek to 0", "stdin");
 
 		if (job->node->type & (OP_MAKE | OP_SUBMAKE)) {
-			/*
-			 * Pass job token pipe to submakes.
-			 */
+			/* Pass job token pipe to submakes. */
 			if (fcntl(tokenWaitJob.inPipe, F_SETFD, 0) == -1)
 				execDie("clear close-on-exec",
 				    "tokenWaitJob.inPipe");
@@ -2263,9 +2255,7 @@ Job_Init(void)
 	watchfd(&childExitJob);
 
 	sigemptyset(&caught_signals);
-	/*
-	 * Install a SIGCHLD handler.
-	 */
+	/* Install a SIGCHLD handler. */
 	(void)bmake_signal(SIGCHLD, JobChildSig);
 	sigaddset(&caught_signals, SIGCHLD);
 
@@ -2396,9 +2386,7 @@ Job_ParseShell(char *line)
 
 	memset(&newShell, 0, sizeof newShell);
 
-	/*
-	 * Parse the specification by keyword
-	 */
+	/* Parse the specification by keyword. */
 	wordsList = Str_Words(line, true);
 	words = wordsList.words;
 	argc = wordsList.len;
@@ -2752,9 +2740,7 @@ clearfd(Job *job)
 		fdsLen--;
 	}
 #endif
-	/*
-	 * Move last job in table into hole made by dead job.
-	 */
+	/* Move last job in table into hole made by dead job. */
 	if (fdsLen != i) {
 		fds[i] = fds[fdsLen];
 		jobByFdIndex[i] = jobByFdIndex[fdsLen];

Index: src/usr.bin/make/job.h
diff -u src/usr.bin/make/job.h:1.77 src/usr.bin/make/job.h:1.78
--- src/usr.bin/make/job.h:1.77	Wed Dec 15 12:58:01 2021
+++ src/usr.bin/make/job.h	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.h,v 1.77 2021/12/15 12:58:01 rillig Exp $	*/
+/*	$NetBSD: job.h,v 1.78 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -73,9 +73,7 @@
  *	from: @(#)job.h	8.1 (Berkeley) 6/6/93
  */
 
-/*
- * Running of jobs in parallel mode.
- */
+/* Run jobs in parallel mode. */
 
 #ifndef MAKE_JOB_H
 #define MAKE_JOB_H

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.711 src/usr.bin/make/parse.c:1.712
--- src/usr.bin/make/parse.c:1.711	Sun Dec 17 08:53:55 2023
+++ src/usr.bin/make/parse.c	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.711 2023/12/17 08:53:55 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.712 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.711 2023/12/17 08:53:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.712 2023/12/19 19:33:39 rillig Exp $");
 
 /* Detects a multiple-inclusion guard in a makefile. */
 typedef enum {
@@ -426,8 +426,8 @@ IsEscaped(const char *line, const char *
 }
 
 /*
- * Add the filename and lineno to the GNode so that we remember where its
- * last command was added or where it was mentioned in a .depend file.
+ * Remember the location (filename and lineno) where the last command was
+ * added or where the node was mentioned in a .depend file.
  */
 static void
 RememberLocation(GNode *gn)
@@ -1732,10 +1732,7 @@ Parse_IsVar(const char *p, VarAssign *ou
 	nameStart = p;
 	firstSpace = NULL;
 
-	/*
-	 * Scan for one of the assignment operators outside a variable
-	 * expansion.
-	 */
+	/* Scan for one of the assignment operators outside an expression. */
 	while (*p != '\0') {
 		char ch = *p++;
 		if (ch == '(' || ch == '{') {

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.371 src/usr.bin/make/suff.c:1.372
--- src/usr.bin/make/suff.c:1.371	Sun Dec 17 08:53:55 2023
+++ src/usr.bin/make/suff.c	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.371 2023/12/17 08:53:55 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.372 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -115,7 +115,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.371 2023/12/17 08:53:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.372 2023/12/19 19:33:39 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -1247,9 +1247,7 @@ ExpandWildcards(GNodeListNode *cln, GNod
 	if (!Dir_HasWildcards(cgn->name))
 		return;
 
-	/*
-	 * Expand the word along the chosen path
-	 */
+	/* Expand the word along the chosen path. */
 	Lst_Init(&expansions);
 	SearchPath_Expand(Suff_FindPath(cgn), cgn->name, &expansions);
 
@@ -1274,8 +1272,8 @@ ExpandWildcards(GNodeListNode *cln, GNod
 	DEBUG0(SUFF, "\n");
 
 	/*
-	 * Now the source is expanded, remove it from the list of children to
-	 * keep it from being processed.
+	 * Now that the source is expanded, remove it from the list of
+	 * children, to keep it from being processed.
 	 */
 	pgn->unmade--;
 	Lst_Remove(&pgn->children, cln);
@@ -1401,21 +1399,14 @@ ExpandChildren(GNodeListNode *cln, GNode
 			ExpandChildrenRegular(expanded, pgn, &members);
 		}
 
-		/*
-		 * Add all elements of the members list to the parent node.
-		 */
+		/* Add all members to the parent node. */
 		while (!Lst_IsEmpty(&members)) {
 			GNode *gn = Lst_Dequeue(&members);
 
 			DEBUG1(SUFF, "%s...", gn->name);
-			/*
-			 * Add gn to the parents child list before the
-			 * original child.
-			 */
 			Lst_InsertBefore(&pgn->children, cln, gn);
 			Lst_Append(&gn->parents, pgn);
 			pgn->unmade++;
-			/* Expand wildcards on new node */
 			ExpandWildcards(cln->prev, pgn);
 		}
 		Lst_Done(&members);
@@ -1426,8 +1417,8 @@ ExpandChildren(GNodeListNode *cln, GNode
 	DEBUG0(SUFF, "\n");
 
 	/*
-	 * Now the source is expanded, remove it from the list of children to
-	 * keep it from being processed.
+	 * The source is expanded now, so remove it from the list of children,
+	 * to keep it from being processed.
 	 */
 	pgn->unmade--;
 	Lst_Remove(&pgn->children, cln);
@@ -1446,16 +1437,10 @@ ExpandAllChildren(GNode *gn)
 }
 
 /*
- * Find a path along which to expand the node.
- *
- * If the node has a known suffix, use that path.
- * If it has no known suffix, use the default system search path.
+ * Find a path along which to search or expand the node.
  *
- * Input:
- *	gn		Node being examined
- *
- * Results:
- *	The appropriate path to search for the GNode.
+ * If the node has a known suffix, use that path,
+ * otherwise use the default system search path.
  */
 SearchPath *
 Suff_FindPath(GNode *gn)
@@ -1529,7 +1514,7 @@ ApplyTransform(GNode *tgn, GNode *sgn, S
 	/* Apply the rule. */
 	Make_HandleUse(gn, tgn);
 
-	/* Deal with wildcards and variables in any acquired sources. */
+	/* Deal with wildcards and expressions in any acquired sources. */
 	ln = ln != NULL ? ln->next : NULL;
 	while (ln != NULL) {
 		GNodeListNode *nln = ln->next;
@@ -1565,7 +1550,6 @@ ExpandMember(GNode *gn, const char *eoar
 			break;
 
 	if (ln != NULL) {
-		/* Got one -- apply it */
 		Suffix *suff = ln->datum;
 		if (!ApplyTransform(gn, mem, suff, memSuff)) {
 			DEBUG2(SUFF, "\tNo transformation from %s -> %s\n",
@@ -1579,9 +1563,6 @@ static void FindDeps(GNode *, CandidateS
 /*
  * Locate dependencies for an OP_ARCHV node.
  *
- * Input:
- *	gn		Node for which to locate dependencies
- *
  * Side Effects:
  *	Same as Suff_FindDeps
  */
@@ -1595,7 +1576,7 @@ FindDepsArchive(GNode *gn, CandidateSear
 	const char *name;	/* Start of member's name */
 
 	/*
-	 * The node is an archive(member) pair. so we must find a
+	 * The node is an 'archive(member)' pair, so we must find a
 	 * suffix for both of them.
 	 */
 	eoarch = strchr(gn->name, '(');
@@ -2068,9 +2049,6 @@ FindDeps(GNode *gn, CandidateSearcher *c
  *
  * Need to handle the changing of the null suffix gracefully so the old
  * transformation rules don't just go away.
- *
- * Input:
- *	name		Name of null suffix
  */
 void
 Suff_SetNull(const char *name)

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1083 src/usr.bin/make/var.c:1.1084
--- src/usr.bin/make/var.c:1.1083	Sun Dec 17 08:53:55 2023
+++ src/usr.bin/make/var.c	Tue Dec 19 19:33:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1083 2023/12/17 08:53:55 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1084 2023/12/19 19:33:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1083 2023/12/17 08:53:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1084 2023/12/19 19:33:39 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -222,9 +222,6 @@ typedef struct Var {
 /*
  * Exporting variables is expensive and may leak memory, so skip it if we
  * can.
- *
- * To avoid this, it might be worth encapsulating the environment variables
- * in a separate data structure called EnvVars.
  */
 typedef enum VarExportedMode {
 	VAR_EXPORTED_NONE,
@@ -3251,7 +3248,6 @@ ApplyModifier_Words(const char **pp, Mod
 			size_t ac = words.len;
 			SubstringWords_Free(words);
 
-			/* 3 digits + '\0' is usually enough */
 			Buf_InitSize(&buf, 4);
 			Buf_AddInt(&buf, (int)ac);
 			Expr_SetValueOwn(expr, Buf_DoneData(&buf));
@@ -4583,7 +4579,7 @@ Var_Parse(const char **pp, GNode *scope,
 	 * variable.  This means that as long as the value of the expression
 	 * stays the same, the value of the variable must not change, and the
 	 * variable must not be deleted.  Using the ':@' modifier, it is
-	 * possible (since var.c 1.212 from 2017/02/01) to delete the variable
+	 * possible (since var.c 1.212 from 2017-02-01) to delete the variable
 	 * while its value is still being used:
 	 *
 	 *	VAR=	value

Index: src/usr.bin/make/unit-tests/cond-func-empty.mk
diff -u src/usr.bin/make/unit-tests/cond-func-empty.mk:1.23 src/usr.bin/make/unit-tests/cond-func-empty.mk:1.24
--- src/usr.bin/make/unit-tests/cond-func-empty.mk:1.23	Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/cond-func-empty.mk	Tue Dec 19 19:33:40 2023
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func-empty.mk,v 1.23 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: cond-func-empty.mk,v 1.24 2023/12/19 19:33:40 rillig Exp $
 #
 # Tests for the empty() function in .if conditions, which tests an
 # expression for emptiness.
@@ -194,7 +194,7 @@ ${:U WORD }=	variable name with spaces
 # wrong variable name should have been discarded quickly after parsing it, to
 # prevent it from doing any harm.
 #
-# The expression was expanded though, and this was wrong.  The
+# The expression was expanded, and this was wrong.  The
 # expansion was done without VARE_WANTRES (called VARF_WANTRES back then)
 # though.  This had the effect that the ${:U1} from the value of VARNAME
 # expanded to an empty string.  This in turn created the seemingly recursive

Index: src/usr.bin/make/unit-tests/dep-var.mk
diff -u src/usr.bin/make/unit-tests/dep-var.mk:1.10 src/usr.bin/make/unit-tests/dep-var.mk:1.11
--- src/usr.bin/make/unit-tests/dep-var.mk:1.10	Sun Nov 19 22:32:44 2023
+++ src/usr.bin/make/unit-tests/dep-var.mk	Tue Dec 19 19:33:40 2023
@@ -1,4 +1,4 @@
-# $NetBSD: dep-var.mk,v 1.10 2023/11/19 22:32:44 rillig Exp $
+# $NetBSD: dep-var.mk,v 1.11 2023/12/19 19:33:40 rillig Exp $
 #
 # Tests for variable references in dependency declarations.
 #
@@ -13,7 +13,7 @@
 # to an empty string.
 all: ${UNDEF1}
 
-# Using a double dollar in order to circumvent immediate variable expansion
+# Using a double dollar in order to circumvent immediate expression expansion
 # feels like unintended behavior.  At least the manual page says nothing at
 # all about defined or undefined variables in dependency lines.
 #
Index: src/usr.bin/make/unit-tests/dir.mk
diff -u src/usr.bin/make/unit-tests/dir.mk:1.10 src/usr.bin/make/unit-tests/dir.mk:1.11
--- src/usr.bin/make/unit-tests/dir.mk:1.10	Tue Jan 24 00:24:02 2023
+++ src/usr.bin/make/unit-tests/dir.mk	Tue Dec 19 19:33:40 2023
@@ -1,4 +1,4 @@
-# $NetBSD: dir.mk,v 1.10 2023/01/24 00:24:02 sjg Exp $
+# $NetBSD: dir.mk,v 1.11 2023/12/19 19:33:40 rillig Exp $
 #
 # Tests for dir.c.
 
@@ -67,7 +67,7 @@ fetch fetch-post extract extract-post:
 
 # The expansions may have duplicates.
 # When the source of the dependency line is expanded later, each of the
-# expanded words will be the same.
+# expanded words resolves to the same node.
 all: dup-{1,1,1,1,1,1,1}
 
 dup-1:

Index: src/usr.bin/make/unit-tests/directive-for-errors.mk
diff -u src/usr.bin/make/unit-tests/directive-for-errors.mk:1.8 src/usr.bin/make/unit-tests/directive-for-errors.mk:1.9
--- src/usr.bin/make/unit-tests/directive-for-errors.mk:1.8	Sun Dec 17 09:44:00 2023
+++ src/usr.bin/make/unit-tests/directive-for-errors.mk	Tue Dec 19 19:33:40 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-errors.mk,v 1.8 2023/12/17 09:44:00 rillig Exp $
+# $NetBSD: directive-for-errors.mk,v 1.9 2023/12/19 19:33:40 rillig Exp $
 #
 # Tests for error handling in .for loops.
 
@@ -67,7 +67,7 @@ ${:U\\}=	backslash	# see whether the "va
 
 
 # The list of values after the 'in' may be empty, no matter if this emptiness
-# comes from an empty expansion or even from a syntactically empty line.
+# comes from an expanded expression or from a syntactically empty line.
 .for i in
 .  info Would be reached if there were items to loop over.
 .endfor

Index: src/usr.bin/make/unit-tests/opt-debug-loud.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-loud.mk:1.4 src/usr.bin/make/unit-tests/opt-debug-loud.mk:1.5
--- src/usr.bin/make/unit-tests/opt-debug-loud.mk:1.4	Mon Oct  5 19:27:48 2020
+++ src/usr.bin/make/unit-tests/opt-debug-loud.mk	Tue Dec 19 19:33:40 2023
@@ -1,4 +1,4 @@
-# $NetBSD: opt-debug-loud.mk,v 1.4 2020/10/05 19:27:48 rillig Exp $
+# $NetBSD: opt-debug-loud.mk,v 1.5 2023/12/19 19:33:40 rillig Exp $
 #
 # Tests for the -dl command line option, which prints the commands before
 # running them, ignoring the command line option for silent mode (-s) as
@@ -8,8 +8,8 @@
 .MAKEFLAGS: -dl -s
 .SILENT:
 
-# The -dl command line option does not affect commands that are run during
-# variable expansion, such as :!cmd! or :sh.
+# The -dl command line option does not affect commands that are run when
+# evaluating expressions and their modifiers, such as :!cmd! or :sh.
 .if ${:!echo word!} != "word"
 .  error
 .endif

Reply via email to