diff --git a/genex/comp.c b/genex/comp.c index 4824823..2fbfca5 100644 --- a/genex/comp.c +++ b/genex/comp.c @@ -223,7 +223,7 @@ void set_libs(struct node *node, } -static void dump_level(const struct node *tree, int level) +static void dump_tree_level(const struct node *tree, int level) { const struct node *n; const struct line *line; @@ -240,12 +240,30 @@ static void dump_level(const struct node *tree, int level) printf("\n"); for (line = n->comment; line; line = line->next) printf("%*s\"%s\"\n", 4*level+2, "", line->s); - dump_level(n->child, level+1); + dump_tree_level(n->child, level+1); } } void dump_tree(void) { - dump_level(tree, 0); + dump_tree_level(tree, 0); +} + + +static void dump_comp_level(const struct node *tree) +{ + const struct node *n; + + for (n = tree; n; n = n->next) { + if (n->lib) + printf("%s\n", n->names->s); + dump_comp_level(n->child); + } +} + + +void dump_comp(void) +{ + dump_comp_level(tree); } diff --git a/genex/comp.h b/genex/comp.h index e31338a..70d2d44 100644 --- a/genex/comp.h +++ b/genex/comp.h @@ -43,5 +43,6 @@ void set_libs(struct node *node, const char *(*find_lib)(const char *sym, const struct name **names, int *units)); void dump_tree(void); +void dump_comp(void); #endif /* !COMP_H */ diff --git a/genex/genex.c b/genex/genex.c index d3b6c8d..d4f74ff 100644 --- a/genex/genex.c +++ b/genex/genex.c @@ -23,9 +23,10 @@ static void usage(const char *name) { fprintf(stderr, -"usage: %s [-d] [-p] [-P] [-L libdir ...] [-l lib ...] hierarchy\n" +"usage: %s [-d|-D] [-p] [-P] [-L libdir ...] [-l lib ...] hierarchy\n" " %*s [descriptions ...]\n\n" " -d dump the tree instead of generating a PDF\n" +" -D dump all the canonical component names (without aliases)\n" " -L libdir search all libraries in the specified directory\n" " -l lib search the specified component library\n" " -p use portrait orientation; default: landscape\n" @@ -39,13 +40,16 @@ int main(int argc, char **argv) { FILE *file; int c; - int dump = 0, postscript = 0, portrait = 0; + int opt_dump_tree = 0, opt_dump_comp = 0, postscript = 0, portrait = 0; char **arg; - while ((c = getopt(argc, argv, "dL:l:Pp")) != EOF) + while ((c = getopt(argc, argv, "dDL:l:Pp")) != EOF) switch (c) { case 'd': - dump = 1; + opt_dump_tree = 1; + break; + case 'D': + opt_dump_comp = 1; break; case 'L': add_libdir(optarg); @@ -63,6 +67,9 @@ int main(int argc, char **argv) usage(*argv); } + if (opt_dump_tree && opt_dump_comp) + usage(*argv); + switch (argc-optind) { case 1: case 2: @@ -89,8 +96,10 @@ int main(int argc, char **argv) read_desc(file); fclose(file); } - if (dump) + if (opt_dump_tree) dump_tree(); + else if (opt_dump_comp) + dump_comp(); else make_pdf(!postscript, portrait); return 0;