Module Name: src
Committed By: rillig
Date: Sat Sep 12 16:22:32 UTC 2020
Modified Files:
src/usr.bin/make: targ.c
Log Message:
make(1): fix trailing space in output of related node names (-dg2)
To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/usr.bin/make/targ.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/targ.c
diff -u src/usr.bin/make/targ.c:1.84 src/usr.bin/make/targ.c:1.85
--- src/usr.bin/make/targ.c:1.84 Sat Sep 12 16:13:48 2020
+++ src/usr.bin/make/targ.c Sat Sep 12 16:22:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.84 2020/09/12 16:13:48 rillig Exp $ */
+/* $NetBSD: targ.c,v 1.85 2020/09/12 16:22:32 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: targ.c,v 1.84 2020/09/12 16:13:48 rillig Exp $";
+static char rcsid[] = "$NetBSD: targ.c,v 1.85 2020/09/12 16:22:32 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: targ.c,v 1.84 2020/09/12 16:13:48 rillig Exp $");
+__RCSID("$NetBSD: targ.c,v 1.85 2020/09/12 16:22:32 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -141,7 +141,6 @@ static Lst allGNs; /* List of all the
static Hash_Table targets; /* a hash table of same */
static int TargPrintOnlySrc(void *, void *);
-static int TargPrintName(void *, void *);
#ifdef CLEANUP
static void TargFreeGN(void *);
#endif
@@ -369,14 +368,25 @@ Targ_SetMain(GNode *gn)
mainTarg = gn;
}
-static int
-TargPrintName(void *gnp, void *pflags MAKE_ATTR_UNUSED)
+static void __attribute__((noinline))
+PrintNodeNames(Lst gnodes)
{
- GNode *gn = (GNode *)gnp;
+ LstNode node;
- fprintf(debug_file, "%s%s ", gn->name, gn->cohort_num);
+ for (node = Lst_First(gnodes); node != NULL; node = LstNode_Next(node)) {
+ GNode *gn = LstNode_Datum(node);
+ fprintf(debug_file, " %s%s", gn->name, gn->cohort_num);
+ }
+}
- return 0;
+static void
+PrintNodeNamesLine(const char *label, Lst gnodes)
+{
+ if (Lst_IsEmpty(gnodes))
+ return;
+ fprintf(debug_file, "# %s:", label);
+ PrintNodeNames(gnodes);
+ fprintf(debug_file, "\n");
}
static int
@@ -492,30 +502,14 @@ Targ_PrintNode(void *gnp, void *passp)
fprintf(debug_file, "# unmade\n");
}
}
- if (!Lst_IsEmpty(gn->implicitParents)) {
- fprintf(debug_file, "# implicit parents: ");
- Lst_ForEach(gn->implicitParents, TargPrintName, NULL);
- fprintf(debug_file, "\n");
- }
+ PrintNodeNamesLine("implicit parents", gn->implicitParents);
} else {
if (gn->unmade)
fprintf(debug_file, "# %d unmade children\n", gn->unmade);
}
- if (!Lst_IsEmpty(gn->parents)) {
- fprintf(debug_file, "# parents: ");
- Lst_ForEach(gn->parents, TargPrintName, NULL);
- fprintf(debug_file, "\n");
- }
- if (!Lst_IsEmpty(gn->order_pred)) {
- fprintf(debug_file, "# order_pred: ");
- Lst_ForEach(gn->order_pred, TargPrintName, NULL);
- fprintf(debug_file, "\n");
- }
- if (!Lst_IsEmpty(gn->order_succ)) {
- fprintf(debug_file, "# order_succ: ");
- Lst_ForEach(gn->order_succ, TargPrintName, NULL);
- fprintf(debug_file, "\n");
- }
+ PrintNodeNamesLine("parents", gn->parents);
+ PrintNodeNamesLine("order_pred", gn->order_pred);
+ PrintNodeNamesLine("order_succ", gn->order_succ);
fprintf(debug_file, "%-16s", gn->name);
switch (gn->type & OP_OPMASK) {
@@ -527,7 +521,7 @@ Targ_PrintNode(void *gnp, void *passp)
fprintf(debug_file, "::"); break;
}
Targ_PrintType(gn->type);
- Lst_ForEach(gn->children, TargPrintName, NULL);
+ PrintNodeNames(gn->children);
fprintf(debug_file, "\n");
Targ_PrintCmds(gn);
fprintf(debug_file, "\n\n");