diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-09-23 20:39:14 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-09-23 20:39:14 +0000 |
commit | b5b0cb7f97e94580a28e79fbe0ecedb947f2e7a9 (patch) | |
tree | 7764aed1e95f2becc6aff8e978bb8815774af257 | |
parent | d333faff4e82e328c07ed7b1976ad45d1b6d2acc (diff) |
When the HEAD of an .Nm block in the SYNOPSIS might be wider
than the column containing it, the TERMP_HANG flag is required,
but avoid the flag when we know that the HEAD is shorter,
because in that case, the flag might ruin the alignment.
Problem originally reported by jmc@, who also spotted a regression
in an earlier version of this patch.
"feel free to commit" kristaps@
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 50f5ad445fc..04b2e8b0709 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.104 2010/09/20 20:02:27 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.105 2010/09/23 20:39:13 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -1027,12 +1027,18 @@ termp_nm_pre(DECL_ARGS) synopsis_pre(p, n->parent); if (MDOC_HEAD == n->type && n->next->child) { - p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_HANG; - p->rmargin = p->offset + term_len(p, 1) + - (NULL == n->child ? term_strlen(p, m->name) : - MDOC_TEXT == n->child->type ? - term_strlen(p, n->child->string) : - term_len(p, 5)); + p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; + p->rmargin = p->offset + term_len(p, 1); + if (NULL == n->child) { + p->rmargin += term_strlen(p, m->name); + } else if (MDOC_TEXT == n->child->type) { + p->rmargin += term_strlen(p, n->child->string); + if (n->child->next) + p->flags |= TERMP_HANG; + } else { + p->rmargin += term_len(p, 5); + p->flags |= TERMP_HANG; + } } term_fontpush(p, TERMFONT_BOLD); |