aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-12 15:23:25 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-12 15:23:25 +0000
commit32d745fbf3e703a2a0b405cd89d73ef56e995d26 (patch)
tree0155c3dc8b9ad47eb542de21625665c650e64585 /man_term.c
parentbf9cd278f0762f5462721f4edb03b4172663d23f (diff)
downloadmandoc-32d745fbf3e703a2a0b405cd89d73ef56e995d26.tar.gz
mandoc-32d745fbf3e703a2a0b405cd89d73ef56e995d26.tar.zst
mandoc-32d745fbf3e703a2a0b405cd89d73ef56e995d26.zip
Make -man -Tascii not break within literal lines, e.g.,
.nf .B hello world .fi Also, clean up the print_man_node() function a little bit. This problem has long since been in the TODO and was recently noted again by Brad Smith. The -T[x]html fix will follow...
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c62
1 files changed, 34 insertions, 28 deletions
diff --git a/man_term.c b/man_term.c
index c94900fc..b6e4b004 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.96 2011/01/12 10:43:22 kristaps Exp $ */
+/* $Id: man_term.c,v 1.97 2011/01/12 15:23:25 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -855,23 +855,31 @@ print_man_node(DECL_ARGS)
size_t rm, rmax;
int c;
- c = 1;
-
switch (n->type) {
case(MAN_TEXT):
+ /*
+ * If we have a blank line, output a vertical space.
+ * If we have a space as the first character, break
+ * before printing the line's data.
+ */
if ('\0' == *n->string) {
term_vspace(p);
break;
- }
-
- if (' ' == *n->string && MAN_LINE & n->flags)
+ } else if (' ' == *n->string && MAN_LINE & n->flags)
term_newln(p);
term_word(p, n->string);
- /* FIXME: this means that macro lines are munged! */
-
- if (MANT_LITERAL & mt->fl) {
+ /*
+ * If we're in a literal context, make sure that words
+ * togehter on the same line stay together. This is a
+ * POST-printing call, so we check the NEXT word. Since
+ * -man doesn't have nested macros, we don't need to be
+ * more specific than this.
+ */
+ if (MANT_LITERAL & mt->fl &&
+ (NULL == n->next ||
+ n->next->line > n->line)) {
rm = p->rmargin;
rmax = p->maxrmargin;
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
@@ -881,36 +889,34 @@ print_man_node(DECL_ARGS)
p->rmargin = rm;
p->maxrmargin = rmax;
}
-
- break;
+ return;
case (MAN_TBL):
+ /*
+ * Tables are preceded by a newline. Then process a
+ * table line, which will cause line termination,
+ */
if (TBL_SPAN_FIRST & n->span->flags)
term_newln(p);
term_tbl(p, n->span);
- break;
+ return;
default:
- if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
- term_fontrepl(p, TERMFONT_NONE);
- if (termacts[n->tok].pre)
- c = (*termacts[n->tok].pre)(p, mt, n, m);
break;
}
+ if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
+ term_fontrepl(p, TERMFONT_NONE);
+
+ c = 1;
+ if (termacts[n->tok].pre)
+ c = (*termacts[n->tok].pre)(p, mt, n, m);
+
if (c && n->child)
print_man_nodelist(p, mt, n->child, m);
- switch (n->type) {
- case (MAN_TEXT):
- /* FALLTHROUGH */
- case (MAN_TBL):
- break;
- default:
- if (termacts[n->tok].post)
- (*termacts[n->tok].post)(p, mt, n, m);
- if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
- term_fontrepl(p, TERMFONT_NONE);
- break;
- }
+ if (termacts[n->tok].post)
+ (*termacts[n->tok].post)(p, mt, n, m);
+ if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
+ term_fontrepl(p, TERMFONT_NONE);
if (MAN_EOS & n->flags)
p->flags |= TERMP_SENTENCE;