aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--mandoc.h22
-rw-r--r--out.c25
-rw-r--r--tbl_data.c7
-rw-r--r--tbl_layout.c4
4 files changed, 31 insertions, 27 deletions
diff --git a/mandoc.h b/mandoc.h
index 260ce40a..e7c0e96a 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.50 2011/01/10 14:40:30 kristaps Exp $ */
+/* $Id: mandoc.h,v 1.51 2011/01/10 15:31:00 kristaps Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -200,7 +200,7 @@ enum tbl_cellt {
struct tbl_cell {
struct tbl_cell *next;
enum tbl_cellt pos;
- int spacing;
+ size_t spacing;
int flags;
#define TBL_CELL_TALIGN (1 << 0) /* t, T */
#define TBL_CELL_BALIGN (1 << 1) /* d, D */
@@ -222,12 +222,12 @@ struct tbl_row {
};
enum tbl_datt {
- TBL_DATA_NONE,
- TBL_DATA_DATA,
- TBL_DATA_HORIZ,
- TBL_DATA_DHORIZ,
- TBL_DATA_NHORIZ,
- TBL_DATA_NDHORIZ
+ TBL_DATA_NONE, /* has no data */
+ TBL_DATA_DATA, /* consists of data/string */
+ TBL_DATA_HORIZ, /* horizontal line */
+ TBL_DATA_DHORIZ, /* double-horizontal line */
+ TBL_DATA_NHORIZ, /* squeezed horizontal line */
+ TBL_DATA_NDHORIZ /* squeezed double-horizontal line */
};
/*
@@ -235,10 +235,10 @@ enum tbl_datt {
* string value that's in the cell. The rest is layout.
*/
struct tbl_dat {
- struct tbl_cell *layout; /* layout cell: CAN BE NULL */
+ struct tbl_cell *layout; /* layout cell */
int spans; /* how many spans follow */
struct tbl_dat *next;
- char *string;
+ char *string; /* data (NULL if not TBL_DATA_DATA) */
enum tbl_datt pos;
};
@@ -254,7 +254,7 @@ enum tbl_spant {
struct tbl_span {
struct tbl *tbl;
struct tbl_head *head;
- struct tbl_row *layout; /* layout row: CAN BE NULL */
+ struct tbl_row *layout; /* layout row */
struct tbl_dat *first;
struct tbl_dat *last;
int flags;
diff --git a/out.c b/out.c
index b13d783f..46f87098 100644
--- a/out.c
+++ b/out.c
@@ -1,4 +1,4 @@
-/* $Id: out.c,v 1.33 2011/01/10 14:40:30 kristaps Exp $ */
+/* $Id: out.c,v 1.34 2011/01/10 15:31:00 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -464,6 +464,7 @@ tblcalc_literal(struct rofftbl *tbl, struct roffcol *col,
const struct tbl_dat *dp)
{
size_t sz, bufsz, spsz;
+ const char *str;
/*
* Calculate our width and use the spacing, with a minimum
@@ -471,9 +472,11 @@ tblcalc_literal(struct rofftbl *tbl, struct roffcol *col,
* either side, while right/left get a single adjacent space).
*/
- sz = bufsz = spsz = 0;
- if (dp->string)
- sz = (*tbl->slen)(dp->string, tbl->arg);
+ bufsz = spsz = 0;
+ str = dp->string ? dp->string : "";
+ sz = (*tbl->slen)(str, tbl->arg);
+
+ /* FIXME: TBL_DATA_HORIZ et al.? */
assert(dp->layout);
switch (dp->layout->pos) {
@@ -502,9 +505,9 @@ tblcalc_number(struct rofftbl *tbl, struct roffcol *col,
const struct tbl *tp, const struct tbl_dat *dp)
{
int i;
- size_t sz, psz, ssz, d, max;
- char *cp;
+ size_t sz, psz, ssz, d;
const char *str;
+ char *cp;
char buf[2];
/*
@@ -516,11 +519,11 @@ tblcalc_number(struct rofftbl *tbl, struct roffcol *col,
* Finally, re-assign the stored values.
*/
- str = dp && dp->string ? dp->string : "";
- max = dp && dp->layout ? dp->layout->spacing : 0;
-
+ str = dp->string ? dp->string : "";
sz = (*tbl->slen)(str, tbl->arg);
+ /* FIXME: TBL_DATA_HORIZ et al.? */
+
buf[0] = tp->decimal;
buf[1] = '\0';
@@ -556,8 +559,8 @@ tblcalc_number(struct rofftbl *tbl, struct roffcol *col,
/* Adjust for stipulated width. */
- if (col->width < max)
- col->width = max;
+ if (col->width < dp->layout->spacing)
+ col->width = dp->layout->spacing;
}
diff --git a/tbl_data.c b/tbl_data.c
index e30f1959..e68cd4a7 100644
--- a/tbl_data.c
+++ b/tbl_data.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_data.c,v 1.17 2011/01/10 14:56:06 kristaps Exp $ */
+/* $Id: tbl_data.c,v 1.18 2011/01/10 15:31:00 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -188,8 +188,6 @@ tbl_data(struct tbl_node *tbl, int ln, const char *p)
* If there's no last parsed span, use the first row. Lastly,
* if the last span was a horizontal line, use the same layout
* (it doesn't "consume" the layout).
- *
- * In the end, this can be NULL!
*/
if (tbl->last_span) {
@@ -198,11 +196,14 @@ tbl_data(struct tbl_node *tbl, int ln, const char *p)
rp = tbl->last_span->layout->next;
else
rp = tbl->last_span->layout;
+
if (NULL == rp)
rp = tbl->last_span->layout;
} else
rp = tbl->first_row;
+ assert(rp);
+
dp = mandoc_calloc(1, sizeof(struct tbl_span));
dp->tbl = &tbl->opts;
dp->layout = rp;
diff --git a/tbl_layout.c b/tbl_layout.c
index 12d53fad..b3e81467 100644
--- a/tbl_layout.c
+++ b/tbl_layout.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_layout.c,v 1.14 2011/01/10 14:40:30 kristaps Exp $ */
+/* $Id: tbl_layout.c,v 1.15 2011/01/10 15:31:00 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -122,7 +122,7 @@ mod:
}
*pos += i;
- cp->spacing = atoi(buf);
+ cp->spacing = (size_t)atoi(buf);
goto mod;
/* NOTREACHED */