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

Diff for /mandoc/main.c between version 1.43 and 1.45

version 1.43, 2009/09/16 22:17:27 version 1.45, 2009/10/13 10:21:24
Line 20 
Line 20 
 #include <err.h>  #include <err.h>
 #include <fcntl.h>  #include <fcntl.h>
 #include <stdio.h>  #include <stdio.h>
   #include <stdint.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
Line 27 
Line 28 
 #include "mdoc.h"  #include "mdoc.h"
 #include "man.h"  #include "man.h"
   
   #define UNCONST(a)      ((void *)(uintptr_t)(const void *)(a))
   
 /* Account for FreeBSD and Linux in our declarations. */  /* Account for FreeBSD and Linux in our declarations. */
   
 #ifdef __linux__  #ifdef __linux__
Line 58  enum intt {
Line 61  enum intt {
 enum    outt {  enum    outt {
         OUTT_ASCII = 0,          OUTT_ASCII = 0,
         OUTT_TREE,          OUTT_TREE,
 #if 1  
         OUTT_HTML,          OUTT_HTML,
 #endif  
         OUTT_LINT          OUTT_LINT
 };  };
   
Line 86  struct curparse {
Line 87  struct curparse {
         out_man           outman;          out_man           outman;
         out_free          outfree;          out_free          outfree;
         void             *outdata;          void             *outdata;
           char             *outopts;
 };  };
   
 #if 1  extern  void             *html_alloc(char *);
 extern  void             *html_alloc(void);  
 extern  void              html_mdoc(void *, const struct mdoc *);  extern  void              html_mdoc(void *, const struct mdoc *);
 extern  void              html_man(void *, const struct man *);  extern  void              html_man(void *, const struct man *);
 extern  void              html_free(void *);  extern  void              html_free(void *);
 #endif  
 extern  void             *ascii_alloc(void);  extern  void             *ascii_alloc(void);
 extern  void              tree_mdoc(void *, const struct mdoc *);  extern  void              tree_mdoc(void *, const struct mdoc *);
 extern  void              tree_man(void *, const struct man *);  extern  void              tree_man(void *, const struct man *);
Line 134  main(int argc, char *argv[])
Line 134  main(int argc, char *argv[])
         curp.outtype = OUTT_ASCII;          curp.outtype = OUTT_ASCII;
   
         /* LINTED */          /* LINTED */
         while (-1 != (c = getopt(argc, argv, "f:m:VW:T:")))          while (-1 != (c = getopt(argc, argv, "f:m:o:T:VW:")))
                 switch (c) {                  switch (c) {
                 case ('f'):                  case ('f'):
                         if ( ! foptions(&curp.fflags, optarg))                          if ( ! foptions(&curp.fflags, optarg))
Line 144  main(int argc, char *argv[])
Line 144  main(int argc, char *argv[])
                         if ( ! moptions(&curp.inttype, optarg))                          if ( ! moptions(&curp.inttype, optarg))
                                 return(EXIT_FAILURE);                                  return(EXIT_FAILURE);
                         break;                          break;
                   case ('o'):
                           curp.outopts = optarg;
                           break;
                 case ('T'):                  case ('T'):
                         if ( ! toptions(&curp.outtype, optarg))                          if ( ! toptions(&curp.outtype, optarg))
                                 return(EXIT_FAILURE);                                  return(EXIT_FAILURE);
Line 441  fdesc(struct buf *blk, struct buf *ln, struct curparse
Line 444  fdesc(struct buf *blk, struct buf *ln, struct curparse
   
         if ( ! (curp->outman && curp->outmdoc)) {          if ( ! (curp->outman && curp->outmdoc)) {
                 switch (curp->outtype) {                  switch (curp->outtype) {
 #if 1  
                 case (OUTT_HTML):                  case (OUTT_HTML):
                         curp->outdata = html_alloc();                          curp->outdata = html_alloc(curp->outopts);
                         curp->outman = html_man;                          curp->outman = html_man;
                         curp->outmdoc = html_mdoc;                          curp->outmdoc = html_mdoc;
                         curp->outfree = html_free;                          curp->outfree = html_free;
                         break;                          break;
 #endif  
                 case (OUTT_TREE):                  case (OUTT_TREE):
                         curp->outman = tree_man;                          curp->outman = tree_man;
                         curp->outmdoc = tree_mdoc;                          curp->outmdoc = tree_mdoc;
Line 563  toptions(enum outt *tflags, char *arg)
Line 564  toptions(enum outt *tflags, char *arg)
                 *tflags = OUTT_LINT;                  *tflags = OUTT_LINT;
         else if (0 == strcmp(arg, "tree"))          else if (0 == strcmp(arg, "tree"))
                 *tflags = OUTT_TREE;                  *tflags = OUTT_TREE;
 #if 1  
         else if (0 == strcmp(arg, "html"))          else if (0 == strcmp(arg, "html"))
                 *tflags = OUTT_HTML;                  *tflags = OUTT_HTML;
 #endif  
         else {          else {
                 warnx("bad argument: -T%s", arg);                  warnx("bad argument: -T%s", arg);
                 return(0);                  return(0);
Line 580  static int
Line 579  static int
 foptions(int *fflags, char *arg)  foptions(int *fflags, char *arg)
 {  {
         char            *v, *o;          char            *v, *o;
         char            *toks[7];          const char      *toks[7];
   
         toks[0] = "ign-scope";          toks[0] = "ign-scope";
         toks[1] = "no-ign-escape";          toks[1] = "no-ign-escape";
Line 592  foptions(int *fflags, char *arg)
Line 591  foptions(int *fflags, char *arg)
   
         while (*arg) {          while (*arg) {
                 o = arg;                  o = arg;
                 switch (getsubopt(&arg, toks, &v)) {                  switch (getsubopt(&arg, UNCONST(toks), &v)) {
                 case (0):                  case (0):
                         *fflags |= IGN_SCOPE;                          *fflags |= IGN_SCOPE;
                         break;                          break;
Line 626  static int
Line 625  static int
 woptions(int *wflags, char *arg)  woptions(int *wflags, char *arg)
 {  {
         char            *v, *o;          char            *v, *o;
         char            *toks[3];          const char      *toks[3];
   
         toks[0] = "all";          toks[0] = "all";
         toks[1] = "error";          toks[1] = "error";
Line 634  woptions(int *wflags, char *arg)
Line 633  woptions(int *wflags, char *arg)
   
         while (*arg) {          while (*arg) {
                 o = arg;                  o = arg;
                 switch (getsubopt(&arg, toks, &v)) {                  switch (getsubopt(&arg, UNCONST(toks), &v)) {
                 case (0):                  case (0):
                         *wflags |= WARN_WALL;                          *wflags |= WARN_WALL;
                         break;                          break;

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.45

CVSweb