summaryrefslogtreecommitdiffstats
path: root/man_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-08-17 11:03:07 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-08-17 11:03:07 +0000
commitc09292673699d2b1eb00bd922cdbc573622e4b19 (patch)
treef1309cebaa9125018a4afabc7256998915bfe034 /man_term.c
parentbeea252a74daede4b79d152b669a994f3e728274 (diff)
downloadmandoc-c09292673699d2b1eb00bd922cdbc573622e4b19.tar.gz
`IP' and `TP' correctly handle width arguments.
Documented numeric widths.
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c64
1 files changed, 50 insertions, 14 deletions
diff --git a/man_term.c b/man_term.c
index 5c216b2e..3f20e1e3 100644
--- a/man_term.c
+++ b/man_term.c
@@ -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;