=================================================================== RCS file: /cvs/mandoc/read.c,v retrieving revision 1.161 retrieving revision 1.163 diff -u -p -r1.161 -r1.163 --- mandoc/read.c 2017/02/18 17:29:28 1.161 +++ mandoc/read.c 2017/03/07 20:00:08 1.163 @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.161 2017/02/18 17:29:28 schwarze Exp $ */ +/* $Id: read.c,v 1.163 2017/03/07 20:00:08 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -66,7 +66,7 @@ struct mparse { static void choose_parser(struct mparse *); static void resize_buf(struct buf *, size_t); -static void mparse_buf_r(struct mparse *, struct buf, size_t, int); +static int mparse_buf_r(struct mparse *, struct buf, size_t, int); static int read_whole_file(struct mparse *, const char *, int, struct buf *, int *); static void mparse_end(struct mparse *); @@ -113,6 +113,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "bad NAME section content", "missing comma before name", "missing description line, using \"\"", + "description line outside NAME section", "sections out of conventional order", "duplicate section title", "unexpected section", @@ -309,7 +310,7 @@ choose_parser(struct mparse *curp) * macros, inline equations, and input line traps) * and indirectly (for .so file inclusion). */ -static void +static int mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start) { const struct tbl_span *span; @@ -510,13 +511,16 @@ rerun: switch (rr) { case ROFF_REPARSE: - if (REPARSE_LIMIT >= ++curp->reparse_count) - mparse_buf_r(curp, ln, of, 0); - else + if (++curp->reparse_count > REPARSE_LIMIT) mandoc_msg(MANDOCERR_ROFFLOOP, curp, curp->line, pos, NULL); - pos = 0; - continue; + else if (mparse_buf_r(curp, ln, of, 0) == 1 || + start == 1) { + pos = 0; + continue; + } + free(ln.buf); + return 0; case ROFF_APPEND: pos = strlen(ln.buf); continue; @@ -530,7 +534,7 @@ rerun: (i >= blk.sz || blk.buf[i] == '\0')) { curp->sodest = mandoc_strdup(ln.buf + of); free(ln.buf); - return; + return 1; } /* * We remove `so' clauses from our lookaside @@ -596,6 +600,7 @@ rerun: } free(ln.buf); + return 1; } static int