=================================================================== RCS file: /cvs/mandoc/out.c,v retrieving revision 1.30 retrieving revision 1.33 diff -u -p -r1.30 -r1.33 --- mandoc/out.c 2011/01/05 15:37:23 1.30 +++ mandoc/out.c 2011/01/10 14:40:30 1.33 @@ -1,4 +1,4 @@ -/* $Id: out.c,v 1.30 2011/01/05 15:37:23 kristaps Exp $ */ +/* $Id: out.c,v 1.33 2011/01/10 14:40:30 kristaps Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons * @@ -399,8 +399,7 @@ tblcalc(struct rofftbl *tbl, const struct tbl_span *sp * to data cells in the data section. */ for (dp = sp->first; dp; dp = dp->next) { - if (NULL == dp->layout) - continue; + assert(dp->layout); col = &tbl->cols[dp->layout->head->ident]; tblcalc_data(tbl, col, sp->tbl, dp); } @@ -503,13 +502,11 @@ tblcalc_number(struct rofftbl *tbl, struct roffcol *co const struct tbl *tp, const struct tbl_dat *dp) { int i; - size_t sz, psz, ssz, d; + size_t sz, psz, ssz, d, max; char *cp; const char *str; char buf[2]; - /* TODO: use spacing modifier. */ - /* * First calculate number width and decimal place (last + 1 for * no-decimal numbers). If the stored decimal is subsequent @@ -519,9 +516,8 @@ tblcalc_number(struct rofftbl *tbl, struct roffcol *co * Finally, re-assign the stored values. */ - str = ""; - if (dp->string) - str = dp->string; + str = dp && dp->string ? dp->string : ""; + max = dp && dp->layout ? dp->layout->spacing : 0; sz = (*tbl->slen)(str, tbl->arg); @@ -530,7 +526,7 @@ tblcalc_number(struct rofftbl *tbl, struct roffcol *co psz = (*tbl->slen)(buf, tbl->arg); - if (NULL != (cp = strchr(str, tp->decimal))) { + if (NULL != (cp = strrchr(str, tp->decimal))) { buf[1] = '\0'; for (ssz = 0, i = 0; cp != &str[i]; i++) { buf[0] = str[i]; @@ -557,6 +553,11 @@ tblcalc_number(struct rofftbl *tbl, struct roffcol *co col->width = sz; if (d > col->decimal) col->decimal = d; + + /* Adjust for stipulated width. */ + + if (col->width < max) + col->width = max; }