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): print suffix flags in the standard way



details:   https://anonhg.NetBSD.org/src/rev/39a7e18ffdff
branches:  trunk
changeset: 937840:39a7e18ffdff
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 28 03:35:45 2020 +0000

description:
make(1): print suffix flags in the standard way

This changes the output (it is now SUFF_NULL instead of just NULL), and
the order of the flags in the output is reversed.

diffstat:

 usr.bin/make/make.h |   3 ++-
 usr.bin/make/suff.c |  41 +++++++++++++++--------------------------
 2 files changed, 17 insertions(+), 27 deletions(-)

diffs (101 lines):

diff -r 517c6b7d3422 -r 39a7e18ffdff usr.bin/make/make.h
--- a/usr.bin/make/make.h       Fri Aug 28 02:45:51 2020 +0000
+++ b/usr.bin/make/make.h       Fri Aug 28 03:35:45 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.127 2020/08/26 23:00:47 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.128 2020/08/28 03:35:45 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -160,6 +160,7 @@
 #define        FAILURE                 0x00000001
 
 #include "lst.h"
+#include "enum.h"
 #include "hash.h"
 #include "config.h"
 #include "buf.h"
diff -r 517c6b7d3422 -r 39a7e18ffdff usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Fri Aug 28 02:45:51 2020 +0000
+++ b/usr.bin/make/suff.c       Fri Aug 28 03:35:45 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.121 2020/08/27 19:15:35 rillig Exp $        */
+/*     $NetBSD: suff.c,v 1.122 2020/08/28 03:35:45 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.121 2020/08/27 19:15:35 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.122 2020/08/28 03:35:45 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)suff.c     8.4 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: suff.c,v 1.121 2020/08/27 19:15:35 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.122 2020/08/28 03:35:45 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -151,14 +151,18 @@
     SUFF_INCLUDE       = 0x01, /* One which is #include'd */
     SUFF_LIBRARY       = 0x02, /* One which contains a library */
     SUFF_NULL          = 0x04  /* The empty suffix */
+    /* XXX: Why is SUFF_NULL needed? Wouldn't nameLen == 0 mean the same? */
 } SuffFlags;
 
+ENUM_FLAGS_RTTI_3(SuffFlags,
+                 SUFF_INCLUDE, SUFF_LIBRARY, SUFF_NULL);
+
 /*
  * Structure describing an individual suffix.
  */
 typedef struct Suff {
-    char         *name;                /* The suffix itself */
-    int                 nameLen;       /* Length of the suffix */
+    char         *name;                /* The suffix itself, such as ".c" */
+    int                 nameLen;       /* Length of the name, to avoid strlen calls */
     SuffFlags   flags;         /* Type of suffix */
     Lst         searchPath;    /* The path along which files of this suffix
                                 * may be found */
@@ -2602,30 +2606,15 @@
 SuffPrintSuff(void *sp, void *dummy MAKE_ATTR_UNUSED)
 {
     Suff    *s = (Suff *)sp;
-    int            flags;
-    int            flag;
 
     fprintf(debug_file, "# `%s' [%d] ", s->name, s->refCount);
 
-    flags = s->flags;
-    if (flags) {
-       fputs(" (", debug_file);
-       while (flags) {
-           flag = 1 << (ffs(flags) - 1);
-           flags &= ~flag;
-           switch (flag) {
-               case SUFF_NULL:
-                   fprintf(debug_file, "NULL");
-                   break;
-               case SUFF_INCLUDE:
-                   fprintf(debug_file, "INCLUDE");
-                   break;
-               case SUFF_LIBRARY:
-                   fprintf(debug_file, "LIBRARY");
-                   break;
-           }
-           fputc(flags ? '|' : ')', debug_file);
-       }
+    if (s->flags != 0) {
+       char flags_buf[SuffFlags_ToStringSize];
+
+       fprintf(debug_file, " (%s)",
+               Enum_FlagsToString(flags_buf, sizeof flags_buf,
+                                  s->flags, SuffFlags_ToStringSpecs));
     }
     fputc('\n', debug_file);
     fprintf(debug_file, "#\tTo: ");



Home | Main Index | Thread Index | Old Index