=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.214 retrieving revision 1.221 diff -u -p -r1.214 -r1.221 --- mandoc/mdoc_term.c 2011/01/25 16:20:24 1.214 +++ mandoc/mdoc_term.c 2011/03/22 10:13:01 1.221 @@ -1,6 +1,6 @@ -/* $Id: mdoc_term.c,v 1.214 2011/01/25 16:20:24 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.221 2011/03/22 10:13:01 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons + * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any @@ -32,7 +32,6 @@ #include "out.h" #include "term.h" #include "mdoc.h" -#include "chars.h" #include "main.h" #define INDENT 5 @@ -312,22 +311,6 @@ print_mdoc_node(DECL_ARGS) memset(&npair, 0, sizeof(struct termpair)); npair.ppair = pair; - - switch (n->type) { - case (MDOC_TEXT): - if (' ' == *n->string && MDOC_LINE & n->flags) - term_newln(p); - term_word(p, n->string); - break; - case (MDOC_TBL): - term_tbl(p, n->span); - break; - default: - if (termacts[n->tok].pre && ENDBODY_NOT == n->end) - chld = (*termacts[n->tok].pre) - (p, &npair, m, n); - break; - } /* * Keeps only work until the end of a line. If a keep was @@ -359,6 +342,30 @@ print_mdoc_node(DECL_ARGS) (n->parent && MDOC_SYNPRETTY & n->parent->flags))) p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); + /* + * After the keep flags have been set up, we may now + * produce output. Note that some pre-handlers do so. + */ + + switch (n->type) { + case (MDOC_TEXT): + if (' ' == *n->string && MDOC_LINE & n->flags) + term_newln(p); + term_word(p, n->string); + break; + case (MDOC_EQN): + term_word(p, n->eqn->data); + break; + case (MDOC_TBL): + term_tbl(p, n->span); + break; + default: + if (termacts[n->tok].pre && ENDBODY_NOT == n->end) + chld = (*termacts[n->tok].pre) + (p, &npair, m, n); + break; + } + if (chld && n->child) print_mdoc_nodelist(p, &npair, m, n->child); @@ -369,6 +376,8 @@ print_mdoc_node(DECL_ARGS) break; case (MDOC_TBL): break; + case (MDOC_EQN): + break; default: if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags) break; @@ -403,7 +412,6 @@ print_mdoc_node(DECL_ARGS) static void print_mdoc_foot(struct termp *p, const void *arg) { - char buf[DATESIZ], os[BUFSIZ]; const struct mdoc_meta *m; m = (const struct mdoc_meta *)arg; @@ -418,24 +426,21 @@ print_mdoc_foot(struct termp *p, const void *arg) * SYSTEM DATE SYSTEM */ - time2a(m->date, buf, DATESIZ); - strlcpy(os, m->os, BUFSIZ); - term_vspace(p); p->offset = 0; p->rmargin = (p->maxrmargin - - term_strlen(p, buf) + term_len(p, 1)) / 2; + term_strlen(p, m->date) + term_len(p, 1)) / 2; p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; - term_word(p, os); + term_word(p, m->os); term_flushln(p); p->offset = p->rmargin; - p->rmargin = p->maxrmargin - term_strlen(p, os); + p->rmargin = p->maxrmargin - term_strlen(p, m->os); p->flags |= TERMP_NOLPAD | TERMP_NOSPACE; - term_word(p, buf); + term_word(p, m->date); term_flushln(p); p->offset = p->rmargin; @@ -443,7 +448,7 @@ print_mdoc_foot(struct termp *p, const void *arg) p->flags &= ~TERMP_NOBREAK; p->flags |= TERMP_NOLPAD | TERMP_NOSPACE; - term_word(p, os); + term_word(p, m->os); term_flushln(p); p->offset = 0; @@ -1151,7 +1156,8 @@ static int termp_ns_pre(DECL_ARGS) { - p->flags |= TERMP_NOSPACE; + if ( ! (MDOC_LINE & n->flags)) + p->flags |= TERMP_NOSPACE; return(1); } @@ -1703,6 +1709,7 @@ static int termp_xx_pre(DECL_ARGS) { const char *pp; + int flags; pp = NULL; switch (n->tok) { @@ -1730,9 +1737,10 @@ termp_xx_pre(DECL_ARGS) term_word(p, pp); if (n->child) { + flags = p->flags; p->flags |= TERMP_KEEP; term_word(p, n->child->string); - p->flags &= ~TERMP_KEEP; + p->flags = flags; } return(0); } @@ -2186,7 +2194,7 @@ termp__t_post(DECL_ARGS) * If we're in an `Rs' and there's a journal present, then quote * us instead of underlining us (for disambiguation). */ - if (n->parent && MDOC_Rs == n->parent->tok && + if (n->parent && MDOC_Rs == n->parent->tok && n->parent->norm->Rs.quote_T) termp_quote_post(p, pair, m, n);