Module Name:    src
Committed By:   rillig
Date:           Mon Nov 23 19:14:24 UTC 2020

Modified Files:
        src/usr.bin/make: compat.c

Log Message:
make(1): extract DebugFailedTarget from Compat_RunCommand


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 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.183 src/usr.bin/make/compat.c:1.184
--- src/usr.bin/make/compat.c:1.183	Sun Nov 15 22:31:03 2020
+++ src/usr.bin/make/compat.c	Mon Nov 23 19:14:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.183 2020/11/15 22:31:03 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.184 2020/11/23 19:14:24 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.183 2020/11/15 22:31:03 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.184 2020/11/23 19:14:24 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -159,6 +159,27 @@ CompatInterrupt(int signo)
     }
 }
 
+static void
+DebugFailedTarget(const char *cmd, GNode *gn)
+{
+	const char *p = cmd;
+	debug_printf("\n*** Failed target:  %s\n*** Failed command: ",
+		     gn->name);
+
+	/* 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(" ");
+			cpp_skip_whitespace(&p);
+		} else {
+			debug_printf("%c", *p);
+			p++;
+		}
+	}
+	debug_printf("\n");
+}
+
 /* Execute the next command for a target. If the command returns an error,
  * the node's made field is set to ERROR and creation stops.
  *
@@ -373,24 +394,8 @@ Compat_RunCommand(const char *cmdp, GNod
 	}
 #endif
 	if (status != 0) {
-	    if (DEBUG(ERROR)) {
-		const char *p = cmd;
-		debug_printf("\n*** Failed target:  %s\n*** Failed command: ",
-			     gn->name);
-
-		/* 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(" ");
-			cpp_skip_whitespace(&p);
-		    } else {
-			debug_printf("%c", *p);
-			p++;
-		    }
-		}
-		debug_printf("\n");
-	    }
+	    if (DEBUG(ERROR))
+		    DebugFailedTarget(cmd, gn);
 	    printf("*** Error code %d", status);
 	}
     } else {

Reply via email to