aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit8532b513ad046c8c7407add6f29b742c717bb60e (patch)
tree2588a006e07be8d5cf42947d412dfab7d92ac586 /out.c
parentbf4bddcd274b710f5c5b77eb76f1d129507f43de (diff)
downloadmandoc-8532b513ad046c8c7407add6f29b742c717bb60e.tar.gz
mandoc-8532b513ad046c8c7407add6f29b742c717bb60e.tar.zst
mandoc-8532b513ad046c8c7407add6f29b742c717bb60e.zip
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.c25
1 files changed, 14 insertions, 11 deletions
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;
}