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

Diff for /mandoc/main.c between version 1.84 and 1.91

version 1.84, 2010/06/07 10:52:44 version 1.91, 2010/06/26 15:36:37
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>   * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 30 
Line 30 
 #include <unistd.h>  #include <unistd.h>
   
 #include "mandoc.h"  #include "mandoc.h"
   #include "regs.h"
   #include "main.h"
 #include "mdoc.h"  #include "mdoc.h"
 #include "man.h"  #include "man.h"
 #include "roff.h"  #include "roff.h"
 #include "main.h"  
   
 #define UNCONST(a)      ((void *)(uintptr_t)(const void *)(a))  #define UNCONST(a)      ((void *)(uintptr_t)(const void *)(a))
   
Line 65  enum outt {
Line 66  enum outt {
         OUTT_TREE,          OUTT_TREE,
         OUTT_HTML,          OUTT_HTML,
         OUTT_XHTML,          OUTT_XHTML,
         OUTT_LINT          OUTT_LINT,
           OUTT_PS
 };  };
   
 struct  curparse {  struct  curparse {
Line 108  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 110  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "unterminated quoted string",          "unterminated quoted string",
         "argument requires the width argument",          "argument requires the width argument",
         "superfluous width argument",          "superfluous width argument",
           "ignoring argument",
         "bad date argument",          "bad date argument",
         "bad width argument",          "bad width argument",
         "unknown manual section",          "unknown manual section",
Line 142  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 145  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "macro requires argument(s)",          "macro requires argument(s)",
         "no title in document",          "no title in document",
         "missing list type",          "missing list type",
           "missing display type",
         "line argument(s) will be lost",          "line argument(s) will be lost",
         "body argument(s) will be lost",          "body argument(s) will be lost",
         "column syntax is inconsistent",          "column syntax is inconsistent",
         "missing font type",          "missing font type",
         "missing display type",  
         "displays may not be nested",          "displays may not be nested",
           "unsupported display type",
         "no scope to rewind: syntax violated",          "no scope to rewind: syntax violated",
         "scope broken, syntax violated",          "scope broken, syntax violated",
         "line scope broken, syntax violated",          "line scope broken, syntax violated",
Line 447  fdesc(struct curparse *curp)
Line 451  fdesc(struct curparse *curp)
         struct man      *man;          struct man      *man;
         struct mdoc     *mdoc;          struct mdoc     *mdoc;
         struct roff     *roff;          struct roff     *roff;
           struct regset    regs;
   
         man = NULL;          man = NULL;
         mdoc = NULL;          mdoc = NULL;
         roff = NULL;          roff = NULL;
         memset(&ln, 0, sizeof(struct buf));          memset(&ln, 0, sizeof(struct buf));
           memset(&regs, 0, sizeof(struct regset));
   
         /*          /*
          * Two buffers: ln and buf.  buf is the input file and may be           * Two buffers: ln and buf.  buf is the input file and may be
Line 534  fdesc(struct curparse *curp)
Line 540  fdesc(struct curparse *curp)
   
                 of = 0;                  of = 0;
                 do {                  do {
                         re = roff_parseln(roff, lnn_start,                          re = roff_parseln(roff, &regs, lnn_start,
                                         &ln.buf, &ln.sz, of, &of);                                          &ln.buf, &ln.sz, of, &of);
                 } while (ROFF_RERUN == re);                  } while (ROFF_RERUN == re);
   
Line 556  fdesc(struct curparse *curp)
Line 562  fdesc(struct curparse *curp)
   
                 /* Lastly, push down into the parsers themselves. */                  /* Lastly, push down into the parsers themselves. */
   
                 if (man && ! man_parseln(man, lnn_start, ln.buf, of))                  if (man && ! man_parseln(man, &regs, lnn_start, ln.buf, of))
                         goto bailout;                          goto bailout;
                 if (mdoc && ! mdoc_parseln(mdoc, lnn_start, ln.buf, of))                  if (mdoc && ! mdoc_parseln(mdoc, &regs, lnn_start, ln.buf, of))
                         goto bailout;                          goto bailout;
         }          }
   
Line 584  fdesc(struct curparse *curp)
Line 590  fdesc(struct curparse *curp)
                 switch (curp->outtype) {                  switch (curp->outtype) {
                 case (OUTT_XHTML):                  case (OUTT_XHTML):
                         curp->outdata = xhtml_alloc(curp->outopts);                          curp->outdata = xhtml_alloc(curp->outopts);
                         curp->outman = html_man;  
                         curp->outmdoc = html_mdoc;  
                         curp->outfree = html_free;  
                         break;                          break;
                 case (OUTT_HTML):                  case (OUTT_HTML):
                         curp->outdata = html_alloc(curp->outopts);                          curp->outdata = html_alloc(curp->outopts);
                           break;
                   case (OUTT_ASCII):
                           curp->outdata = ascii_alloc(curp->outopts);
                           curp->outfree = ascii_free;
                           break;
                   case (OUTT_PS):
                           curp->outdata = ps_alloc();
                           curp->outfree = ps_free;
                           break;
                   default:
                           break;
                   }
   
                   switch (curp->outtype) {
                   case (OUTT_HTML):
                           /* FALLTHROUGH */
                   case (OUTT_XHTML):
                         curp->outman = html_man;                          curp->outman = html_man;
                         curp->outmdoc = html_mdoc;                          curp->outmdoc = html_mdoc;
                         curp->outfree = html_free;                          curp->outfree = html_free;
Line 598  fdesc(struct curparse *curp)
Line 618  fdesc(struct curparse *curp)
                         curp->outman = tree_man;                          curp->outman = tree_man;
                         curp->outmdoc = tree_mdoc;                          curp->outmdoc = tree_mdoc;
                         break;                          break;
                 case (OUTT_LINT):                  case (OUTT_ASCII):
                         break;                          /* FALLTHROUGH */
                 default:                  case (OUTT_PS):
                         curp->outdata = ascii_alloc(curp->outopts);  
                         curp->outman = terminal_man;                          curp->outman = terminal_man;
                         curp->outmdoc = terminal_mdoc;                          curp->outmdoc = terminal_mdoc;
                         curp->outfree = terminal_free;  
                         break;                          break;
                   default:
                           break;
                 }                  }
         }          }
   
Line 729  toptions(struct curparse *curp, char *arg)
Line 749  toptions(struct curparse *curp, char *arg)
                 curp->outtype = OUTT_HTML;                  curp->outtype = OUTT_HTML;
         else if (0 == strcmp(arg, "xhtml"))          else if (0 == strcmp(arg, "xhtml"))
                 curp->outtype = OUTT_XHTML;                  curp->outtype = OUTT_XHTML;
           else if (0 == strcmp(arg, "ps"))
                   curp->outtype = OUTT_PS;
         else {          else {
                 fprintf(stderr, "%s: Bad argument\n", arg);                  fprintf(stderr, "%s: Bad argument\n", arg);
                 return(0);                  return(0);

Legend:
Removed from v.1.84  
changed lines
  Added in v.1.91

CVSweb