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

Diff for /mandoc/main.c between version 1.94 and 1.102

version 1.94, 2010/06/30 20:32:15 version 1.102, 2010/08/08 14:45:59
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
    * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * 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 22 
Line 23 
 #include <sys/stat.h>  #include <sys/stat.h>
   
 #include <assert.h>  #include <assert.h>
   #include <ctype.h>
 #include <fcntl.h>  #include <fcntl.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdint.h>  #include <stdint.h>
Line 30 
Line 32 
 #include <unistd.h>  #include <unistd.h>
   
 #include "mandoc.h"  #include "mandoc.h"
 #include "regs.h"  
 #include "main.h"  #include "main.h"
 #include "mdoc.h"  #include "mdoc.h"
 #include "man.h"  #include "man.h"
 #include "roff.h"  #include "roff.h"
   
   #ifndef MAP_FILE
   #define MAP_FILE        0
   #endif
   
 #define UNCONST(a)      ((void *)(uintptr_t)(const void *)(a))  #define UNCONST(a)      ((void *)(uintptr_t)(const void *)(a))
   
 /* FIXME: Intel's compiler?  LLVM?  pcc?  */  /* FIXME: Intel's compiler?  LLVM?  pcc?  */
Line 67  enum outt {
Line 72  enum outt {
         OUTT_HTML,          OUTT_HTML,
         OUTT_XHTML,          OUTT_XHTML,
         OUTT_LINT,          OUTT_LINT,
         OUTT_PS          OUTT_PS,
           OUTT_PDF
 };  };
   
 struct  curparse {  struct  curparse {
Line 110  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 116  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "list type must come first",          "list type must come first",
         "bad standard",          "bad standard",
         "bad library",          "bad library",
           "tab in non-literal context",
         "bad escape sequence",          "bad escape sequence",
         "unterminated quoted string",          "unterminated quoted string",
         "argument requires the width argument",          "argument requires the width argument",
Line 120  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 127  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "unknown manual section",          "unknown manual section",
         "section not in conventional manual section",          "section not in conventional manual section",
         "end of line whitespace",          "end of line whitespace",
           "blocks badly nested",
         "scope open on exit",          "scope open on exit",
   
         "generic error",          "generic error",
Line 143  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 151  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "bad comment style",          "bad comment style",
         "unknown macro will be lost",          "unknown macro will be lost",
         "line scope broken",          "line scope broken",
         "scope broken",  
         "argument count wrong",          "argument count wrong",
         "request scope close w/none open",          "request scope close w/none open",
         "scope already open",          "scope already open",
Line 153  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 160  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "no title in document",          "no title in document",
         "missing list type",          "missing list type",
         "missing display type",          "missing display type",
           "missing font 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",
   
         "generic fatal error",          "generic fatal error",
   
         "column syntax is inconsistent",          "column syntax is inconsistent",
         "missing font type",  
         "displays may not be nested",          "displays may not be nested",
         "unsupported display type",          "unsupported display type",
         "no scope to rewind: syntax violated",          "blocks badly nested",
           "no such block is open",
         "scope broken, syntax violated",          "scope broken, syntax violated",
         "line scope broken, syntax violated",          "line scope broken, syntax violated",
         "argument count wrong, violates syntax",          "argument count wrong, violates syntax",
Line 458  fdesc(struct curparse *curp)
Line 466  fdesc(struct curparse *curp)
         struct buf       ln, blk;          struct buf       ln, blk;
         int              i, pos, lnn, lnn_start, with_mmap, of;          int              i, pos, lnn, lnn_start, with_mmap, of;
         enum rofferr     re;          enum rofferr     re;
           unsigned char    c;
         struct man      *man;          struct man      *man;
         struct mdoc     *mdoc;          struct mdoc     *mdoc;
         struct roff     *roff;          struct roff     *roff;
Line 490  fdesc(struct curparse *curp)
Line 499  fdesc(struct curparse *curp)
                                 ++lnn;                                  ++lnn;
                                 break;                                  break;
                         }                          }
   
                           /*
                            * Warn about bogus characters.  If you're using
                            * non-ASCII encoding, you're screwing your
                            * readers.  Since I'd rather this not happen,
                            * I'll be helpful and drop these characters so
                            * we don't display gibberish.  Note to manual
                            * writers: use special characters.
                            */
   
                           c = (unsigned char) blk.buf[i];
                           if ( ! (isascii(c) && (isgraph(c) || isblank(c)))) {
                                   if ( ! mmsg(MANDOCERR_BADCHAR, curp,
                                                   lnn_start, pos,
                                                   "ignoring byte"))
                                           goto bailout;
                                   i++;
                                   continue;
                           }
   
                         /* Trailing backslash is like a plain character. */                          /* Trailing backslash is like a plain character. */
                         if ('\\' != blk.buf[i] || i + 1 == (int)blk.sz) {                          if ('\\' != blk.buf[i] || i + 1 == (int)blk.sz) {
                                 if (pos >= (int)ln.sz)                                  if (pos >= (int)ln.sz)
Line 607  fdesc(struct curparse *curp)
Line 636  fdesc(struct curparse *curp)
                         curp->outdata = ascii_alloc(curp->outopts);                          curp->outdata = ascii_alloc(curp->outopts);
                         curp->outfree = ascii_free;                          curp->outfree = ascii_free;
                         break;                          break;
                   case (OUTT_PDF):
                           curp->outdata = pdf_alloc(curp->outopts);
                           curp->outfree = pspdf_free;
                           break;
                 case (OUTT_PS):                  case (OUTT_PS):
                         curp->outdata = ps_alloc(curp->outopts);                          curp->outdata = ps_alloc(curp->outopts);
                         curp->outfree = ps_free;                          curp->outfree = pspdf_free;
                         break;                          break;
                 default:                  default:
                         break;                          break;
Line 627  fdesc(struct curparse *curp)
Line 660  fdesc(struct curparse *curp)
                         curp->outman = tree_man;                          curp->outman = tree_man;
                         curp->outmdoc = tree_mdoc;                          curp->outmdoc = tree_mdoc;
                         break;                          break;
                   case (OUTT_PDF):
                           /* FALLTHROUGH */
                 case (OUTT_ASCII):                  case (OUTT_ASCII):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (OUTT_PS):                  case (OUTT_PS):
Line 761  toptions(struct curparse *curp, char *arg)
Line 796  toptions(struct curparse *curp, char *arg)
                 curp->outtype = OUTT_XHTML;                  curp->outtype = OUTT_XHTML;
         else if (0 == strcmp(arg, "ps"))          else if (0 == strcmp(arg, "ps"))
                 curp->outtype = OUTT_PS;                  curp->outtype = OUTT_PS;
           else if (0 == strcmp(arg, "pdf"))
                   curp->outtype = OUTT_PDF;
         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.94  
changed lines
  Added in v.1.102

CVSweb