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(1): don't concatenate identifiers in Targ_...



details:   https://anonhg.NetBSD.org/src/rev/37dfed3c6604
branches:  trunk
changeset: 946639:37dfed3c6604
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 05 15:57:02 2020 +0000

description:
make(1): don't concatenate identifiers in Targ_PrintType

Concatenating identifiers makes it difficult to spot them when searching
the code.  This gets rid of the special case for OP_MEMBER and MEMBER.

The same pattern is applied in the DEBUG macro, by the way.

diffstat:

 usr.bin/make/targ.c |  42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diffs (70 lines):

diff -r afb96c20ec61 -r 37dfed3c6604 usr.bin/make/targ.c
--- a/usr.bin/make/targ.c       Sat Dec 05 15:35:34 2020 +0000
+++ b/usr.bin/make/targ.c       Sat Dec 05 15:57:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: targ.c,v 1.150 2020/12/05 15:35:34 rillig Exp $        */
+/*     $NetBSD: targ.c,v 1.151 2020/12/05 15:57:02 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -119,7 +119,7 @@
 #include "dir.h"
 
 /*     "@(#)targ.c     8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.150 2020/12/05 15:35:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.151 2020/12/05 15:57:02 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -444,9 +444,6 @@
 {
        int tbit;
 
-#define PRINTBIT(attr) case CONCAT(OP_,attr): debug_printf(" ." #attr); break
-#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG))debug_printf(" ." #attr); break
-
        type &= ~OP_OPMASK;
 
        while (type != 0) {
@@ -454,22 +451,25 @@
                type &= ~tbit;
 
                switch (tbit) {
-               PRINTBIT(OPTIONAL);
-               PRINTBIT(USE);
-               PRINTBIT(EXEC);
-               PRINTBIT(IGNORE);
-               PRINTBIT(PRECIOUS);
-               PRINTBIT(SILENT);
-               PRINTBIT(MAKE);
-               PRINTBIT(JOIN);
-               PRINTBIT(INVISIBLE);
-               PRINTBIT(NOTMAIN);
-               PRINTDBIT(LIB);
-               /*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
-               case OP_MEMBER: if (DEBUG(TARG))debug_printf(" .MEMBER"); break;
-               PRINTDBIT(ARCHV);
-               PRINTDBIT(MADE);
-               PRINTDBIT(PHONY);
+#define PRINTBIT(bit, name) case bit: debug_printf(" " name); break
+#define PRINTDBIT(bit, attr) case bit: if (DEBUG(TARG)) debug_printf(" " 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
                }
        }
 }



Home | Main Index | Thread Index | Old Index