=================================================================== RCS file: /cvs/mandoc/roff.c,v retrieving revision 1.242 retrieving revision 1.243 diff -u -p -r1.242 -r1.243 --- mandoc/roff.c 2014/12/16 03:53:43 1.242 +++ mandoc/roff.c 2014/12/16 23:44:41 1.243 @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.242 2014/12/16 03:53:43 schwarze Exp $ */ +/* $Id: roff.c,v 1.243 2014/12/16 23:44:41 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -730,6 +730,7 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, enum rofft t; enum rofferr e; int pos; /* parse point */ + int spos; /* saved parse point for messages */ int ppos; /* original offset in buf->buf */ int ctl; /* macro line (boolean) */ @@ -800,14 +801,28 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, return((*roffs[t].sub)(r, t, buf, ln, ppos, pos, offs)); } + /* No scope is open. This is a new request or macro. */ + + spos = pos; + t = roff_parse(r, buf->buf, &pos, ln, ppos); + + /* Tables ignore most macros. */ + + if (r->tbl != NULL && (t == ROFF_MAX || t == ROFF_TS)) { + mandoc_msg(MANDOCERR_TBLMACRO, r->parse, + ln, pos, buf->buf + spos); + return(ROFF_IGN); + } + /* - * Lastly, as we've no scope open, try to look up and execute - * the new macro. If no macro is found, simply return and let - * the compilers handle it. + * This is neither a roff request nor a user-defined macro. + * Let the standard macro set parsers handle it. */ - if ((t = roff_parse(r, buf->buf, &pos, ln, ppos)) == ROFF_MAX) + if (t == ROFF_MAX) return(ROFF_CONT); + + /* Execute a roff request or a user defined macro. */ assert(roffs[t].proc); return((*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs));