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

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

version 1.6, 2019/04/12 19:14:50 version 1.10, 2019/05/01 09:02:25
Line 16 
Line 16 
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
 #include <getopt.h>  #include <getopt.h>
   #include <libgen.h>
 #include <stdio.h>  #include <stdio.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   
 #include "node.h"  #include "node.h"
 #include "parse.h"  #include "parse.h"
   #include "reorg.h"
 #include "format.h"  #include "format.h"
   
 /*  /*
Line 40  main(int argc, char *argv[])
Line 42  main(int argc, char *argv[])
         struct parse    *parser;          struct parse    *parser;
         struct ptree    *tree;          struct ptree    *tree;
         const char      *progname;          const char      *progname;
         const char      *fname;          const char      *bname, *fname, *sec;
         int              ch, fd, rc, warn;          int              ch, fd, rc, warn;
         enum outt        outtype;          enum outt        outtype;
   
Line 49  main(int argc, char *argv[])
Line 51  main(int argc, char *argv[])
         else          else
                 progname++;                  progname++;
   
           sec = NULL;
         warn = 0;          warn = 0;
         outtype = OUTT_MDOC;          outtype = OUTT_MDOC;
         while ((ch = getopt(argc, argv, "T:W")) != -1) {          while ((ch = getopt(argc, argv, "s:T:W")) != -1) {
                 switch (ch) {                  switch (ch) {
                   case 's':
                           sec = optarg;
                           break;
                 case 'T':                  case 'T':
                         if (strcmp(optarg, "mdoc") == 0)                          if (strcmp(optarg, "mdoc") == 0)
                                 outtype = OUTT_MDOC;                                  outtype = OUTT_MDOC;
Line 94  main(int argc, char *argv[])
Line 100  main(int argc, char *argv[])
   
         /* Parse. */          /* Parse. */
   
         if ((parser = parse_alloc(warn)) == NULL) {          parser = parse_alloc(warn);
                 perror(NULL);  
                 return 6;  
         }  
         tree = parse_file(parser, fd, fname);          tree = parse_file(parser, fd, fname);
           ptree_reorg(tree, sec);
         rc = tree->flags & TREE_ERROR ? 3 : tree->flags & TREE_WARN ? 2 : 0;          rc = tree->flags & TREE_ERROR ? 3 : tree->flags & TREE_WARN ? 2 : 0;
   
         /* Format. */          /* Format. */
Line 106  main(int argc, char *argv[])
Line 110  main(int argc, char *argv[])
         if (outtype != OUTT_LINT && tree->root != NULL) {          if (outtype != OUTT_LINT && tree->root != NULL) {
                 if (rc > 2)                  if (rc > 2)
                         fputc('\n', stderr);                          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);                          ptree_print_mdoc(tree);
                 else                  } else
                         ptree_print_tree(tree);                          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 "
Line 118  main(int argc, char *argv[])
Line 125  main(int argc, char *argv[])
         return rc;          return rc;
   
 usage:  usage:
         fprintf(stderr, "usage: %s [-W] [-T mdoc | tree | lint] "          fprintf(stderr, "usage: %s [-W] [-s section] "
             "[input_filename]\n", progname);              "[-T mdoc | tree | lint] [input_filename]\n", progname);
         return 5;          return 5;
 }  }

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

CVSweb