[BACK]Return to main.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / docbook2mdoc

Diff for /docbook2mdoc/main.c between version 1.4 and 1.8

version 1.4, 2019/04/08 22:47:34 version 1.8, 2019/04/28 17:10:06
Line 22 
Line 22 
   
 #include "node.h"  #include "node.h"
 #include "parse.h"  #include "parse.h"
   #include "reorg.h"
 #include "format.h"  #include "format.h"
   
 /*  /*
  * The steering function of the docbook2mdoc(1) program.   * The steering function of the docbook2mdoc(1) program.
  */   */
   
   enum    outt {
           OUTT_MDOC = 0,
           OUTT_TREE,
           OUTT_LINT
   };
   
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
Line 36  main(int argc, char *argv[])
Line 43  main(int argc, char *argv[])
         const char      *progname;          const char      *progname;
         const char      *fname;          const char      *fname;
         int              ch, fd, rc, warn;          int              ch, fd, rc, warn;
           enum outt        outtype;
   
         if ((progname = strrchr(argv[0], '/')) == NULL)          if ((progname = strrchr(argv[0], '/')) == NULL)
                 progname = argv[0];                  progname = argv[0];
Line 43  main(int argc, char *argv[])
Line 51  main(int argc, char *argv[])
                 progname++;                  progname++;
   
         warn = 0;          warn = 0;
         while ((ch = getopt(argc, argv, "W")) != -1) {          outtype = OUTT_MDOC;
           while ((ch = getopt(argc, argv, "T:W")) != -1) {
                 switch (ch) {                  switch (ch) {
                   case 'T':
                           if (strcmp(optarg, "mdoc") == 0)
                                   outtype = OUTT_MDOC;
                           else if (strcmp(optarg, "tree") == 0)
                                   outtype = OUTT_TREE;
                           else if (strcmp(optarg, "lint") == 0)
                                   outtype = OUTT_LINT;
                           else {
                                   fprintf(stderr, "%s: Bad argument\n",
                                       optarg);
                                   goto usage;
                           }
                           break;
                 case 'W':                  case 'W':
                         warn = 1;                          warn = 1;
                         break;                          break;
Line 73  main(int argc, char *argv[])
Line 95  main(int argc, char *argv[])
   
         /* Parse. */          /* Parse. */
   
         if ((parser = parse_alloc(warn)) == NULL) {          parser = parse_alloc(warn);
                 perror(NULL);  
                 return 1;  
         }  
         tree = parse_file(parser, fd, fname);          tree = parse_file(parser, fd, fname);
         rc = tree->flags & TREE_FAIL ? 1 : 0;          ptree_reorg(tree);
           rc = tree->flags & TREE_ERROR ? 3 : tree->flags & TREE_WARN ? 2 : 0;
   
         /* Format. */          /* Format. */
   
         if (tree->root != NULL) {          if (outtype != OUTT_LINT && tree->root != NULL) {
                 if (rc)                  if (rc > 2)
                         fputc('\n', stderr);                          fputc('\n', stderr);
                 ptree_print(tree);                  if (outtype == OUTT_MDOC)
                 if (rc)                          ptree_print_mdoc(tree);
                   else
                           ptree_print_tree(tree);
                   if (rc > 2)
                         fputs("\nThe output may be incomplete, see the "                          fputs("\nThe output may be incomplete, see the "
                             "parse error reported above.\n\n", stderr);                              "parse error reported above.\n\n", stderr);
         }          }
Line 94  main(int argc, char *argv[])
Line 117  main(int argc, char *argv[])
         return rc;          return rc;
   
 usage:  usage:
         fprintf(stderr, "usage: %s [-W] [input_filename]\n", progname);          fprintf(stderr, "usage: %s [-W] [-T mdoc | tree | lint] "
         return 1;              "[input_filename]\n", progname);
           return 5;
 }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.8

CVSweb