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

Diff for /mandoc/main.c between version 1.44 and 1.50

version 1.44, 2009/09/21 13:06:13 version 1.50, 2009/10/26 15:44:51
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>
   
 #include "mdoc.h"  #include "mdoc.h"
 #include "man.h"  #include "man.h"
   #include "main.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__
 extern  int               getsubopt(char **, char * const *, char **);  extern  int               getsubopt(char **, char * const *, char **);
   extern  size_t            strlcat(char *, const char *, size_t);
 # ifndef __dead  # ifndef __dead
 #  define __dead __attribute__((__noreturn__))  #  define __dead __attribute__((__noreturn__))
 # endif  # endif
Line 84  struct curparse {
Line 89  struct curparse {
         out_man           outman;          out_man           outman;
         out_free          outfree;          out_free          outfree;
         void             *outdata;          void             *outdata;
         char             *outopts;          char              outopts[BUFSIZ];
 };  };
   
 extern  void             *html_alloc(char *);  
 extern  void              html_mdoc(void *, const struct mdoc *);  
 extern  void              html_man(void *, const struct man *);  
 extern  void              html_free(void *);  
 extern  void             *ascii_alloc(void);  
 extern  void              tree_mdoc(void *, const struct mdoc *);  
 extern  void              tree_man(void *, const struct man *);  
 extern  void              terminal_mdoc(void *, const struct mdoc *);  
 extern  void              terminal_man(void *, const struct man *);  
 extern  void              terminal_free(void *);  
   
 static  int               foptions(int *, char *);  static  int               foptions(int *, char *);
 static  int               toptions(enum outt *, char *);  static  int               toptions(enum outt *, char *);
 static  int               moptions(enum intt *, char *);  static  int               moptions(enum intt *, char *);
Line 131  main(int argc, char *argv[])
Line 125  main(int argc, char *argv[])
         curp.outtype = OUTT_ASCII;          curp.outtype = OUTT_ASCII;
   
         /* LINTED */          /* LINTED */
         while (-1 != (c = getopt(argc, argv, "f:m:o:T:VW:")))          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 141  main(int argc, char *argv[])
Line 135  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'):                  case ('O'):
                         curp.outopts = optarg;                          (void)strlcat(curp.outopts, optarg, BUFSIZ);
                           (void)strlcat(curp.outopts, ",", BUFSIZ);
                         break;                          break;
                 case ('T'):                  case ('T'):
                         if ( ! toptions(&curp.outtype, optarg))                          if ( ! toptions(&curp.outtype, optarg))
Line 228  usage(void)
Line 223  usage(void)
 {  {
   
         (void)fprintf(stderr, "usage: %s [-V] [-foption...] "          (void)fprintf(stderr, "usage: %s [-V] [-foption...] "
                         "[-mformat] [-Toutput] [-Werr...]\n",                          "[-mformat] [-Ooption] [-Toutput] "
                         __progname);                          "[-Werr...]\n", __progname);
         exit(EXIT_FAILURE);          exit(EXIT_FAILURE);
 }  }
   
Line 576  static int
Line 571  static int
 foptions(int *fflags, char *arg)  foptions(int *fflags, char *arg)
 {  {
         char            *v, *o;          char            *v, *o;
         char            *toks[7];          const char      *toks[8];
   
         toks[0] = "ign-scope";          toks[0] = "ign-scope";
         toks[1] = "no-ign-escape";          toks[1] = "no-ign-escape";
Line 584  foptions(int *fflags, char *arg)
Line 579  foptions(int *fflags, char *arg)
         toks[3] = "no-ign-chars";          toks[3] = "no-ign-chars";
         toks[4] = "ign-errors";          toks[4] = "ign-errors";
         toks[5] = "strict";          toks[5] = "strict";
         toks[6] = NULL;          toks[6] = "ign-escape";
           toks[7] = NULL;
   
         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 608  foptions(int *fflags, char *arg)
Line 604  foptions(int *fflags, char *arg)
                         *fflags |= NO_IGN_ESCAPE |                          *fflags |= NO_IGN_ESCAPE |
                                    NO_IGN_MACRO | NO_IGN_CHARS;                                     NO_IGN_MACRO | NO_IGN_CHARS;
                         break;                          break;
                   case (6):
                           *fflags &= ~NO_IGN_ESCAPE;
                           break;
                 default:                  default:
                         warnx("bad argument: -f%s", o);                          warnx("bad argument: -f%s", o);
                         return(0);                          return(0);
Line 622  static int
Line 621  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 630  woptions(int *wflags, char *arg)
Line 629  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.44  
changed lines
  Added in v.1.50

CVSweb