aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-05-30 22:56:02 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-05-30 22:56:02 +0000
commitc13027734e9d36c96b4fd039e21c3112330c80c1 (patch)
tree68a38c78005cc5fa2efaaa78bb7dcfe23b7de716 /mdoc_term.c
parentb8ca66ed11088edca84601f2bbe21a94cd5392ef (diff)
downloadmandoc-c13027734e9d36c96b4fd039e21c3112330c80c1.tar.gz
mandoc-c13027734e9d36c96b4fd039e21c3112330c80c1.tar.zst
mandoc-c13027734e9d36c96b4fd039e21c3112330c80c1.zip
Migrate `Bl -column' phrases to be MDOC_BODY instead of MDOC_HEAD. This
will make it easy for re-entrant parsing of `Ta' macros to fit in with standard closure rules. Added some more regressions for `Bl -column'. Note that one should fail, as documented in the TODO file. Recorded change of AST BNF in mdoc.3.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 9342abd0..ff04d3a2 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.133 2010/05/29 18:58:52 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.134 2010/05/30 22:56:02 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -700,7 +700,7 @@ termp_it_pre(DECL_ARGS)
switch (type) {
case (LIST_column):
- if (MDOC_BODY == n->type)
+ if (MDOC_HEAD == n->type)
break;
/*
* Imitate groff's column handling:
@@ -715,8 +715,13 @@ termp_it_pre(DECL_ARGS)
/* LINTED */
dcol = ncols < 5 ? 4 : ncols == 5 ? 3 : 1;
+ /*
+ * Calculate the offset by applying all prior MDOC_BODY,
+ * so we stop at the MDOC_HEAD (NULL == nn->prev).
+ */
+
for (i = 0, nn = n->prev;
- nn && i < (int)ncols;
+ nn->prev && i < (int)ncols;
nn = nn->prev, i++)
offset += dcol + a2width
(&bl->args->argv[vals[2]], i);
@@ -869,15 +874,18 @@ termp_it_pre(DECL_ARGS)
p->flags |= TERMP_DANGLE;
break;
case (LIST_column):
- if (MDOC_HEAD == n->type) {
- assert(n->next);
- if (MDOC_BODY == n->next->type)
- p->flags &= ~TERMP_NOBREAK;
- else
- p->flags |= TERMP_NOBREAK;
- if (n->prev)
- p->flags |= TERMP_NOLPAD;
- }
+ if (MDOC_HEAD == n->type)
+ break;
+
+ if (NULL == n->next)
+ p->flags &= ~TERMP_NOBREAK;
+ else
+ p->flags |= TERMP_NOBREAK;
+
+ assert(n->prev);
+ if (MDOC_BODY == n->prev->type)
+ p->flags |= TERMP_NOLPAD;
+
break;
case (LIST_diag):
if (MDOC_HEAD == n->type)
@@ -929,9 +937,9 @@ termp_it_pre(DECL_ARGS)
* XXX - this behaviour is not documented: the
* right-most column is filled to the right margin.
*/
- if (MDOC_HEAD == n->type &&
- MDOC_BODY == n->next->type &&
- p->rmargin < p->maxrmargin)
+ if (MDOC_HEAD == n->type)
+ break;
+ if (NULL == n->next && p->rmargin < p->maxrmargin)
p->rmargin = p->maxrmargin;
break;
default:
@@ -985,7 +993,7 @@ termp_it_pre(DECL_ARGS)
return(0);
break;
case (LIST_column):
- if (MDOC_BODY == n->type)
+ if (MDOC_HEAD == n->type)
return(0);
break;
default:
@@ -1017,7 +1025,7 @@ termp_it_post(DECL_ARGS)
term_newln(p);
break;
case (LIST_column):
- if (MDOC_HEAD == n->type)
+ if (MDOC_BODY == n->type)
term_flushln(p);
break;
default: