diff options
-rw-r--r-- | out.c | 16 | ||||
-rw-r--r-- | tbl.7 | 20 | ||||
-rw-r--r-- | tbl_term.c | 5 |
3 files changed, 20 insertions, 21 deletions
@@ -1,4 +1,4 @@ -/* $Id: out.c,v 1.30 2011/01/05 15:37:23 kristaps Exp $ */ +/* $Id: out.c,v 1.31 2011/01/08 17:00:27 kristaps Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -503,13 +503,11 @@ 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; + 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 +517,8 @@ tblcalc_number(struct rofftbl *tbl, struct roffcol *col, * 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); @@ -557,6 +554,11 @@ tblcalc_number(struct rofftbl *tbl, struct roffcol *col, col->width = sz; if (d > col->decimal) col->decimal = d; + + /* Adjust for stipulated width. */ + + if (col->width < max) + col->width = max; } @@ -1,4 +1,4 @@ -.\" $Id: tbl.7,v 1.4 2011/01/07 14:59:52 kristaps Exp $ +.\" $Id: tbl.7,v 1.5 2011/01/08 17:00:27 kristaps Exp $ .\" .\" Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 7 2011 $ +.Dd $Mdocdate: January 8 2011 $ .Dt TBL 7 .Os .Sh NAME @@ -231,16 +231,9 @@ Emit a vertical bar instead of data. Emit a double-vertical bar instead of data. .El .Pp -For example, the following layout specifies a centre-justified column of -minimum width 10, followed by vertical bar, followed by a left-justified -column of minimum width 10, another vertical bar, then a column -justified about the decimal point in numbers: -.Pp -.Dl c10 | l10 | n -.Pp Keys may be followed by a set of modifiers. A modifier is either a modifier key or a natural number for specifying -spacing. +the minimum width of a column. The following case-insensitive modifier keys are available: .Cm z , .Cm u , @@ -255,6 +248,13 @@ and .Cm i . All of these are ignored by .Xr mandoc 1 . +.Pp +For example, the following layout specifies a centre-justified column of +minimum width 10, followed by vertical bar, followed by a left-justified +column of minimum width 10, another vertical bar, then a column +justified about the decimal point in numbers: +.Pp +.Dl c10 | l10 | n .Ss Data The data section follows the last layout row. By default, cells in a data section are delimited by a tab. @@ -1,4 +1,4 @@ -/* $Id: tbl_term.c,v 1.13 2011/01/07 14:59:52 kristaps Exp $ */ +/* $Id: tbl_term.c,v 1.14 2011/01/08 17:00:27 kristaps Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -27,9 +27,6 @@ #include "out.h" #include "term.h" -/* FIXME: `n' modifier doesn't always do the right thing. */ -/* FIXME: `n' modifier doesn't use the cell-spacing buffer. */ - static size_t term_tbl_len(size_t, void *); static size_t term_tbl_strlen(const char *, void *); static void tbl_char(struct termp *, char, size_t); |