diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-01-28 15:03:45 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-01-28 15:03:45 +0000 |
commit | b8a3bef0831e00e2921ed5feb59338efcca0984d (patch) | |
tree | ff08f642c8b68a7908a923cd1e512ab4cdfee54e | |
parent | 3a4b4e867c202716bfdde346a8fe008f2a6edd3a (diff) | |
download | mandoc-b8a3bef0831e00e2921ed5feb59338efcca0984d.tar.gz |
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-- | libroff.h | 10 | ||||
-rw-r--r-- | roff.c | 8 | ||||
-rw-r--r-- | tbl.c | 14 | ||||
-rw-r--r-- | tbl_data.c | 9 | ||||
-rw-r--r-- | tbl_layout.c | 5 | ||||
-rw-r--r-- | tbl_opts.c | 8 |
6 files changed, 27 insertions, 27 deletions
@@ -1,7 +1,7 @@ /* $Id$ */ /* * 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 *); @@ -1237,7 +1237,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)); } /* @@ -32,7 +32,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; @@ -46,7 +46,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; @@ -64,8 +64,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); } } @@ -74,15 +74,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); } @@ -138,13 +138,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; @@ -204,11 +201,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 @@ -259,7 +255,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/tbl_layout.c b/tbl_layout.c index adf728aa..52d2ed5e 100644 --- a/tbl_layout.c +++ b/tbl_layout.c @@ -234,14 +234,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. */ @@ -120,17 +120,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. */ |