=================================================================== RCS file: /cvs/docbook2mdoc/main.c,v retrieving revision 1.7 retrieving revision 1.9 diff -u -p -r1.7 -r1.9 --- docbook2mdoc/main.c 2019/04/28 15:03:29 1.7 +++ docbook2mdoc/main.c 2019/05/01 07:14:17 1.9 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.7 2019/04/28 15:03:29 schwarze Exp $ */ +/* $Id: main.c,v 1.9 2019/05/01 07:14:17 schwarze Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * Copyright (c) 2019 Ingo Schwarze @@ -16,12 +16,14 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include +#include #include #include #include #include "node.h" #include "parse.h" +#include "reorg.h" #include "format.h" /* @@ -40,7 +42,7 @@ main(int argc, char *argv[]) struct parse *parser; struct ptree *tree; const char *progname; - const char *fname; + const char *fname, *bname; int ch, fd, rc, warn; enum outt outtype; @@ -96,6 +98,7 @@ main(int argc, char *argv[]) parser = parse_alloc(warn); tree = parse_file(parser, fd, fname); + ptree_reorg(tree); rc = tree->flags & TREE_ERROR ? 3 : tree->flags & TREE_WARN ? 2 : 0; /* Format. */ @@ -103,9 +106,12 @@ main(int argc, char *argv[]) if (outtype != OUTT_LINT && tree->root != NULL) { if (rc > 2) fputc('\n', stderr); - if (outtype == OUTT_MDOC) + if (outtype == OUTT_MDOC) { + if (fd == -1 && (bname = basename(fname)) != NULL) + printf(".\\\" automatically generated " + "with %s %s\n", progname, bname); ptree_print_mdoc(tree); - else + } else ptree_print_tree(tree); if (rc > 2) fputs("\nThe output may be incomplete, see the "