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): clean up JobExec, JobStart, JobDoOutput



details:   https://anonhg.NetBSD.org/src/rev/34f611ee1d0e
branches:  trunk
changeset: 957023:34f611ee1d0e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 14 17:04:01 2020 +0000

description:
make(1): clean up JobExec, JobStart, JobDoOutput

The comments about temporary files for shell output are no longer
relevant since the output is always handled via pipes.

diffstat:

 usr.bin/make/job.c |  52 +++++++++++++++++-----------------------------------
 1 files changed, 17 insertions(+), 35 deletions(-)

diffs (106 lines):

diff -r f1afc99473f7 -r 34f611ee1d0e usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat Nov 14 16:44:04 2020 +0000
+++ b/usr.bin/make/job.c        Sat Nov 14 17:04:01 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.324 2020/11/14 16:44:04 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.325 2020/11/14 17:04: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.324 2020/11/14 16:44:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.325 2020/11/14 17:04: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
@@ -1239,9 +1239,7 @@
 
 /* Execute the shell for the given job.
  *
- * A shell is executed, its output is altered and the Job structure added
- * to the job table.
- */
+ * See Job_CatchOutput for handling the output of the shell. */
 static void
 JobExec(Job *job, char **argv)
 {
@@ -1604,11 +1602,9 @@
        /*
         * Unlink and close the command file if we opened one
         */
-       if (job->cmdFILE != stdout) {
-           if (job->cmdFILE != NULL) {
-               (void)fclose(job->cmdFILE);
-               job->cmdFILE = NULL;
-           }
+       if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
+           (void)fclose(job->cmdFILE);
+           job->cmdFILE = NULL;
        }
 
        /*
@@ -1675,34 +1671,20 @@
     return cp;
 }
 
-/*-
- *-----------------------------------------------------------------------
- * JobDoOutput  --
- *     This function is called at different times depending on
- *     whether the user has specified that output is to be collected
- *     via pipes or temporary files. In the former case, we are called
- *     whenever there is something to read on the pipe. We collect more
- *     output from the given job and store it in the job's outBuf. If
- *     this makes up a line, we print it tagged by the job's identifier,
- *     as necessary.
- *     If output has been collected in a temporary file, we open the
- *     file and read it line by line, transferring it to our own
- *     output channel until the file is empty. At which point we
- *     remove the temporary file.
- *     In both cases, however, we keep our figurative eye out for the
- *     'noPrint' line for the shell from which the output came. If
- *     we recognize a line, we don't print it. If the command is not
- *     alone on the line (the character after it is not \0 or \n), we
- *     do print whatever follows it.
+/*
+ * This function is called whenever there is something to read on the pipe.
+ * We collect more output from the given job and store it in the job's
+ * outBuf. If this makes up a line, we print it tagged by the job's
+ * identifier, as necessary.
+ *
+ * In the output of the shell, the 'noPrint' lines are removed. If the
+ * command is not alone on the line (the character after it is not \0 or
+ * \n), we do print whatever follows it.
  *
  * Input:
  *     job             the job whose output needs printing
  *     finish          TRUE if this is the last time we'll be called
  *                     for this job
- *
- * Side Effects:
- *     curPos may be shifted as may the contents of outBuf.
- *-----------------------------------------------------------------------
  */
 static void
 JobDoOutput(Job *job, Boolean finish)
@@ -1717,7 +1699,7 @@
     /*
      * Read as many bytes as will fit in the buffer.
      */
-end_loop:
+again:
     gotNL = FALSE;
     fbuf = FALSE;
 
@@ -1835,7 +1817,7 @@
         * we do get an EOF, finish will be set FALSE and we'll fall
         * through and out.
         */
-       goto end_loop;
+       goto again;
     }
 }
 



Home | Main Index | Thread Index | Old Index