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): remove duplicate code for job output
details: https://anonhg.NetBSD.org/src/rev/92244af2b4de
branches: trunk
changeset: 946764:92244af2b4de
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Dec 07 22:55:01 2020 +0000
description:
make(1): remove duplicate code for job output
diffstat:
usr.bin/make/job.c | 49 ++++++++++++++++++-------------------------------
1 files changed, 18 insertions(+), 31 deletions(-)
diffs (124 lines):
diff -r 84fd33e4bd4c -r 92244af2b4de usr.bin/make/job.c
--- a/usr.bin/make/job.c Mon Dec 07 22:47:03 2020 +0000
+++ b/usr.bin/make/job.c Mon Dec 07 22:55:01 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.339 2020/12/07 22:47:03 rillig Exp $ */
+/* $NetBSD: job.c,v 1.340 2020/12/07 22:55:01 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.339 2020/12/07 22:47:03 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.340 2020/12/07 22:55:01 rillig Exp $");
/* A shell defines how the commands are run. All commands for a target are
* written into a single file, which is then given to the shell to execute
@@ -389,8 +389,6 @@
static void clearfd(Job *);
static int readyfd(Job *);
-static GNode *lastNode; /* The node for which output was most recently
- * produced. */
static char *targPrefix = NULL; /* To identify a job change in the output. */
static Job tokenWaitJob; /* token wait pseudo-job */
@@ -408,8 +406,15 @@
static void JobSigReset(void);
static void
-Message(GNode *gn)
+SwitchOutputTo(GNode *gn)
{
+ /* The node for which output was most recently produced. */
+ static GNode *lastNode = NULL;
+
+ if (gn == lastNode)
+ return;
+ lastNode = gn;
+
if (opts.maxJobs != 1 && targPrefix != NULL && targPrefix[0] != '\0')
(void)fprintf(stdout, "%s %s ---\n", targPrefix, gn->name);
}
@@ -1004,10 +1009,7 @@
DEBUG2(JOB, "Process %d [%s] exited.\n",
job->pid, job->node->name);
if (WEXITSTATUS(status) != 0) {
- if (job->node != lastNode) {
- Message(job->node);
- lastNode = job->node;
- }
+ SwitchOutputTo(job->node);
#ifdef USE_META
if (useMeta) {
meta_job_error(job, job->node, job->flags, WEXITSTATUS(status));
@@ -1027,18 +1029,12 @@
PrintOnError(job->node, NULL);
}
} else if (DEBUG(JOB)) {
- if (job->node != lastNode) {
- Message(job->node);
- lastNode = job->node;
- }
+ SwitchOutputTo(job->node);
(void)printf("*** [%s] Completed successfully\n",
job->node->name);
}
} else {
- if (job->node != lastNode) {
- Message(job->node);
- lastNode = job->node;
- }
+ SwitchOutputTo(job->node);
(void)printf("*** [%s] Signal %d\n",
job->node->name, WTERMSIG(status));
if (deleteOnError) {
@@ -1264,10 +1260,8 @@
* banner with their name in it never appears). This is an attempt to
* provide that feedback, even if nothing follows it.
*/
- if ((lastNode != job->node) && !(job->flags & JOB_SILENT)) {
- Message(job->node);
- lastNode = job->node;
- }
+ if (!(job->flags & JOB_SILENT))
+ SwitchOutputTo(job->node);
/* No interruptions until this job is on the `jobs' list */
JobSigLock(&mask);
@@ -1559,10 +1553,7 @@
* Not executing anything -- just print all the commands to stdout
* in one fell swoop. This will still set up job->tailCmds correctly.
*/
- if (lastNode != gn) {
- Message(gn);
- lastNode = gn;
- }
+ SwitchOutputTo(gn);
job->cmdFILE = stdout;
/*
* Only print the commands if they're ok, but don't die if they're
@@ -1778,10 +1769,8 @@
* our own free will.
*/
if (*cp != '\0') {
- if (!opts.beSilent && job->node != lastNode) {
- Message(job->node);
- lastNode = job->node;
- }
+ if (!opts.beSilent)
+ SwitchOutputTo(job->node);
#ifdef USE_META
if (useMeta) {
meta_job_output(job, cp, gotNL ? "\n" : "");
@@ -2080,8 +2069,6 @@
aborting = ABORT_NONE;
job_errors = 0;
- lastNode = NULL;
-
/*
* There is a non-zero chance that we already have children.
* eg after 'make -f- <<EOF'
Home |
Main Index |
Thread Index |
Old Index