summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-08 17:00:27 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-08 17:00:27 +0000
commit29f8344876163462796a63fb0835930cea1b51ce (patch)
tree37104860271039bde1ad7adc3c4b9ab5d1af38c0
parente524e4faa861bbbcd2c8889fd1731bf9cf334399 (diff)
downloadmandoc-29f8344876163462796a63fb0835930cea1b51ce.tar.gz
Give the "n" cell type knowledge of its spacing.
-rw-r--r--out.c14
-rw-r--r--tbl.716
-rw-r--r--tbl_term.c3
3 files changed, 16 insertions, 17 deletions
diff --git a/out.c b/out.c
index 9e89321f..8cc80e64 100644
--- a/out.c
+++ b/out.c
@@ -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;
}
diff --git a/tbl.7 b/tbl.7
index 79248986..088af960 100644
--- a/tbl.7
+++ b/tbl.7
@@ -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.
diff --git a/tbl_term.c b/tbl_term.c
index 62573486..c3dbaf35 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -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);