version 1.13, 2011/04/11 21:59:39 |
version 1.17, 2011/07/17 14:08:49 |
|
|
#include "config.h" |
#include "config.h" |
#endif |
#endif |
|
|
#include <sys/stat.h> |
#ifdef HAVE_MMAP |
#include <sys/mman.h> |
# include <sys/stat.h> |
|
# include <sys/mman.h> |
|
#endif |
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
Line 144 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
Line 146 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
"bad comment style", |
"bad comment style", |
"bad escape sequence", |
"bad escape sequence", |
"unterminated quoted string", |
"unterminated quoted string", |
|
|
|
/* related to equations */ |
|
"unexpected literal in equation", |
|
|
"generic error", |
"generic error", |
|
|
|
/* related to equations */ |
|
"bad equation macro syntax", |
|
|
/* related to tables */ |
/* related to tables */ |
"bad table syntax", |
"bad table syntax", |
"bad table option", |
"bad table option", |
|
|
|
|
/* |
/* |
* If input parsers have not been allocated, do so now. |
* If input parsers have not been allocated, do so now. |
* We keep these instanced betwen parsers, but set them |
* We keep these instanced between parsers, but set them |
* locally per parse routine since we can use different |
* locally per parse routine since we can use different |
* parsers with each one. |
* parsers with each one. |
*/ |
*/ |
Line 529 pdesc(struct mparse *curp, const char *file, int fd) |
|
Line 537 pdesc(struct mparse *curp, const char *file, int fd) |
|
|
|
mparse_buf_r(curp, blk, 1); |
mparse_buf_r(curp, blk, 1); |
|
|
|
#ifdef HAVE_MMAP |
if (with_mmap) |
if (with_mmap) |
munmap(blk.buf, blk.sz); |
munmap(blk.buf, blk.sz); |
else |
else |
|
#endif |
free(blk.buf); |
free(blk.buf); |
} |
} |
|
|
static int |
static int |
read_whole_file(const char *file, int fd, struct buf *fb, int *with_mmap) |
read_whole_file(const char *file, int fd, struct buf *fb, int *with_mmap) |
{ |
{ |
struct stat st; |
|
size_t off; |
size_t off; |
ssize_t ssz; |
ssize_t ssz; |
|
|
|
#ifdef HAVE_MMAP |
|
struct stat st; |
if (-1 == fstat(fd, &st)) { |
if (-1 == fstat(fd, &st)) { |
perror(file); |
perror(file); |
return(0); |
return(0); |
Line 566 read_whole_file(const char *file, int fd, struct buf * |
|
Line 577 read_whole_file(const char *file, int fd, struct buf * |
|
if (fb->buf != MAP_FAILED) |
if (fb->buf != MAP_FAILED) |
return(1); |
return(1); |
} |
} |
|
#endif |
|
|
/* |
/* |
* If this isn't a regular file (like, say, stdin), then we must |
* If this isn't a regular file (like, say, stdin), then we must |