diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-08-17 11:03:07 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-08-17 11:03:07 +0000 |
commit | 68a4884e51e55098303cfe5b920959d493ee8e73 (patch) | |
tree | 86d7137d370dc24352eac08297e311d5e0aade0f /man_term.c | |
parent | d8cc7939c87b98bce901828e6ad799e21b6154dc (diff) | |
download | mandoc-68a4884e51e55098303cfe5b920959d493ee8e73.tar.gz mandoc-68a4884e51e55098303cfe5b920959d493ee8e73.tar.zst mandoc-68a4884e51e55098303cfe5b920959d493ee8e73.zip |
`IP' and `TP' correctly handle width arguments.
Documented numeric widths.
Diffstat (limited to 'man_term.c')
-rw-r--r-- | man_term.c | 66 |
1 files changed, 51 insertions, 15 deletions
@@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.22 2009/08/13 12:54:52 kristaps Exp $ */ +/* $Id: man_term.c,v 1.23 2009/08/17 11:03:07 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -474,9 +474,6 @@ pre_IP(DECL_ARGS) int ival; switch (n->type) { - case (MAN_BLOCK): - fmt_block_vspace(p, n); - return(1); case (MAN_BODY): p->flags |= TERMP_NOLPAD; p->flags |= TERMP_NOSPACE; @@ -485,11 +482,14 @@ pre_IP(DECL_ARGS) p->flags |= TERMP_NOBREAK; p->flags |= TERMP_TWOSPACE; break; + case (MAN_BLOCK): + fmt_block_vspace(p, n); + /* FALLTHROUGH */ default: return(1); } - len = INDENT * 2; + len = INDENT; ival = -1; /* Calculate offset. */ @@ -503,11 +503,11 @@ pre_IP(DECL_ARGS) } switch (n->type) { - case (MAN_BODY): - p->offset = INDENT + len; - p->rmargin = p->maxrmargin; - break; case (MAN_HEAD): + /* Handle zero-width lengths. */ + if (0 == len) + len = 1; + p->offset = INDENT; p->rmargin = INDENT + len; if (ival < 0) @@ -517,6 +517,10 @@ pre_IP(DECL_ARGS) for (nn = n->child; nn->next; nn = nn->next) print_node(p, fl, nn, m); return(0); + case (MAN_BODY): + p->offset = INDENT + len; + p->rmargin = p->maxrmargin; + break; default: break; } @@ -551,21 +555,53 @@ post_IP(DECL_ARGS) static int pre_TP(DECL_ARGS) { + const struct man_node *nn; + size_t len; + int ival; switch (n->type) { - case (MAN_BLOCK): - fmt_block_vspace(p, n); - break; case (MAN_HEAD): - p->rmargin = INDENT * 2; - p->offset = INDENT; p->flags |= TERMP_NOBREAK; p->flags |= TERMP_TWOSPACE; break; case (MAN_BODY): p->flags |= TERMP_NOLPAD; p->flags |= TERMP_NOSPACE; - p->offset = INDENT * 2; + break; + case (MAN_BLOCK): + fmt_block_vspace(p, n); + /* FALLTHROUGH */ + default: + return(1); + } + + len = INDENT; + ival = -1; + + /* Calculate offset. */ + + if (NULL != (nn = n->parent->head->child)) + if (NULL != nn->next) + if ((ival = arg_width(nn)) >= 0) + len = (size_t)ival; + + switch (n->type) { + case (MAN_HEAD): + /* Handle zero-length properly. */ + if (0 == len) + len = 1; + + p->offset = INDENT; + p->rmargin = INDENT + len; + + /* Don't print same-line elements. */ + for (nn = n->child; nn; nn = nn->next) + if (nn->line > n->line) + print_node(p, fl, nn, m); + return(0); + case (MAN_BODY): + p->offset = INDENT + len; + p->rmargin = p->maxrmargin; break; default: break; |