=================================================================== RCS file: /cvs/mandoc/man_term.c,v retrieving revision 1.96 retrieving revision 1.103 diff -u -p -r1.96 -r1.103 --- mandoc/man_term.c 2011/01/12 10:43:22 1.96 +++ mandoc/man_term.c 2011/02/09 09:52:47 1.103 @@ -1,6 +1,6 @@ -/* $Id: man_term.c,v 1.96 2011/01/12 10:43:22 kristaps Exp $ */ +/* $Id: man_term.c,v 1.103 2011/02/09 09:52:47 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons + * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any @@ -126,7 +126,7 @@ static const struct termact termacts[MAN_MAX] = { { pre_I, NULL, 0 }, /* I */ { pre_alternate, NULL, 0 }, /* IR */ { pre_alternate, NULL, 0 }, /* RI */ - { NULL, NULL, MAN_NOTEXT }, /* na */ + { pre_ign, NULL, MAN_NOTEXT }, /* na */ { pre_sp, NULL, MAN_NOTEXT }, /* sp */ { pre_literal, NULL, 0 }, /* nf */ { pre_literal, NULL, 0 }, /* fi */ @@ -212,6 +212,9 @@ print_bvspace(struct termp *p, const struct man_node * { term_newln(p); + if (n->body && n->body->child && MAN_TBL == n->body->child->type) + return; + if (NULL == n->prev) return; @@ -255,7 +258,7 @@ pre_literal(DECL_ARGS) else mt->fl &= ~MANT_LITERAL; - return(1); + return(0); } /* ARGSUSED */ @@ -855,23 +858,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) + return; + } 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; @@ -882,35 +893,39 @@ print_man_node(DECL_ARGS) p->maxrmargin = rmax; } - break; + if (MAN_EOS & n->flags) + p->flags |= TERMP_SENTENCE; + return; + case (MAN_EQN): + term_word(p, n->eqn->data); + 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;