=================================================================== RCS file: /cvs/mandoc/read.c,v retrieving revision 1.150.2.8 retrieving revision 1.151 diff -u -p -r1.150.2.8 -r1.151 --- mandoc/read.c 2017/02/18 17:33:24 1.150.2.8 +++ mandoc/read.c 2016/07/19 21:31:55 1.151 @@ -1,7 +1,7 @@ -/* $Id: read.c,v 1.150.2.8 2017/02/18 17:33:24 schwarze Exp $ */ +/* $Id: read.c,v 1.151 2016/07/19 21:31:55 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010-2017 Ingo Schwarze + * Copyright (c) 2010-2016 Ingo Schwarze * Copyright (c) 2010, 2012 Joerg Sonnenberger * * Permission to use, copy, modify, and distribute this software for any @@ -19,10 +19,8 @@ #include "config.h" #include -#if HAVE_MMAP #include #include -#endif #include #include @@ -32,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -49,8 +48,8 @@ #define REPARSE_LIMIT 1000 struct mparse { - struct roff *roff; /* roff parser (!NULL) */ struct roff_man *man; /* man parser */ + struct roff *roff; /* roff parser (!NULL) */ char *sodest; /* filename pointed to by .so */ const char *file; /* filename of current input file */ struct buf *primary; /* buffer currently being parsed */ @@ -109,11 +108,10 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "no document body", "content before first section header", "first section is not \"NAME\"", - "NAME section without Nm before Nd", + "NAME section without name", "NAME section without description", "description not at the end of NAME", "bad NAME section content", - "missing comma before name", "missing description line, using \"\"", "sections out of conventional order", "duplicate section title", @@ -143,7 +141,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "empty argument, using 0n", "missing display type, using -ragged", "list type is not the first argument", - "missing -width in -tag list, using 6n", + "missing -width in -tag list, using 8n", "missing utility name, using \"\"", "missing function name, using \"\"", "empty head in list item", @@ -152,7 +150,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "unknown font type, using \\fR", "nothing follows prefix", "empty reference block", - "missing section argument", "missing -std argument, adding it", "missing option string, using \"\"", "missing resource identifier, using \"\"", @@ -178,7 +175,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "blank line in fill mode, using .sp", "tab in filled text", "whitespace at end of input line", - "new sentence, new line", "bad comment style", "invalid escape sequence", "undefined string, using \"\"", @@ -319,7 +315,6 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size const char *save_file; char *cp; size_t pos; /* byte number in the ln buffer */ - size_t j; /* auxiliary byte number in the blk buffer */ enum rofferr rr; int of; int lnn; /* line number in the real file */ @@ -425,21 +420,14 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size } if ('"' == blk.buf[i + 1] || '#' == blk.buf[i + 1]) { - j = i; i += 2; /* Comment, skip to end of line */ for (; i < blk.sz; ++i) { - if (blk.buf[i] != '\n') - continue; - if (blk.buf[i - 1] == ' ' || - blk.buf[i - 1] == '\t') - mandoc_msg( - MANDOCERR_SPACE_EOL, - curp, curp->line, - pos + i-1 - j, NULL); - ++i; - ++lnn; - break; + if ('\n' == blk.buf[i]) { + ++i; + ++lnn; + break; + } } /* Backout trailing whitespaces */ @@ -604,14 +592,12 @@ static int read_whole_file(struct mparse *curp, const char *file, int fd, struct buf *fb, int *with_mmap) { -#if HAVE_MMAP - struct stat st; -#endif gzFile gz; size_t off; ssize_t ssz; -#if HAVE_MMAP + struct stat st; + if (fstat(fd, &st) == -1) err((int)MANDOCLEVEL_SYSERR, "%s", file); @@ -633,7 +619,6 @@ read_whole_file(struct mparse *curp, const char *file, if (fb->buf != MAP_FAILED) return 1; } -#endif if (curp->gzip) { if ((gz = gzdopen(fd, "rb")) == NULL) @@ -758,11 +743,9 @@ mparse_readfd(struct mparse *curp, int fd, const char (MPARSE_UTF8 | MPARSE_LATIN1); mparse_parse_buffer(curp, blk, file); curp->filenc = save_filenc; -#if HAVE_MMAP if (with_mmap) munmap(blk.buf, blk.sz); else -#endif free(blk.buf); } return curp->file_status; @@ -836,15 +819,13 @@ mparse_reset(struct mparse *curp) { roff_reset(curp->roff); roff_man_reset(curp->man); - - free(curp->sodest); - curp->sodest = NULL; - if (curp->secondary) curp->secondary->sz = 0; curp->file_status = MANDOCLEVEL_OK; - curp->gzip = 0; + + free(curp->sodest); + curp->sodest = NULL; } void @@ -852,7 +833,8 @@ mparse_free(struct mparse *curp) { roff_man_free(curp->man); - roff_free(curp->roff); + if (curp->roff) + roff_free(curp->roff); if (curp->secondary) free(curp->secondary->buf); @@ -872,13 +854,6 @@ mparse_result(struct mparse *curp, struct roff_man **m } if (man) *man = curp->man; -} - -void -mparse_updaterc(struct mparse *curp, enum mandoclevel *rc) -{ - if (curp->file_status > *rc) - *rc = curp->file_status; } void