Module Name: src Committed By: rillig Date: Sat Nov 7 14:27:16 UTC 2020
Modified Files: src/usr.bin/make: compat.c Log Message: make(1): clean up Compat_RunCommand To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/usr.bin/make/compat.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.177 src/usr.bin/make/compat.c:1.178 --- src/usr.bin/make/compat.c:1.177 Sat Nov 7 14:18:25 2020 +++ src/usr.bin/make/compat.c Sat Nov 7 14:27:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.177 2020/11/07 14:18:25 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.178 2020/11/07 14:27:16 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.177 2020/11/07 14:18:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.178 2020/11/07 14:27:16 rillig Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -278,9 +278,9 @@ Compat_RunCommand(const char *cmdp, GNod * If we're not supposed to execute any commands, this is as far as * we go... */ - if (!doIt && !GNode_ShouldExecute(gn)) { + if (!doIt && !GNode_ShouldExecute(gn)) return 0; - } + DEBUG1(JOB, "Execute: '%s'\n", cmd); if (useShell) { @@ -289,20 +289,13 @@ Compat_RunCommand(const char *cmdp, GNod * because the command contains a "meta" character. */ static const char *shargv[5]; - int shargc; - shargc = 0; + /* The following work for any of the builtin shell specs. */ + int shargc = 0; shargv[shargc++] = shellPath; - /* - * The following work for any of the builtin shell specs. - */ - if (errCheck && shellErrFlag) { + if (errCheck && shellErrFlag) shargv[shargc++] = shellErrFlag; - } - if (DEBUG(SHELL)) - shargv[shargc++] = "-xc"; - else - shargv[shargc++] = "-c"; + shargv[shargc++] = DEBUG(SHELL) ? "-xc" : "-c"; shargv[shargc++] = cmd; shargv[shargc] = NULL; av = shargv; @@ -381,17 +374,19 @@ Compat_RunCommand(const char *cmdp, GNod #endif if (status != 0) { if (DEBUG(ERROR)) { - const char *cp; + const char *p = cmd; debug_printf("\n*** Failed target: %s\n*** Failed command: ", gn->name); - for (cp = cmd; *cp; ) { - if (ch_isspace(*cp)) { + + /* Replace runs of whitespace with a single space, to reduce + * the amount of whitespace for multi-line command lines. */ + while (*p != '\0') { + if (ch_isspace(*p)) { debug_printf(" "); - while (ch_isspace(*cp)) - cp++; + cpp_skip_whitespace(&p); } else { - debug_printf("%c", *cp); - cp++; + debug_printf("%c", *p); + p++; } } debug_printf("\n");