diff options
author | 2015-01-28 15:02:25 +0000 | |
---|---|---|
committer | 2015-01-28 15:02:25 +0000 | |
commit | 39aede77f0abc4e5d3500cced9821df461deab15 (patch) | |
tree | a1271296230107a01b73db79856ece6b58dab49e | |
parent | sync (diff) | |
download | wireguard-openbsd-39aede77f0abc4e5d3500cced9821df461deab15.tar.xz wireguard-openbsd-39aede77f0abc4e5d3500cced9821df461deab15.zip |
For now, it can't be helped that mandoc tbl(7) ignores high-level macros,
but stop throwing away their arguments. This fixes information loss in a
handful of Xenocara manuals, at the price of a small amount of formatting
noise creeping through.
-rw-r--r-- | regress/usr.bin/mandoc/tbl/macro.in | 3 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/tbl/macro.out_lint | 2 | ||||
-rw-r--r-- | usr.bin/mandoc/libroff.h | 12 | ||||
-rw-r--r-- | usr.bin/mandoc/roff.c | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl.c | 16 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_data.c | 11 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_layout.c | 7 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_opts.c | 10 |
8 files changed, 35 insertions, 36 deletions
diff --git a/regress/usr.bin/mandoc/tbl/macro.in b/regress/usr.bin/mandoc/tbl/macro.in index f97907d87ae..07ba2456ea3 100644 --- a/regress/usr.bin/mandoc/tbl/macro.in +++ b/regress/usr.bin/mandoc/tbl/macro.in @@ -8,8 +8,7 @@ box tab(:); l | l . a:b _ -.PD 1 -c:d +.R c:d .TE .PP normal text diff --git a/regress/usr.bin/mandoc/tbl/macro.out_lint b/regress/usr.bin/mandoc/tbl/macro.out_lint index ba4eea35cdd..b2c7a8b3023 100644 --- a/regress/usr.bin/mandoc/tbl/macro.out_lint +++ b/regress/usr.bin/mandoc/tbl/macro.out_lint @@ -1 +1 @@ -mandoc: macro.in:11:2: UNSUPP: ignoring macro in table: PD 1 +mandoc: macro.in:11:2: UNSUPP: ignoring macro in table: R c:d diff --git a/usr.bin/mandoc/libroff.h b/usr.bin/mandoc/libroff.h index cd51b20f35c..f9b3896e36f 100644 --- a/usr.bin/mandoc/libroff.h +++ b/usr.bin/mandoc/libroff.h @@ -1,7 +1,7 @@ -/* $OpenBSD: libroff.h,v 1.13 2015/01/21 00:45:16 schwarze Exp $ */ +/* $OpenBSD: libroff.h,v 1.14 2015/01/28 15:02:25 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -69,10 +69,10 @@ void tbl_restart(int, int, struct tbl_node *); void tbl_free(struct tbl_node *); void tbl_reset(struct tbl_node *); enum rofferr tbl_read(struct tbl_node *, int, const char *, int); -void tbl_option(struct tbl_node *, int, const char *); -void tbl_layout(struct tbl_node *, int, const char *); -void tbl_data(struct tbl_node *, int, const char *); -int tbl_cdata(struct tbl_node *, int, const char *); +void tbl_option(struct tbl_node *, int, const char *, int *); +void tbl_layout(struct tbl_node *, int, const char *, int); +void tbl_data(struct tbl_node *, int, const char *, int); +int tbl_cdata(struct tbl_node *, int, const char *, int); const struct tbl_span *tbl_span(struct tbl_node *); void tbl_end(struct tbl_node **); struct eqn_node *eqn_alloc(int, int, struct mparse *); diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index b3993732c4e..53cb633b4e0 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.128 2015/01/24 02:41:32 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.129 2015/01/28 15:02:25 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -1235,7 +1235,13 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, int *offs) if (r->tbl != NULL && (t == ROFF_MAX || t == ROFF_TS)) { mandoc_msg(MANDOCERR_TBLMACRO, r->parse, ln, pos, buf->buf + spos); - return(ROFF_IGN); + if (t == ROFF_TS) + return(ROFF_IGN); + while (buf->buf[pos] != '\0' && buf->buf[pos] != ' ') + pos++; + while (buf->buf[pos] != '\0' && buf->buf[pos] == ' ') + pos++; + return(tbl_read(r->tbl, ln, buf->buf, pos)); } /* diff --git a/usr.bin/mandoc/tbl.c b/usr.bin/mandoc/tbl.c index df250c19798..93827c8a529 100644 --- a/usr.bin/mandoc/tbl.c +++ b/usr.bin/mandoc/tbl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl.c,v 1.15 2015/01/27 05:20:30 schwarze Exp $ */ +/* $OpenBSD: tbl.c,v 1.16 2015/01/28 15:02:25 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -30,7 +30,7 @@ enum rofferr -tbl_read(struct tbl_node *tbl, int ln, const char *p, int offs) +tbl_read(struct tbl_node *tbl, int ln, const char *p, int pos) { const char *cp; int active; @@ -44,7 +44,7 @@ tbl_read(struct tbl_node *tbl, int ln, const char *p, int offs) if (tbl->part == TBL_PART_OPTS) { tbl->part = TBL_PART_LAYOUT; active = 1; - for (cp = p; *cp != '\0'; cp++) { + for (cp = p + pos; *cp != '\0'; cp++) { switch (*cp) { case '(': active = 0; @@ -62,8 +62,8 @@ tbl_read(struct tbl_node *tbl, int ln, const char *p, int offs) break; } if (*cp == ';') { - tbl_option(tbl, ln, p); - if (*(p = cp + 1) == '\0') + tbl_option(tbl, ln, p, &pos); + if (p[pos] == '\0') return(ROFF_IGN); } } @@ -72,15 +72,15 @@ tbl_read(struct tbl_node *tbl, int ln, const char *p, int offs) switch (tbl->part) { case TBL_PART_LAYOUT: - tbl_layout(tbl, ln, p); + tbl_layout(tbl, ln, p, pos); return(ROFF_IGN); case TBL_PART_CDATA: - return(tbl_cdata(tbl, ln, p) ? ROFF_TBL : ROFF_IGN); + return(tbl_cdata(tbl, ln, p, pos) ? ROFF_TBL : ROFF_IGN); default: break; } - tbl_data(tbl, ln, p); + tbl_data(tbl, ln, p, pos); return(ROFF_TBL); } diff --git a/usr.bin/mandoc/tbl_data.c b/usr.bin/mandoc/tbl_data.c index d7dbc77ad83..463688c2ee0 100644 --- a/usr.bin/mandoc/tbl_data.c +++ b/usr.bin/mandoc/tbl_data.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_data.c,v 1.21 2015/01/27 05:20:30 schwarze Exp $ */ +/* $OpenBSD: tbl_data.c,v 1.22 2015/01/28 15:02:25 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -136,13 +136,10 @@ getdata(struct tbl_node *tbl, struct tbl_span *dp, } int -tbl_cdata(struct tbl_node *tbl, int ln, const char *p) +tbl_cdata(struct tbl_node *tbl, int ln, const char *p, int pos) { struct tbl_dat *dat; size_t sz; - int pos; - - pos = 0; dat = tbl->last_span->last; @@ -202,11 +199,10 @@ newspan(struct tbl_node *tbl, int line, struct tbl_row *rp) } void -tbl_data(struct tbl_node *tbl, int ln, const char *p) +tbl_data(struct tbl_node *tbl, int ln, const char *p, int pos) { struct tbl_span *dp; struct tbl_row *rp; - int pos; /* * Choose a layout row: take the one following the last parsed @@ -257,7 +253,6 @@ tbl_data(struct tbl_node *tbl, int ln, const char *p) dp->pos = TBL_SPAN_DATA; - pos = 0; while ('\0' != p[pos]) getdata(tbl, dp, ln, p, &pos); } diff --git a/usr.bin/mandoc/tbl_layout.c b/usr.bin/mandoc/tbl_layout.c index 59d21c2a45a..407f77199af 100644 --- a/usr.bin/mandoc/tbl_layout.c +++ b/usr.bin/mandoc/tbl_layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_layout.c,v 1.20 2015/01/27 05:20:30 schwarze Exp $ */ +/* $OpenBSD: tbl_layout.c,v 1.21 2015/01/28 15:02:25 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -232,14 +232,11 @@ again: } void -tbl_layout(struct tbl_node *tbl, int ln, const char *p) +tbl_layout(struct tbl_node *tbl, int ln, const char *p, int pos) { struct tbl_row *rp; - int pos; - pos = 0; rp = NULL; - for (;;) { /* Skip whitespace before and after each cell. */ diff --git a/usr.bin/mandoc/tbl_opts.c b/usr.bin/mandoc/tbl_opts.c index 5dab47f24b1..11b6592e66d 100644 --- a/usr.bin/mandoc/tbl_opts.c +++ b/usr.bin/mandoc/tbl_opts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_opts.c,v 1.10 2015/01/26 13:02:53 schwarze Exp $ */ +/* $OpenBSD: tbl_opts.c,v 1.11 2015/01/28 15:02:25 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -118,17 +118,19 @@ arg(struct tbl_node *tbl, int ln, const char *p, int *pos, int key) * and some options are followed by arguments. */ void -tbl_option(struct tbl_node *tbl, int ln, const char *p) +tbl_option(struct tbl_node *tbl, int ln, const char *p, int *offs) { int i, pos, len; - pos = 0; + pos = *offs; for (;;) { while (p[pos] == ' ' || p[pos] == '\t' || p[pos] == ',') pos++; - if (p[pos] == ';') + if (p[pos] == ';') { + *offs = pos + 1; return; + } /* Parse one option name. */ |