=================================================================== RCS file: /cvs/mandoc/read.c,v retrieving revision 1.83 retrieving revision 1.90 diff -u -p -r1.83 -r1.90 --- mandoc/read.c 2014/09/06 22:39:36 1.83 +++ mandoc/read.c 2014/10/12 19:31:41 1.90 @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.83 2014/09/06 22:39:36 schwarze Exp $ */ +/* $Id: read.c,v 1.90 2014/10/12 19:31:41 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -69,9 +69,9 @@ struct mparse { int line; /* line number in the file */ }; +static void choose_parser(struct mparse *); static void resize_buf(struct buf *, size_t); static void mparse_buf_r(struct mparse *, struct buf, int); -static void pset(const char *, int, struct mparse *); static int read_whole_file(struct mparse *, const char *, int, struct buf *, int *); static void mparse_end(struct mparse *); @@ -117,6 +117,9 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "sections out of conventional order", "duplicate section title", "unexpected section", + "unusual Xr order", + "unusual Xr punctuation", + "AUTHORS section without An macro", /* related to macros and nesting */ "obsolete macro", @@ -146,6 +149,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "missing font type, using \\fR", "unknown font type, using \\fR", "missing -std argument, adding it", + "missing eqn box, using \"\"", /* related to bad macro arguments */ "unterminated quoted argument", @@ -155,6 +159,8 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "skipping duplicate list type", "skipping -width argument", "unknown AT&T UNIX version", + "comma in function argument", + "parenthesis in function name", "invalid content in Rs block", "invalid Boolean argument", "unknown font, skipping request", @@ -174,7 +180,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "equation scope open on exit", "overlapping equation scopes", "unexpected end of equation", - "equation syntax error", /* related to tables */ "bad table syntax", @@ -247,20 +252,11 @@ resize_buf(struct buf *buf, size_t initial) } static void -pset(const char *buf, int pos, struct mparse *curp) +choose_parser(struct mparse *curp) { char *cp, *ep; int format; - int i; - if ('.' == buf[0] || '\'' == buf[0]) { - for (i = 1; buf[i]; i++) - if (' ' != buf[i] && '\t' != buf[i]) - break; - if ('\0' == buf[i]) - return; - } - /* * If neither command line arguments -mdoc or -man select * a parser nor the roff parser found a .Dd or .TH macro @@ -271,7 +267,7 @@ pset(const char *buf, int pos, struct mparse *curp) cp = curp->primary->buf; ep = cp + curp->primary->sz; while (cp < ep) { - if (*cp == '.' || *cp != '\'') { + if (*cp == '.' || *cp == '\'') { cp++; if (cp[0] == 'D' && cp[1] == 'd') { format = MPARSE_MDOC; @@ -550,12 +546,10 @@ rerun: */ if ( ! (curp->man || curp->mdoc)) - pset(ln.buf + of, pos - of, curp); + choose_parser(curp); /* - * Lastly, push down into the parsers themselves. One - * of these will have already been set in the pset() - * routine. + * Lastly, push down into the parsers themselves. * If libroff returns ROFF_TBL, then add it to the * currently open parse. Since we only get here if * there does exist data (see tbl_data.c), we're @@ -723,6 +717,7 @@ mparse_end(struct mparse *curp) static void mparse_parse_buffer(struct mparse *curp, struct buf blk, const char *file) { + struct buf *svprimary; const char *svfile; static int recursion_depth; @@ -734,6 +729,7 @@ mparse_parse_buffer(struct mparse *curp, struct buf bl /* Line number is per-file. */ svfile = curp->file; curp->file = file; + svprimary = curp->primary; curp->primary = &blk; curp->line = 1; recursion_depth++; @@ -743,6 +739,7 @@ mparse_parse_buffer(struct mparse *curp, struct buf bl if (0 == --recursion_depth && MANDOCLEVEL_FATAL > curp->file_status) mparse_end(curp); + curp->primary = svprimary; curp->file = svfile; }