summaryrefslogtreecommitdiffstats
path: root/out.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-10 15:31:00 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-10 15:31:00 +0000
commited5e3c51cf000a55a9774ad85994aa7c35abc0df (patch)
tree3038b4cd4495d286fb7980c27cff8a70b29e27f5 /out.c
parent8a26b665a342bbb1c095e7556e69d0995f952fe8 (diff)
downloadmandoc-ed5e3c51cf000a55a9774ad85994aa7c35abc0df.tar.gz
Clarify what members may be NULL or not in calculating widths. Make
sure signedness is correct. Verify that layouts MUST exit for data cells.
Diffstat (limited to 'out.c')
-rw-r--r--out.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/out.c b/out.c
index 1a647922..79a0c4d2 100644
--- a/out.c
+++ b/out.c
@@ -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;
}