Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): eliminate global variable numCommands
details: https://anonhg.NetBSD.org/src/rev/63e135657789
branches: trunk
changeset: 978996:63e135657789
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Dec 10 23:12:59 2020 +0000
description:
make(1): eliminate global variable numCommands
It had only been used in a very small scope. The elimination of
Lst_ForEach made it easy to turn this global variable into a local
variable.
diffstat:
usr.bin/make/job.c | 28 +++++++++++-----------------
1 files changed, 11 insertions(+), 17 deletions(-)
diffs (83 lines):
diff -r 9239a524e868 -r 63e135657789 usr.bin/make/job.c
--- a/usr.bin/make/job.c Thu Dec 10 23:03:00 2020 +0000
+++ b/usr.bin/make/job.c Thu Dec 10 23:12:59 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.361 2020/12/10 23:03:00 rillig Exp $ */
+/* $NetBSD: job.c,v 1.362 2020/12/10 23:12:59 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.361 2020/12/10 23:03:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.362 2020/12/10 23:12:59 rillig Exp $");
/*
* A shell defines how the commands are run. All commands for a target are
@@ -248,10 +248,6 @@
*/
int jobTokensRunning = 0;
-/* The number of commands actually printed to the shell commands file for
- * the current job. Should this number be 0, no shell will be executed. */
-static int numCommands;
-
typedef enum JobStartResult {
JOB_RUNNING, /* Job is running */
JOB_ERROR, /* Error in starting the job */
@@ -853,8 +849,6 @@
run = GNode_ShouldExecute(job->node);
- numCommands++;
-
Var_Subst(cmd, job->node, VARE_WANTRES, &cmd);
/* TODO: handle errors */
cmdStart = cmd;
@@ -952,11 +946,14 @@
*
* The special command "..." stops printing and saves the remaining commands
* to be executed later.
+ *
+ * Return whether at least one command was written to the shell file.
*/
-static void
+static Boolean
JobPrintCommands(Job *job)
{
StringListNode *ln;
+ Boolean seen = FALSE;
for (ln = job->node->commands.first; ln != NULL; ln = ln->next) {
const char *cmd = ln->datum;
@@ -968,7 +965,10 @@
}
JobPrintCommand(job, ln->datum);
+ seen = TRUE;
}
+
+ return seen;
}
/* Save the delayed commands, to be executed when everything else is done. */
@@ -1544,15 +1544,9 @@
job->echo = FALSE;
}
#endif
+
/* We can do all the commands at once. hooray for sanity */
- numCommands = 0;
- JobPrintCommands(job);
-
- /*
- * If we didn't print out any commands to the shell script,
- * there's no point in executing the shell.
- */
- if (numCommands == 0)
+ if (!JobPrintCommands(job))
*out_run = FALSE;
free(tfile);
Home |
Main Index |
Thread Index |
Old Index