Module Name: src Committed By: rillig Date: Sun Sep 12 07:50:45 UTC 2021
Modified Files: src/usr.bin/make: targ.c Log Message: make: make Targ_PrintType simpler No functional change. To generate a diff of this commit: cvs rdiff -u -r1.168 -r1.169 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.168 src/usr.bin/make/targ.c:1.169 --- src/usr.bin/make/targ.c:1.168 Sat Apr 3 12:01:00 2021 +++ src/usr.bin/make/targ.c Sun Sep 12 07:50:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: targ.c,v 1.168 2021/04/03 12:01:00 rillig Exp $ */ +/* $NetBSD: targ.c,v 1.169 2021/09/12 07:50:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -113,7 +113,7 @@ #include "dir.h" /* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: targ.c,v 1.168 2021/04/03 12:01:00 rillig Exp $"); +MAKE_RCSID("$NetBSD: targ.c,v 1.169 2021/09/12 07:50:45 rillig Exp $"); /* * All target nodes that appeared on the left-hand side of one of the @@ -418,34 +418,34 @@ Targ_FmtTime(time_t tm) void Targ_PrintType(int type) { - int tbit; - - type &= ~OP_OPMASK; - - while (type != 0) { - tbit = 1 << (ffs(type) - 1); - type &= ~tbit; - - switch (tbit) { -#define PRINTBIT(bit, attr) case bit: debug_printf(" " attr); break -#define PRINTDBIT(bit, attr) case bit: DEBUG0(TARG, " " attr); break - PRINTBIT(OP_OPTIONAL, ".OPTIONAL"); - PRINTBIT(OP_USE, ".USE"); - PRINTBIT(OP_EXEC, ".EXEC"); - PRINTBIT(OP_IGNORE, ".IGNORE"); - PRINTBIT(OP_PRECIOUS, ".PRECIOUS"); - PRINTBIT(OP_SILENT, ".SILENT"); - PRINTBIT(OP_MAKE, ".MAKE"); - PRINTBIT(OP_JOIN, ".JOIN"); - PRINTBIT(OP_INVISIBLE, ".INVISIBLE"); - PRINTBIT(OP_NOTMAIN, ".NOTMAIN"); - PRINTDBIT(OP_LIB, ".LIB"); - PRINTDBIT(OP_MEMBER, ".MEMBER"); - PRINTDBIT(OP_ARCHV, ".ARCHV"); - PRINTDBIT(OP_MADE, ".MADE"); - PRINTDBIT(OP_PHONY, ".PHONY"); -#undef PRINTBIT -#undef PRINTDBIT + static const struct { + GNodeType bit; + bool internal; + const char *name; + } names[] = { + { OP_MEMBER, true, "MEMBER" }, + { OP_LIB, true, "LIB" }, + { OP_ARCHV, true, "ARCHV" }, + { OP_PHONY, true, "PHONY" }, + { OP_NOTMAIN, false, "NOTMAIN" }, + { OP_INVISIBLE, false, "INVISIBLE" }, + { OP_MADE, true, "MADE" }, + { OP_JOIN, false, "JOIN" }, + { OP_MAKE, false, "MAKE" }, + { OP_SILENT, false, "SILENT" }, + { OP_PRECIOUS, false, "PRECIOUS" }, + { OP_IGNORE, false, "IGNORE" }, + { OP_EXEC, false, "EXEC" }, + { OP_USE, false, "USE" }, + { OP_OPTIONAL, false, "OPTIONAL" }, + }; + + for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) { + if (type & names[i].bit) { + if (names[i].internal) + DEBUG1(TARG, " .%s", names[i].name); + else + debug_printf(" .%s", names[i].name); } } }