aboutsummaryrefslogtreecommitdiffstatshomepage
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
commitb3ea03504ba905470ba5c486ba69062c89034488 (patch)
treedf4cbcc9f5102817e214499b8ce04b165972afbf /tbl_data.c
parent8b2891b502ff415c363420b6f4238ec3561efd97 (diff)
downloadmandoc-b3ea03504ba905470ba5c486ba69062c89034488.tar.gz
mandoc-b3ea03504ba905470ba5c486ba69062c89034488.tar.zst
mandoc-b3ea03504ba905470ba5c486ba69062c89034488.zip
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.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/tbl_data.c b/tbl_data.c
index 67e7485c..c7bca649 100644
--- a/tbl_data.c
+++ b/tbl_data.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_data.c,v 1.15 2011/01/09 23:14:41 kristaps Exp $ */
+/* $Id: tbl_data.c,v 1.16 2011/01/10 14:40:30 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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)