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

Diff for /mandoc/main.c between version 1.15 and 1.16

version 1.15, 2009/03/25 21:03:13 version 1.16, 2009/03/25 21:46:24
Line 29 
Line 29 
 #include "mdoc.h"  #include "mdoc.h"
 #include "man.h"  #include "man.h"
   
   /* 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 **);
 # ifndef __dead  # ifndef __dead
Line 54  struct curparse {
Line 56  struct curparse {
 #define WARN_WERR        (1 << 2)       /* Warnings->errors. */  #define WARN_WERR        (1 << 2)       /* Warnings->errors. */
 };  };
   
 #define IGN_SCOPE        (1 << 0) /* Flag to ignore scope. */  #define IGN_SCOPE        (1 << 0)       /* Ignore scope errors. */
 #define IGN_ESCAPE       (1 << 1) /* Flag to ignore bad escapes. */  #define IGN_ESCAPE       (1 << 1)       /* Ignore bad escapes. */
 #define IGN_MACRO        (1 << 2) /* Flag to ignore unknown macros. */  #define IGN_MACRO        (1 << 2)       /* Ignore unknown macros. */
   
 enum    intt {  enum    intt {
         INTT_MDOC = 0,          INTT_MDOC = 0,
Line 65  enum intt {
Line 67  enum intt {
   
 enum    outt {  enum    outt {
         OUTT_ASCII = 0,          OUTT_ASCII = 0,
         OUTT_LATIN1,  
         OUTT_UTF8,  
         OUTT_TREE,          OUTT_TREE,
         OUTT_LINT          OUTT_LINT
 };  };
Line 78  typedef void  (*out_free)(void *);
Line 78  typedef void  (*out_free)(void *);
 extern  char             *__progname;  extern  char             *__progname;
   
 extern  void             *ascii_alloc(void);  extern  void             *ascii_alloc(void);
 extern  void             *latin1_alloc(void);  
 extern  void             *utf8_alloc(void);  
 extern  int               terminal_run(void *, const struct man *,  extern  int               terminal_run(void *, const struct man *,
                                 const struct mdoc *);                                  const struct mdoc *);
 extern  int               tree_run(void *, const struct man *,  extern  int               tree_run(void *, const struct man *,
Line 100  static int    file(struct buf *, struct buf *, 
Line 98  static int    file(struct buf *, struct buf *, 
 static  int               fdesc(struct buf *, struct buf *,  static  int               fdesc(struct buf *, struct buf *,
                                 const char *, int,                                  const char *, int,
                                 struct man *, struct mdoc *);                                  struct man *, struct mdoc *);
   
 __dead  static void       version(void);  __dead  static void       version(void);
 __dead  static void       usage(void);  __dead  static void       usage(void);
   
Line 158  main(int argc, char *argv[])
Line 155  main(int argc, char *argv[])
         argv += optind;          argv += optind;
   
         /*          /*
          * Allocate the appropriate front-end.  Note that utf8, ascii           * Allocate the appropriate front-end.  Note that utf8, latin1
          * and latin1 all resolve to the terminal front-end with           * (both not yet implemented) and ascii all resolve to the
          * different encodings (see terminal.c).  Not all frontends have           * terminal front-end with different encodings (see terminal.c).
          * cleanup or alloc routines.           * Not all frontends have cleanup or alloc routines.
          */           */
   
         switch (outtype) {          switch (outtype) {
         case (OUTT_LATIN1):  
                 outdata = latin1_alloc();  
                 outrun = terminal_run;  
                 outfree = terminal_free;  
                 break;  
         case (OUTT_UTF8):  
                 outdata = utf8_alloc();  
                 outrun = terminal_run;  
                 outfree = terminal_free;  
                 break;  
         case (OUTT_TREE):          case (OUTT_TREE):
                 outdata = NULL;                  outdata = NULL;
                 outrun = tree_run;                  outrun = tree_run;
Line 204  main(int argc, char *argv[])
Line 191  main(int argc, char *argv[])
         mancb.man_err = merr;          mancb.man_err = merr;
         mancb.man_warn = manwarn;          mancb.man_warn = manwarn;
   
           /* Configure buffers. */
   
         bzero(&ln, sizeof(struct buf));          bzero(&ln, sizeof(struct buf));
         bzero(&blk, sizeof(struct buf));          bzero(&blk, sizeof(struct buf));
   
Line 211  main(int argc, char *argv[])
Line 200  main(int argc, char *argv[])
         mdoc = NULL;          mdoc = NULL;
         pflags = 0;          pflags = 0;
   
           /*
            * Allocate the parser.  There are two kinds of parser: libman
            * and libmdoc.  We must separately copy over the flags that
            * we'll use internally.
            */
   
         switch (inttype) {          switch (inttype) {
         case (INTT_MAN):          case (INTT_MAN):
                 if (fflags & IGN_MACRO)                  if (fflags & IGN_MACRO)
                         pflags |= MAN_IGN_MACRO;                          pflags |= MAN_IGN_MACRO;
   
                 man = man_alloc(&curp, pflags, &mancb);                  man = man_alloc(&curp, pflags, &mancb);
                 break;                  break;
         default:          default:
Line 225  main(int argc, char *argv[])
Line 219  main(int argc, char *argv[])
                         pflags |= MDOC_IGN_ESCAPE;                          pflags |= MDOC_IGN_ESCAPE;
                 if (fflags & IGN_MACRO)                  if (fflags & IGN_MACRO)
                         pflags |= MDOC_IGN_MACRO;                          pflags |= MDOC_IGN_MACRO;
   
                 mdoc = mdoc_alloc(&curp, pflags, &mdoccb);                  mdoc = mdoc_alloc(&curp, pflags, &mdoccb);
                 break;                  break;
         }          }
   
         /*          /*
          * Loop around available files.           * Main loop around available files.
          */           */
   
         if (NULL == *argv) {          if (NULL == *argv) {
                 curp.file = "<stdin>";                  curp.file = "<stdin>";
                 rc = 0;                  rc = 0;
                 c = fdesc(&blk, &ln, "stdin",                  c = fdesc(&blk, &ln, "stdin", STDIN_FILENO, man, mdoc);
                                 STDIN_FILENO, man, mdoc);  
   
                 if (c && NULL == outrun)                  if (c && NULL == outrun)
                         rc = 1;                          rc = 1;
Line 256  main(int argc, char *argv[])
Line 248  main(int argc, char *argv[])
                                 man_reset(man);                                  man_reset(man);
                         if (mdoc)                          if (mdoc)
                                 mdoc_reset(mdoc);                                  mdoc_reset(mdoc);
   
                         argv++;                          argv++;
                 }                  }
                 rc = NULL == *argv;                  rc = NULL == *argv;
Line 429  toptions(enum outt *tflags, char *arg)
Line 420  toptions(enum outt *tflags, char *arg)
   
         if (0 == strcmp(arg, "ascii"))          if (0 == strcmp(arg, "ascii"))
                 *tflags = OUTT_ASCII;                  *tflags = OUTT_ASCII;
         else if (0 == strcmp(arg, "latin1"))  
                 *tflags = OUTT_LATIN1;  
         else if (0 == strcmp(arg, "utf8"))  
                 *tflags = OUTT_UTF8;  
         else if (0 == strcmp(arg, "lint"))          else if (0 == strcmp(arg, "lint"))
                 *tflags = OUTT_LINT;                  *tflags = OUTT_LINT;
         else if (0 == strcmp(arg, "tree"))          else if (0 == strcmp(arg, "tree"))

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

CVSweb