aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorHartmut Brandt <harti@FreeBSD.org>2005-03-11 13:24:08 +0000
committerHartmut Brandt <harti@FreeBSD.org>2005-03-11 13:24:08 +0000
commitc2d34cc331dbaaae52d689a69bd4a2da5013d504 (patch)
treed7a72118acaac8f01559518c6d55a24514af1049 /usr.bin
parentd64ac531acb0f81be1d56e10b36556e6689fbe19 (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/suff.c101
-rw-r--r--usr.bin/make/util.c20
-rw-r--r--usr.bin/make/util.h7
3 files changed, 65 insertions, 63 deletions
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c
index 4972b4b84420..408f44ebb8cb 100644
--- a/usr.bin/make/suff.c
+++ b/usr.bin/make/suff.c
@@ -2288,80 +2288,55 @@ Suff_Init(void)
/********************* DEBUGGING FUNCTIONS **********************/
-static int
-SuffPrintName(void *s, void *dummy __unused)
+void
+Suff_PrintAll(void)
{
+ const LstNode *ln;
+ const LstNode *tln;
+ const GNode *gn;
+ const Suff *s;
- printf("`%s' ", ((Suff *)s)->name);
- return (0);
-}
-
-static int
-SuffPrintSuff(void *sp, void *dummy __unused)
-{
- Suff *s = sp;
- int flags;
- int flag;
+ static const struct flag2str suff_flags[] = {
+ { SUFF_INCLUDE, "INCLUDE" },
+ { SUFF_LIBRARY, "LIBRARY" },
+ { SUFF_NULL, "NULL" },
+ { 0, NULL }
+ };
- printf("# `%s' [%d] ", s->name, s->refCount);
+ printf("#*** Suffixes:\n");
+ LST_FOREACH(ln, &sufflist) {
+ s = Lst_Datum(ln);
+ printf("# `%s' [%d] ", s->name, s->refCount);
- flags = s->flags;
- if (flags) {
- fputs(" (", stdout);
- while (flags) {
- flag = 1 << (ffs(flags) - 1);
- flags &= ~flag;
- switch (flag) {
- case SUFF_NULL:
- printf("NULL");
- break;
- case SUFF_INCLUDE:
- printf("INCLUDE");
- break;
- case SUFF_LIBRARY:
- printf("LIBRARY");
- break;
- default:
- break;
- }
- fputc(flags ? '|' : ')', stdout);
+ if (s->flags != 0) {
+ printf(" ");
+ print_flags(stdout, suff_flags, s->flags);
}
- }
- fputc('\n', stdout);
- printf("#\tTo: ");
- Lst_ForEach(&s->parents, SuffPrintName, (void *)NULL);
- fputc('\n', stdout);
- printf("#\tFrom: ");
- Lst_ForEach(&s->children, SuffPrintName, (void *)NULL);
- fputc('\n', stdout);
- printf("#\tSearch Path: ");
- Dir_PrintPath(&s->searchPath);
- fputc('\n', stdout);
- return (0);
-}
-static int
-SuffPrintTrans(void *tp, void *dummy __unused)
-{
- GNode *t = tp;
+ printf("\n#\tTo: ");
+ LST_FOREACH(tln, &s->parents)
+ printf("`%s' ", ((const Suff *)Lst_Datum(tln))->name);
- printf("%-16s: ", t->name);
- Targ_PrintType(t->type);
- fputc('\n', stdout);
- Lst_ForEach(&t->commands, Targ_PrintCmd, (void *)NULL);
- fputc('\n', stdout);
- return (0);
-}
+ printf("\n#\tFrom: ");
+ LST_FOREACH(tln, &s->children)
+ printf("`%s' ", ((const Suff *)Lst_Datum(tln))->name);
-void
-Suff_PrintAll(void)
-{
+ printf("\n#\tSearch Path: ");
+ Dir_PrintPath(&s->searchPath);
- printf("#*** Suffixes:\n");
- Lst_ForEach(&sufflist, SuffPrintSuff, (void *)NULL);
+ printf("\n");
+ }
printf("#*** Transformations:\n");
- Lst_ForEach(&transforms, SuffPrintTrans, (void *)NULL);
+ LST_FOREACH(ln, &transforms) {
+ gn = Lst_Datum(ln);
+ printf("%-16s: ", gn->name);
+ Targ_PrintType(gn->type);
+ printf("\n");
+ LST_FOREACH(tln, &gn->commands)
+ printf("\t%s\n", (const char *)Lst_Datum(tln));
+ printf("\n");
+ }
}
#ifdef DEBUG_SRC
diff --git a/usr.bin/make/util.c b/usr.bin/make/util.c
index e0dbfdc7ffab..70e814a126ee 100644
--- a/usr.bin/make/util.c
+++ b/usr.bin/make/util.c
@@ -292,3 +292,23 @@ eunlink(const char *file)
return (unlink(file));
}
+/*
+ * Convert a flag word to a printable thing and print it
+ */
+void
+print_flags(FILE *fp, const struct flag2str *tab, u_int flags)
+{
+ int first = 1;
+
+ fprintf(fp, "(");
+ while (tab->str != NULL) {
+ if (flags & tab->flag) {
+ if (!first)
+ fprintf(fp, "|");
+ first = 0;
+ fprintf(fp, "%s", tab->str);
+ }
+ tab++;
+ }
+ fprintf(fp, ")");
+}
diff --git a/usr.bin/make/util.h b/usr.bin/make/util.h
index 84fc6b9e1e55..bcb8effa7f7b 100644
--- a/usr.bin/make/util.h
+++ b/usr.bin/make/util.h
@@ -42,9 +42,15 @@
#define util_h_b7020fdb
#include <sys/types.h>
+#include <stdio.h>
#define CONCAT(a,b) a##b
+struct flag2str {
+ u_int flag;
+ const char *str;
+};
+
/*
* debug control:
* There is one bit per module. It is up to the module what debug
@@ -90,5 +96,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);
#endif /* util_h_b7020fdb */