aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-12-16 23:44:41 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-12-16 23:44:41 +0000
commitda9096c534bd288ffa8acf2aea3a0611c1c6ecd2 (patch)
treec4d913599e6e814d9238954054fe576357878a85 /roff.c
parent24ce5dc84ac4a240d9f02f32b4a1bd3972e74d10 (diff)
downloadmandoc-da9096c534bd288ffa8acf2aea3a0611c1c6ecd2.tar.gz
mandoc-da9096c534bd288ffa8acf2aea3a0611c1c6ecd2.tar.zst
mandoc-da9096c534bd288ffa8acf2aea3a0611c1c6ecd2.zip
Ignore mdoc(7) and man(7) macros inside tbl(7) code because they
would abort the table in an unclean way, causing assertion failures found by jsg@.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/roff.c b/roff.c
index 099f7503..d2b2d85b 100644
--- a/roff.c
+++ b/roff.c
@@ -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 <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -730,6 +730,7 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, int *offs)
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,15 +801,29 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, int *offs)
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));
}