diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-30 22:56:02 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-30 22:56:02 +0000 |
commit | 3bc2083f7ee493642602f9dcee0f82ecbcca4c85 (patch) | |
tree | dcd389ecbb19d7ac1548b907063f320ddff97cb5 /mdoc_term.c | |
parent | 23898d93c7914bc2b07dc60fde156bdff597205b (diff) | |
download | mandoc-3bc2083f7ee493642602f9dcee0f82ecbcca4c85.tar.gz |
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.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/mdoc_term.c b/mdoc_term.c index 943a880d..9bd89edc 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -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: |