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: reduce indentation of Cmd_Exec



details:   https://anonhg.NetBSD.org/src/rev/d6052627b907
branches:  trunk
changeset: 1029222:d6052627b907
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 27 23:19:41 2021 +0000

description:
make: reduce indentation of Cmd_Exec

No functional change.

diffstat:

 usr.bin/make/main.c |  74 +++++++++++++++++++++++++---------------------------
 1 files changed, 35 insertions(+), 39 deletions(-)

diffs (111 lines):

diff -r cf83862bf44b -r d6052627b907 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Mon Dec 27 23:11:55 2021 +0000
+++ b/usr.bin/make/main.c       Mon Dec 27 23:19:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.557 2021/12/27 23:11:55 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.558 2021/12/27 23:19:41 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.557 2021/12/27 23:11:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.558 2021/12/27 23:19:41 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -1748,7 +1748,7 @@
 
        if (pipe(pipefds) == -1) {
                *errfmt = "Couldn't create pipe for \"%s\"";
-               goto bad;
+               return bmake_strdup("");
        }
 
        Var_ReexportVars();
@@ -1765,51 +1765,47 @@
 
        case -1:
                *errfmt = "Couldn't exec \"%s\"";
-               goto bad;
+               return bmake_strdup("");
+       }
 
-       default:
-               (void)close(pipefds[1]); /* No need for the writing half */
+       (void)close(pipefds[1]);        /* No need for the writing half */
 
-               savederr = 0;
-               Buf_Init(&buf);
+       savederr = 0;
+       Buf_Init(&buf);
 
-               do {
-                       char result[BUFSIZ];
-                       bytes_read = read(pipefds[0], result, sizeof result);
-                       if (bytes_read > 0)
-                               Buf_AddBytes(&buf, result, (size_t)bytes_read);
-               } while (bytes_read > 0 ||
-                        (bytes_read == -1 && errno == EINTR));
-               if (bytes_read == -1)
-                       savederr = errno;
+       do {
+               char result[BUFSIZ];
+               bytes_read = read(pipefds[0], result, sizeof result);
+               if (bytes_read > 0)
+                       Buf_AddBytes(&buf, result, (size_t)bytes_read);
+       } while (bytes_read > 0 || (bytes_read == -1 && errno == EINTR));
+       if (bytes_read == -1)
+               savederr = errno;
 
-               (void)close(pipefds[0]); /* Close the input side of the pipe. */
-
-               while ((pid = waitpid(cpid, &status, 0)) != cpid && pid >= 0)
-                       JobReapChild(pid, status, false);
+       (void)close(pipefds[0]); /* Close the input side of the pipe. */
 
-               res_len = buf.len;
-               res = Buf_DoneData(&buf);
+       while ((pid = waitpid(cpid, &status, 0)) != cpid && pid >= 0)
+               JobReapChild(pid, status, false);
 
-               if (savederr != 0)
-                       *errfmt = "Couldn't read shell's output for \"%s\"";
+       res_len = buf.len;
+       res = Buf_DoneData(&buf);
 
-               if (WIFSIGNALED(status))
-                       *errfmt = "\"%s\" exited on a signal";
-               else if (WEXITSTATUS(status) != 0)
-                       *errfmt = "\"%s\" returned non-zero status";
+       if (savederr != 0)
+               *errfmt = "Couldn't read shell's output for \"%s\"";
 
-               /* Convert newlines to spaces, strip the final newline. */
-               if (res_len > 0 && res[res_len - 1] == '\n')
-                       res[res_len - 1] = '\0';
-               for (cp = res; *cp != '\0'; cp++)
-                       if (*cp == '\n')
-                               *cp = ' ';
-               break;
-       }
+       if (WIFSIGNALED(status))
+               *errfmt = "\"%s\" exited on a signal";
+       else if (WEXITSTATUS(status) != 0)
+               *errfmt = "\"%s\" returned non-zero status";
+
+       /* Convert newlines to spaces, strip the final newline. */
+       if (res_len > 0 && res[res_len - 1] == '\n')
+               res[res_len - 1] = '\0';
+       for (cp = res; *cp != '\0'; cp++)
+               if (*cp == '\n')
+                       *cp = ' ';
+
        return res;
-bad:
-       return bmake_strdup("");
 }
 
 /*



Home | Main Index | Thread Index | Old Index