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

Diff for /docbook2mdoc/main.c between version 1.5 and 1.6

version 1.5, 2019/04/09 15:23:51 version 1.6, 2019/04/12 19:14:50
Line 28 
Line 28 
  * 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 42  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 50  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 82  main(int argc, char *argv[])
Line 103  main(int argc, char *argv[])
   
         /* Format. */          /* Format. */
   
         if (tree->root != NULL) {          if (outtype != OUTT_LINT && tree->root != NULL) {
                 if (rc > 2)                  if (rc > 2)
                         fputc('\n', stderr);                          fputc('\n', stderr);
                 ptree_print(tree);                  if (outtype == OUTT_MDOC)
                           ptree_print_mdoc(tree);
                   else
                           ptree_print_tree(tree);
                 if (rc > 2)                  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 118  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] "
               "[input_filename]\n", progname);
         return 5;          return 5;
 }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

CVSweb