=================================================================== RCS file: /cvs/mandoc/man_term.c,v retrieving revision 1.97 retrieving revision 1.110 diff -u -p -r1.97 -r1.110 --- mandoc/man_term.c 2011/01/12 15:23:25 1.97 +++ mandoc/man_term.c 2011/06/18 17:36:52 1.110 @@ -1,6 +1,6 @@ -/* $Id: man_term.c,v 1.97 2011/01/12 15:23:25 kristaps Exp $ */ +/* $Id: man_term.c,v 1.110 2011/06/18 17:36:52 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 @@ -31,7 +31,6 @@ #include "out.h" #include "man.h" #include "term.h" -#include "chars.h" #include "main.h" #define INDENT 7 @@ -126,7 +125,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 */ @@ -157,14 +156,7 @@ terminal_man(void *arg, const struct man *man) p->tabwidth = term_len(p, 5); if (NULL == p->symtab) - switch (p->enc) { - case (TERMENC_ASCII): - p->symtab = chars_init(CHARS_ASCII); - break; - default: - abort(); - /* NOTREACHED */ - } + p->symtab = mchars_alloc(); n = man_node(man); m = man_meta(man); @@ -212,6 +204,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 +250,7 @@ pre_literal(DECL_ARGS) else mt->fl &= ~MANT_LITERAL; - return(1); + return(0); } /* ARGSUSED */ @@ -796,13 +791,12 @@ post_SH(DECL_ARGS) } } - /* ARGSUSED */ static int pre_RS(DECL_ARGS) { - const struct man_node *nn; - int ival; + int ival; + size_t sz; switch (n->type) { case (MAN_BLOCK): @@ -814,41 +808,45 @@ pre_RS(DECL_ARGS) break; } - if (NULL == (nn = n->parent->head->child)) { - mt->offset = mt->lmargin + term_len(p, INDENT); - p->offset = mt->offset; - return(1); - } + sz = term_len(p, INDENT); - if ((ival = a2width(p, nn->string)) < 0) - return(1); + if (NULL != (n = n->parent->head->child)) + if ((ival = a2width(p, n->string)) >= 0) + sz = (size_t)ival; - mt->offset = term_len(p, INDENT) + (size_t)ival; + mt->offset += sz; p->offset = mt->offset; return(1); } - /* ARGSUSED */ static void post_RS(DECL_ARGS) { + int ival; + size_t sz; switch (n->type) { case (MAN_BLOCK): - mt->offset = mt->lmargin = term_len(p, INDENT); - break; + return; case (MAN_HEAD): - break; + return; default: term_newln(p); - p->offset = term_len(p, INDENT); break; } -} + sz = term_len(p, INDENT); + if (NULL != (n = n->parent->head->child)) + if ((ival = a2width(p, n->string)) >= 0) + sz = (size_t)ival; + + mt->offset = mt->offset < sz ? 0 : mt->offset - sz; + p->offset = mt->offset; +} + static void print_man_node(DECL_ARGS) { @@ -864,7 +862,7 @@ print_man_node(DECL_ARGS) */ if ('\0' == *n->string) { term_vspace(p); - break; + return; } else if (' ' == *n->string && MAN_LINE & n->flags) term_newln(p); @@ -889,7 +887,13 @@ print_man_node(DECL_ARGS) p->rmargin = rm; p->maxrmargin = rmax; } + + 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 @@ -937,24 +941,18 @@ print_man_nodelist(DECL_ARGS) static void print_man_foot(struct termp *p, const void *arg) { - char buf[DATESIZ]; const struct man_meta *meta; meta = (const struct man_meta *)arg; term_fontrepl(p, TERMFONT_NONE); - if (meta->rawdate) - strlcpy(buf, meta->rawdate, DATESIZ); - else - time2a(meta->date, buf, DATESIZ); - term_vspace(p); term_vspace(p); term_vspace(p); p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; - p->rmargin = p->maxrmargin - term_strlen(p, buf); + p->rmargin = p->maxrmargin - term_strlen(p, meta->date); p->offset = 0; /* term_strlen() can return zero. */ @@ -972,7 +970,7 @@ print_man_foot(struct termp *p, const void *arg) p->rmargin = p->maxrmargin; p->flags &= ~TERMP_NOBREAK; - term_word(p, buf); + term_word(p, meta->date); term_flushln(p); }