aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-01-28 15:03:45 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-01-28 15:03:45 +0000
commit7793230177d864fb80c0c572a2b896f3ecb7df10 (patch)
tree9200fdac5fa9fae03f349e62032d6041b10d54d3
parentc49d930f6dcda366d67ac4b3bad9cc05ac3bc954 (diff)
downloadmandoc-7793230177d864fb80c0c572a2b896f3ecb7df10.tar.gz
mandoc-7793230177d864fb80c0c572a2b896f3ecb7df10.tar.zst
mandoc-7793230177d864fb80c0c572a2b896f3ecb7df10.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--libroff.h12
-rw-r--r--roff.c10
-rw-r--r--tbl.c16
-rw-r--r--tbl_data.c11
-rw-r--r--tbl_layout.c7
-rw-r--r--tbl_opts.c10
6 files changed, 33 insertions, 33 deletions
diff --git a/libroff.h b/libroff.h
index ca1bcf6f..be2890a5 100644
--- a/libroff.h
+++ b/libroff.h
@@ -1,7 +1,7 @@
-/* $Id: libroff.h,v 1.35 2015/01/21 00:47:04 schwarze Exp $ */
+/* $Id: libroff.h,v 1.36 2015/01/28 15:03:45 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/roff.c b/roff.c
index f940913b..7e1360e2 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.256 2015/01/24 02:41:49 schwarze Exp $ */
+/* $Id: roff.c,v 1.257 2015/01/28 15:03:45 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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));
}
/*
diff --git a/tbl.c b/tbl.c
index bd8fc99c..c183750f 100644
--- a/tbl.c
+++ b/tbl.c
@@ -1,4 +1,4 @@
-/* $Id: tbl.c,v 1.34 2015/01/27 05:21:45 schwarze Exp $ */
+/* $Id: tbl.c,v 1.35 2015/01/28 15:03:45 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
}
diff --git a/tbl_data.c b/tbl_data.c
index c237ac86..9ac2566c 100644
--- a/tbl_data.c
+++ b/tbl_data.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_data.c,v 1.34 2015/01/27 05:21:45 schwarze Exp $ */
+/* $Id: tbl_data.c,v 1.35 2015/01/28 15:03:45 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 4b34e74a..5a990765 100644
--- a/tbl_layout.c
+++ b/tbl_layout.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_layout.c,v 1.33 2015/01/27 05:21:45 schwarze Exp $ */
+/* $Id: tbl_layout.c,v 1.34 2015/01/28 15:03:45 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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. */
diff --git a/tbl_opts.c b/tbl_opts.c
index ae1df965..222c6e86 100644
--- a/tbl_opts.c
+++ b/tbl_opts.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_opts.c,v 1.18 2015/01/26 13:03:48 schwarze Exp $ */
+/* $Id: tbl_opts.c,v 1.19 2015/01/28 15:03:45 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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. */