summaryrefslogtreecommitdiffstats
path: root/tbl_data.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-10 14:40:30 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-10 14:40:30 +0000
commitdede963eacb17dcdbe0624bf76ab3f4045147541 (patch)
treec83ed7ba5f2d938f2f5cd04b659ac67d5da157ee /tbl_data.c
parent4f674421b17961b1c6630a984ebea196eb7eed7a (diff)
downloadmandoc-dede963eacb17dcdbe0624bf76ab3f4045147541.tar.gz
First, make extra data cells be thrown away. This makes "dp->layout"
always hold, which cleans up the table stuff a bit. Second, set a "spans" value per data cell consisting of the number of skipped TBL_CELL_SPAN layout cells. Third, make tbl_term.c understand how to skip over spanned sections when iterating over the header queue. What remains is to calculate the widths of spanned cells.
Diffstat (limited to 'tbl_data.c')
-rw-r--r--tbl_data.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/tbl_data.c b/tbl_data.c
index 7c316aad..ecf3f1a1 100644
--- a/tbl_data.c
+++ b/tbl_data.c
@@ -37,7 +37,7 @@ data(struct tbl_node *tbl, struct tbl_span *dp,
{
struct tbl_dat *dat;
struct tbl_cell *cp;
- int sv;
+ int sv, spans;
cp = NULL;
if (dp->last && dp->last->layout)
@@ -55,12 +55,32 @@ data(struct tbl_node *tbl, struct tbl_span *dp,
TBL_CELL_SPAN == cp->pos))
cp = cp->next;
+ /*
+ * Stop processing when we reach the end of the available layout
+ * cells. This means that we have extra input.
+ */
+
+ if (NULL == cp) {
+ TBL_MSG(tbl, MANDOCERR_TBLEXTRADAT, ln, *pos);
+ /* Skip to the end... */
+ while (p[*pos])
+ (*pos)++;
+ return(1);
+ }
+
dat = mandoc_calloc(1, sizeof(struct tbl_dat));
dat->layout = cp;
dat->pos = TBL_DATA_NONE;
- if (NULL == dat->layout)
- TBL_MSG(tbl, MANDOCERR_TBLEXTRADAT, ln, *pos);
+ assert(TBL_CELL_SPAN != cp->pos);
+
+ for (spans = 0, cp = cp->next; cp; cp = cp->next)
+ if (TBL_CELL_SPAN == cp->pos)
+ spans++;
+ else
+ break;
+
+ dat->spans = spans;
if (dp->last) {
dp->last->next = dat;
@@ -101,9 +121,6 @@ data(struct tbl_node *tbl, struct tbl_span *dp,
else
dat->pos = TBL_DATA_DATA;
- if (NULL == dat->layout)
- return(1);
-
if (TBL_CELL_HORIZ == dat->layout->pos ||
TBL_CELL_DHORIZ == dat->layout->pos)
if (TBL_DATA_DATA == dat->pos && '\0' != *dat->string)