summaryrefslogtreecommitdiffstats
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
commitb8a3bef0831e00e2921ed5feb59338efcca0984d (patch)
treeff08f642c8b68a7908a923cd1e512ab4cdfee54e
parent3a4b4e867c202716bfdde346a8fe008f2a6edd3a (diff)
downloadmandoc-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.h10
-rw-r--r--roff.c8
-rw-r--r--tbl.c14
-rw-r--r--tbl_data.c9
-rw-r--r--tbl_layout.c5
-rw-r--r--tbl_opts.c8
6 files changed, 27 insertions, 27 deletions
diff --git a/libroff.h b/libroff.h
index a56de1bf..9c2f00c7 100644
--- a/libroff.h
+++ b/libroff.h
@@ -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 *);
diff --git a/roff.c b/roff.c
index b6874ea0..6c1a2f5a 100644
--- a/roff.c
+++ b/roff.c
@@ -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 7019f4d2..3e67e21f 100644
--- a/tbl.c
+++ b/tbl.c
@@ -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 2b889542..bbe4697a 100644
--- a/tbl_data.c
+++ b/tbl_data.c
@@ -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. */
diff --git a/tbl_opts.c b/tbl_opts.c
index 00bf74ff..70fd3dff 100644
--- a/tbl_opts.c
+++ b/tbl_opts.c
@@ -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. */