Module Name:    src
Committed By:   rillig
Date:           Mon Dec 27 18:26:22 UTC 2021

Modified Files:
        src/usr.bin/make: compat.c job.c main.c make.c make.h parse.c

Log Message:
make: remove unnecessary words from command line options

Several years ago, the command line options were individual global
variables.  The global variable could therefore not be named 'silent'
since that would have conflicted with local variables of the same name.
After moving the global variable to the namespace 'struct CmdOpts',
there is no conflict anymore.

There doesn't seem to be any risk of naming collisions for the names
'touch' and 'query'.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/usr.bin/make/compat.c
cvs rdiff -u -r1.444 -r1.445 src/usr.bin/make/job.c
cvs rdiff -u -r1.548 -r1.549 src/usr.bin/make/main.c
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/make/make.c
cvs rdiff -u -r1.278 -r1.279 src/usr.bin/make/make.h
cvs rdiff -u -r1.583 -r1.584 src/usr.bin/make/parse.c

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/compat.c
diff -u src/usr.bin/make/compat.c:1.234 src/usr.bin/make/compat.c:1.235
--- src/usr.bin/make/compat.c:1.234	Mon Dec 27 17:18:57 2021
+++ src/usr.bin/make/compat.c	Mon Dec 27 18:26:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.234 2021/12/27 17:18:57 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.235 2021/12/27 18:26:22 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.234 2021/12/27 17:18:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.235 2021/12/27 18:26:22 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -531,7 +531,7 @@ MakeUnmade(GNode *gn, GNode *pgn)
 	 * to tell him/her "yes".
 	 */
 	DEBUG0(MAKE, "out-of-date.\n");
-	if (opts.queryFlag)
+	if (opts.query)
 		exit(1);
 
 	/*
@@ -546,7 +546,7 @@ MakeUnmade(GNode *gn, GNode *pgn)
 	 */
 	if (opts.ignoreErrors)
 		gn->type |= OP_IGNORE;
-	if (opts.beSilent)
+	if (opts.silent)
 		gn->type |= OP_SILENT;
 
 	if (Job_CheckCommands(gn, Fatal)) {
@@ -554,7 +554,7 @@ MakeUnmade(GNode *gn, GNode *pgn)
 		 * Our commands are ok, but we still have to worry about
 		 * the -t flag.
 		 */
-		if (!opts.touchFlag || (gn->type & OP_MAKE)) {
+		if (!opts.touch || (gn->type & OP_MAKE)) {
 			curTarg = gn;
 #ifdef USE_META
 			if (useMeta && GNode_ShouldExecute(gn)) {
@@ -721,7 +721,7 @@ Compat_Run(GNodeList *targs)
 	 */
 	(void)Targ_GetEndNode();
 
-	if (!opts.queryFlag)
+	if (!opts.query)
 		MakeBeginNode();
 
 	/*

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.444 src/usr.bin/make/job.c:1.445
--- src/usr.bin/make/job.c:1.444	Mon Dec 27 17:18:57 2021
+++ src/usr.bin/make/job.c	Mon Dec 27 18:26:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.444 2021/12/27 17:18:57 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.445 2021/12/27 18:26:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.444 2021/12/27 17:18:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.445 2021/12/27 18:26:22 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -1668,7 +1668,7 @@ JobStart(GNode *gn, bool special)
 
 	job->special = special || gn->type & OP_SPECIAL;
 	job->ignerr = opts.ignoreErrors || gn->type & OP_IGNORE;
-	job->echo = !(opts.beSilent || gn->type & OP_SILENT);
+	job->echo = !(opts.silent || gn->type & OP_SILENT);
 
 	/*
 	 * Check the commands now so any attributes from .DEFAULT have a
@@ -1691,7 +1691,7 @@ JobStart(GNode *gn, bool special)
 			DieHorribly();
 		}
 	} else if (((gn->type & OP_MAKE) && !opts.noRecursiveExecute) ||
-	    (!opts.noExecute && !opts.touchFlag)) {
+	    (!opts.noExecute && !opts.touch)) {
 		/*
 		 * The above condition looks very similar to
 		 * GNode_ShouldExecute but is subtly different.  It prevents
@@ -1924,7 +1924,7 @@ again:
 			 * we add one of our own free will.
 			 */
 			if (*cp != '\0') {
-				if (!opts.beSilent)
+				if (!opts.silent)
 					SwitchOutputTo(job->node);
 #ifdef USE_META
 				if (useMeta) {
@@ -2608,7 +2608,7 @@ JobInterrupt(bool runINTERRUPT, int sign
 
 	JobSigUnlock(&mask);
 
-	if (runINTERRUPT && !opts.touchFlag) {
+	if (runINTERRUPT && !opts.touch) {
 		interrupt = Targ_FindNode(".INTERRUPT");
 		if (interrupt != NULL) {
 			opts.ignoreErrors = false;

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.548 src/usr.bin/make/main.c:1.549
--- src/usr.bin/make/main.c:1.548	Mon Dec 27 17:18:57 2021
+++ src/usr.bin/make/main.c	Mon Dec 27 18:26:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.548 2021/12/27 17:18:57 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.549 2021/12/27 18:26:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.548 2021/12/27 17:18:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.549 2021/12/27 18:26:22 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -546,7 +546,7 @@ MainParseArg(char c, const char *argvalu
 		Global_Append(MAKEFLAGS, "-n");
 		break;
 	case 'q':
-		opts.queryFlag = true;
+		opts.query = true;
 		/* Kind of nonsensical, wot? */
 		Global_Append(MAKEFLAGS, "-q");
 		break;
@@ -555,11 +555,11 @@ MainParseArg(char c, const char *argvalu
 		Global_Append(MAKEFLAGS, "-r");
 		break;
 	case 's':
-		opts.beSilent = true;
+		opts.silent = true;
 		Global_Append(MAKEFLAGS, "-s");
 		break;
 	case 't':
-		opts.touchFlag = true;
+		opts.touch = true;
 		Global_Append(MAKEFLAGS, "-t");
 		break;
 	case 'w':
@@ -930,7 +930,7 @@ runTargets(void)
 		 * (to prevent the .BEGIN from being executed should
 		 * it exist).
 		 */
-		if (!opts.queryFlag) {
+		if (!opts.query) {
 			Job_Init();
 			jobsRunning = true;
 		}
@@ -1129,10 +1129,10 @@ CmdOpts_Init(void)
 	opts.keepgoing = false;		/* Stop on error */
 	opts.noRecursiveExecute = false; /* Execute all .MAKE targets */
 	opts.noExecute = false;		/* Execute all commands */
-	opts.queryFlag = false;
+	opts.query = false;
 	opts.noBuiltins = false;	/* Read the built-in rules */
-	opts.beSilent = false;		/* Print commands as executed */
-	opts.touchFlag = false;
+	opts.silent = false;		/* Print commands as executed */
+	opts.touch = false;
 	opts.printVars = PVM_NONE;
 	Lst_Init(&opts.variables);
 	opts.parseWarnFatal = false;

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.249 src/usr.bin/make/make.c:1.250
--- src/usr.bin/make/make.c:1.249	Wed Dec 15 12:58:01 2021
+++ src/usr.bin/make/make.c	Mon Dec 27 18:26:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.249 2021/12/15 12:58:01 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.250 2021/12/27 18:26:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -104,7 +104,7 @@
 #include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.249 2021/12/15 12:58:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.250 2021/12/27 18:26:22 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -1073,7 +1073,7 @@ MakeStartJobs(void)
 		gn->made = BEINGMADE;
 		if (GNode_IsOODate(gn)) {
 			DEBUG0(MAKE, "out-of-date\n");
-			if (opts.queryFlag)
+			if (opts.query)
 				return true;
 			GNode_SetLocalVars(gn);
 			Job_Make(gn);
@@ -1441,7 +1441,7 @@ Make_Run(GNodeList *targs)
 		Targ_PrintGraph(1);
 	}
 
-	if (opts.queryFlag) {
+	if (opts.query) {
 		/*
 		 * We wouldn't do any work unless we could start some jobs
 		 * in the next loop... (we won't actually start any, of

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.278 src/usr.bin/make/make.h:1.279
--- src/usr.bin/make/make.h:1.278	Wed Dec 15 13:03:33 2021
+++ src/usr.bin/make/make.h	Mon Dec 27 18:26:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.278 2021/12/15 13:03:33 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.279 2021/12/27 18:26:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -718,19 +718,19 @@ typedef struct CmdOpts {
 	 * -q: if true, do not really make anything, just see if the targets
 	 * are out-of-date
 	 */
-	bool queryFlag;
+	bool query;
 
 	/* -r: raw mode, do not load the builtin rules. */
 	bool noBuiltins;
 
 	/* -s: don't echo the shell commands before executing them */
-	bool beSilent;
+	bool silent;
 
 	/*
 	 * -t: touch the targets if they are out-of-date, but don't actually
 	 * make them
 	 */
-	bool touchFlag;
+	bool touch;
 
 	/* -[Vv]: print expanded or unexpanded selected variables */
 	PrintVarsMode printVars;

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.583 src/usr.bin/make/parse.c:1.584
--- src/usr.bin/make/parse.c:1.583	Wed Dec 15 12:58:01 2021
+++ src/usr.bin/make/parse.c	Mon Dec 27 18:26:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.583 2021/12/15 12:58:01 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.584 2021/12/27 18:26:22 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.583 2021/12/15 12:58:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.584 2021/12/27 18:26:22 rillig Exp $");
 
 /* types and constants */
 
@@ -1315,7 +1315,7 @@ ParseDependencySourcesEmpty(ParseSpecial
 		opts.ignoreErrors = true;
 		break;
 	case SP_SILENT:
-		opts.beSilent = true;
+		opts.silent = true;
 		break;
 	case SP_PATH:
 		ClearPaths(paths);

Reply via email to