version 1.142, 2015/10/06 18:32:19 |
version 1.144, 2015/10/13 22:59:54 |
|
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <stdarg.h> |
#include <stdarg.h> |
|
|
struct mparse { |
struct mparse { |
struct roff_man *man; /* man parser */ |
struct roff_man *man; /* man parser */ |
struct roff *roff; /* roff parser (!NULL) */ |
struct roff *roff; /* roff parser (!NULL) */ |
const struct mchars *mchars; /* character table */ |
|
char *sodest; /* filename pointed to by .so */ |
char *sodest; /* filename pointed to by .so */ |
const char *file; /* filename of current input file */ |
const char *file; /* filename of current input file */ |
struct buf *primary; /* buffer currently being parsed */ |
struct buf *primary; /* buffer currently being parsed */ |
Line 612 read_whole_file(struct mparse *curp, const char *file, |
|
Line 612 read_whole_file(struct mparse *curp, const char *file, |
|
|
|
#if HAVE_MMAP |
#if HAVE_MMAP |
struct stat st; |
struct stat st; |
if (-1 == fstat(fd, &st)) { |
|
perror(file); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
|
|
|
if (fstat(fd, &st) == -1) |
|
err((int)MANDOCLEVEL_SYSERR, "%s", file); |
|
|
/* |
/* |
* If we're a regular file, try just reading in the whole entry |
* If we're a regular file, try just reading in the whole entry |
* via mmap(). This is faster than reading it into blocks, and |
* via mmap(). This is faster than reading it into blocks, and |
Line 638 read_whole_file(struct mparse *curp, const char *file, |
|
Line 637 read_whole_file(struct mparse *curp, const char *file, |
|
#endif |
#endif |
|
|
if (curp->gzip) { |
if (curp->gzip) { |
if ((gz = gzdopen(fd, "rb")) == NULL) { |
if ((gz = gzdopen(fd, "rb")) == NULL) |
perror(file); |
err((int)MANDOCLEVEL_SYSERR, "%s", file); |
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
} else |
} else |
gz = NULL; |
gz = NULL; |
|
|
Line 670 read_whole_file(struct mparse *curp, const char *file, |
|
Line 667 read_whole_file(struct mparse *curp, const char *file, |
|
fb->sz = off; |
fb->sz = off; |
return 1; |
return 1; |
} |
} |
if (ssz == -1) { |
if (ssz == -1) |
perror(file); |
err((int)MANDOCLEVEL_SYSERR, "%s", file); |
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
off += (size_t)ssz; |
off += (size_t)ssz; |
} |
} |
|
|
Line 819 mparse_open(struct mparse *curp, int *fd, const char * |
|
Line 814 mparse_open(struct mparse *curp, int *fd, const char * |
|
|
|
struct mparse * |
struct mparse * |
mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg, |
mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg, |
const struct mchars *mchars, const char *defos) |
const char *defos) |
{ |
{ |
struct mparse *curp; |
struct mparse *curp; |
|
|
Line 830 mparse_alloc(int options, enum mandoclevel wlevel, man |
|
Line 825 mparse_alloc(int options, enum mandoclevel wlevel, man |
|
curp->mmsg = mmsg; |
curp->mmsg = mmsg; |
curp->defos = defos; |
curp->defos = defos; |
|
|
curp->mchars = mchars; |
curp->roff = roff_alloc(curp, options); |
curp->roff = roff_alloc(curp, curp->mchars, options); |
|
curp->man = roff_man_alloc( curp->roff, curp, curp->defos, |
curp->man = roff_man_alloc( curp->roff, curp, curp->defos, |
curp->options & MPARSE_QUICK ? 1 : 0); |
curp->options & MPARSE_QUICK ? 1 : 0); |
if (curp->options & MPARSE_MDOC) { |
if (curp->options & MPARSE_MDOC) { |