diff options
author | harti <harti@FreeBSD.org> | 2005-05-13 13:47:41 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2005-05-13 13:47:41 +0000 |
commit | c52091a829f09826ff39dc62da6eae2507746aa5 (patch) | |
tree | aba8baf678d2a6c141693d6db6bf039399c89e13 /usr.bin | |
parent | 407f5f009c8e5a70c5fa5d8f7e21fbb26dfb71c0 (diff) | |
download | FreeBSD-src-c52091a829f09826ff39dc62da6eae2507746aa5.zip FreeBSD-src-c52091a829f09826ff39dc62da6eae2507746aa5.tar.gz |
Use the print_flags function to print the OP_ flags of a target.
Give the function one more argument to decide whether it should
print the flags like a C-expression or just space-delimited.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/make/suff.c | 2 | ||||
-rw-r--r-- | usr.bin/make/targ.c | 55 | ||||
-rw-r--r-- | usr.bin/make/util.c | 10 | ||||
-rw-r--r-- | usr.bin/make/util.h | 2 |
4 files changed, 28 insertions, 41 deletions
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 75bae20..6b75493 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -2177,7 +2177,7 @@ Suff_PrintAll(void) if (s->flags != 0) { printf(" "); - print_flags(stdout, suff_flags, s->flags); + print_flags(stdout, suff_flags, s->flags, 1); } printf("\n#\tTo: "); diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c index c738d18..fab3189 100644 --- a/usr.bin/make/targ.c +++ b/usr.bin/make/targ.c @@ -335,43 +335,28 @@ Targ_FmtTime(time_t modtime) void Targ_PrintType(int type) { - int tbit; - -#define PRINTBIT(attr) \ - case CONCAT(OP_,attr): \ - printf("." #attr " "); \ - break - -#define PRINTDBIT(attr) \ - case CONCAT(OP_,attr): \ - DEBUGF(TARG, ("." #attr " ")); \ - break + static const struct flag2str type2str[] = { + { OP_OPTIONAL, ".OPTIONAL" }, + { OP_USE, ".USE" }, + { OP_EXEC, ".EXEC" }, + { OP_IGNORE, ".IGNORE" }, + { OP_PRECIOUS, ".PRECIOUS" }, + { OP_SILENT, ".SILENT" }, + { OP_MAKE, ".MAKE" }, + { OP_JOIN, ".JOIN" }, + { OP_INVISIBLE, ".INVISIBLE" }, + { OP_NOTMAIN, ".NOTMAIN" }, + { OP_PHONY, ".PHONY" }, + { OP_LIB, ".LIB" }, + { OP_MEMBER, ".MEMBER" }, + { OP_ARCHV, ".ARCHV" }, + { 0, NULL } + }; type &= ~OP_OPMASK; - - while (type) { - tbit = 1 << (ffs(type) - 1); - 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: - DEBUGF(TARG, (".MEMBER ")); - break; - PRINTDBIT(ARCHV); - } - } + if (!DEBUG(TARG)) + type &= ~(OP_ARCHV | OP_LIB | OP_MEMBER); + print_flags(stdout, type2str, type, 0); } /** diff --git a/usr.bin/make/util.c b/usr.bin/make/util.c index 70e814a..3a27b0a 100644 --- a/usr.bin/make/util.c +++ b/usr.bin/make/util.c @@ -296,19 +296,21 @@ eunlink(const char *file) * Convert a flag word to a printable thing and print it */ void -print_flags(FILE *fp, const struct flag2str *tab, u_int flags) +print_flags(FILE *fp, const struct flag2str *tab, u_int flags, int par) { int first = 1; - fprintf(fp, "("); + if (par) + fprintf(fp, "("); while (tab->str != NULL) { if (flags & tab->flag) { if (!first) - fprintf(fp, "|"); + fprintf(fp, par ? "|" : " "); first = 0; fprintf(fp, "%s", tab->str); } tab++; } - fprintf(fp, ")"); + if (par) + fprintf(fp, ")"); } diff --git a/usr.bin/make/util.h b/usr.bin/make/util.h index 139e9a3..01cd851 100644 --- a/usr.bin/make/util.h +++ b/usr.bin/make/util.h @@ -116,6 +116,6 @@ char *estrdup(const char *); void *emalloc(size_t); void *erealloc(void *, size_t); int eunlink(const char *); -void print_flags(FILE *, const struct flag2str *, u_int); +void print_flags(FILE *, const struct flag2str *, u_int, int); #endif /* util_h_b7020fdb */ |