summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-07-23 08:36:32 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-07-23 08:36:32 +0000
commit8575c261dfe0a8671a0f20ffaf68572b439becba (patch)
tree735fe7ddaf8297a879ee870878e02e7002d557ce
parent9c5966e1ea31e14db2549951ecd0b985aa71f769 (diff)
downloadmandoc-8575c261dfe0a8671a0f20ffaf68572b439becba.tar.gz
mandoc-8575c261dfe0a8671a0f20ffaf68572b439becba.tar.zst
mandoc-8575c261dfe0a8671a0f20ffaf68572b439becba.zip
Bl -column now accepts columns = (1 + stated columns), which covers all remaining column usage/abuse I can see.
-rw-r--r--mdoc_term.c24
-rw-r--r--mdoc_validate.c4
2 files changed, 22 insertions, 6 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 8c868fc3..0b324ccd 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.57 2009/07/21 15:54:18 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.58 2009/07/23 08:36:32 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -782,11 +782,27 @@ termp_it_pre(DECL_ARGS)
case (MDOC_Column):
if (MDOC_BODY == node->type)
break;
- for (i = 0, n = node->prev; n; n = n->prev, i++)
+ /*
+ * Work around groff's column handling. The offset is
+ * equal to the sum of all widths leading to the current
+ * column (plus the -offset value). If this column
+ * exceeds the stated number of columns, the width is
+ * set as 0, else it's the stated column width (later
+ * the 0 will be adjusted to default 10 or, if in the
+ * last column case, set to stretch to the margin).
+ */
+ for (i = 0, n = node->prev; n && n &&
+ i < (int)bl->args[vals[2]].argv->sz;
+ n = n->prev, i++)
offset += arg_width
(&bl->args->argv[vals[2]], i);
- assert(i < (int)bl->args->argv[vals[2]].sz);
- width = arg_width(&bl->args->argv[vals[2]], i);
+
+ /* Whether exceeds maximum column. */
+ if (i < (int)bl->args[vals[2]].argv->sz)
+ width = arg_width(&bl->args->argv[vals[2]], i);
+ else
+ width = 0;
+
if (vals[1] >= 0)
offset += arg_offset(&bl->args->argv[vals[1]]);
break;
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 15e10637..797642aa 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.38 2009/07/20 15:05:34 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.39 2009/07/23 08:36:32 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -1029,7 +1029,7 @@ post_it(POST_ARGS)
for (i = 0; c && MDOC_HEAD == c->type; c = c->next)
i++;
- if (i < cols) {
+ if (i < cols || i == (cols + 1)) {
if ( ! mdoc_vwarn(mdoc, mdoc->last->line,
mdoc->last->pos, "column "
"mismatch: have %d, want %d",