aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit74fefd1ac6f4b27426d1a6a6dc64e5c52b84945d (patch)
treea2a44747a873bf2886c06f93a0e172dcf198eb75
parentd6b4b7d01dc50c7808c233cb162e71c30a817c08 (diff)
downloadmandoc-74fefd1ac6f4b27426d1a6a6dc64e5c52b84945d.tar.gz
mandoc-74fefd1ac6f4b27426d1a6a6dc64e5c52b84945d.tar.zst
mandoc-74fefd1ac6f4b27426d1a6a6dc64e5c52b84945d.zip
Give the "n" cell type knowledge of its spacing.
-rw-r--r--out.c16
-rw-r--r--tbl.720
-rw-r--r--tbl_term.c5
3 files changed, 20 insertions, 21 deletions
diff --git a/out.c b/out.c
index d0629e43..f12a6439 100644
--- a/out.c
+++ b/out.c
@@ -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;
}
diff --git a/tbl.7 b/tbl.7
index 3c7f0c61..747b54b5 100644
--- a/tbl.7
+++ b/tbl.7
@@ -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.
diff --git a/tbl_term.c b/tbl_term.c
index a30e7235..edf03420 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -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);