=================================================================== RCS file: /cvs/mandoc/read.c,v retrieving revision 1.9 retrieving revision 1.17 diff -u -p -r1.9 -r1.17 --- mandoc/read.c 2011/04/03 10:05:37 1.9 +++ mandoc/read.c 2011/07/17 14:08:49 1.17 @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.9 2011/04/03 10:05:37 kristaps Exp $ */ +/* $Id: read.c,v 1.17 2011/07/17 14:08:49 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -15,9 +15,15 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#ifdef HAVE_MMAP +# include +# include +#endif + #include #include #include @@ -138,11 +144,17 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "tab in non-literal context", "end of line whitespace", "bad comment style", - "unknown escape sequence", + "bad escape sequence", "unterminated quoted string", + + /* related to equations */ + "unexpected literal in equation", "generic error", + /* related to equations */ + "bad equation macro syntax", + /* related to tables */ "bad table syntax", "bad table option", @@ -350,7 +362,7 @@ mparse_buf_r(struct mparse *curp, struct buf blk, int continue; } - if ('"' == blk.buf[i + 1]) { + if ('"' == blk.buf[i + 1] || '#' == blk.buf[i + 1]) { i += 2; /* Comment, skip to end of line */ for (; i < (int)blk.sz; ++i) { @@ -441,7 +453,7 @@ rerun: /* * 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 * parsers with each one. */ @@ -525,19 +537,22 @@ pdesc(struct mparse *curp, const char *file, int fd) mparse_buf_r(curp, blk, 1); +#ifdef HAVE_MMAP if (with_mmap) munmap(blk.buf, blk.sz); else +#endif free(blk.buf); } static int read_whole_file(const char *file, int fd, struct buf *fb, int *with_mmap) { - struct stat st; size_t off; ssize_t ssz; +#ifdef HAVE_MMAP + struct stat st; if (-1 == fstat(fd, &st)) { perror(file); return(0); @@ -562,6 +577,7 @@ read_whole_file(const char *file, int fd, struct buf * if (fb->buf != MAP_FAILED) return(1); } +#endif /* * If this isn't a regular file (like, say, stdin), then we must @@ -661,6 +677,8 @@ struct mparse * mparse_alloc(enum mparset inttype, enum mandoclevel wlevel, mandocmsg mmsg, void *arg) { struct mparse *curp; + + assert(wlevel <= MANDOCLEVEL_FATAL); curp = mandoc_calloc(1, sizeof(struct mparse));