=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.51 retrieving revision 1.55 diff -u -p -r1.51 -r1.55 --- mandoc/mdoc_term.c 2009/07/21 13:34:13 1.51 +++ mandoc/mdoc_term.c 2009/07/21 15:35:30 1.55 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.51 2009/07/21 13:34:13 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.55 2009/07/21 15:35:30 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -65,7 +65,7 @@ const int ttypes[TTYPE_NMAX] = { TERMP_UNDER, /* TTYPE_FUNC_ARG */ TERMP_UNDER, /* TTYPE_LINK */ TERMP_BOLD, /* TTYPE_SSECTION */ - TERMP_UNDER, /* TTYPE_FILE */ + 0, /* TTYPE_FILE */ TERMP_UNDER, /* TTYPE_EMPH */ TERMP_BOLD, /* TTYPE_CONFIG */ TERMP_BOLD, /* TTYPE_CMD */ @@ -154,7 +154,6 @@ static int termp_nd_pre(DECL_ARGS); static int termp_nm_pre(DECL_ARGS); static int termp_ns_pre(DECL_ARGS); static int termp_op_pre(DECL_ARGS); -static int termp_pa_pre(DECL_ARGS); static int termp_pf_pre(DECL_ARGS); static int termp_pp_pre(DECL_ARGS); static int termp_pq_pre(DECL_ARGS); @@ -210,7 +209,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_nm_pre, NULL }, /* Nm */ { termp_op_pre, termp_op_post }, /* Op */ { NULL, NULL }, /* Ot */ - { termp_pa_pre, NULL }, /* Pa */ + { NULL, NULL }, /* Pa */ { termp_rv_pre, NULL }, /* Rv */ { NULL, NULL }, /* St */ { termp_va_pre, NULL }, /* Va */ @@ -309,7 +308,7 @@ static int arg_getattr(int, const struct mdoc_node * static size_t arg_offset(const struct mdoc_argv *); static size_t arg_width(const struct mdoc_argv *, int); static int arg_listtype(const struct mdoc_node *); -static int fmt_block_vspace(struct termp *, +static void fmt_block_vspace(struct termp *, const struct mdoc_node *, const struct mdoc_node *); static void print_node(DECL_ARGS); @@ -660,7 +659,7 @@ arg_getattrs(const int *keys, int *vals, /* ARGSUSED */ -static int +static void fmt_block_vspace(struct termp *p, const struct mdoc_node *bl, const struct mdoc_node *node) @@ -670,25 +669,46 @@ fmt_block_vspace(struct termp *p, term_newln(p); if (arg_hasattr(MDOC_Compact, bl)) - return(1); - /* XXX - not documented! */ - else if (arg_hasattr(MDOC_Column, bl)) - return(1); + return; + /* + * Search through our prior nodes. If we follow a `Ss' or `Sh', + * then don't vspace. + */ + for (n = node; n; n = n->parent) { if (MDOC_BLOCK != n->type) continue; if (MDOC_Ss == n->tok) - break; + return; if (MDOC_Sh == n->tok) - break; + return; if (NULL == n->prev) continue; - term_vspace(p); break; } - return(1); + /* + * XXX - not documented: a `-column' does not ever assert vspace + * within the list. + */ + + if (arg_hasattr(MDOC_Column, bl)) + if (node->prev && MDOC_It == node->prev->tok) + return; + + /* + * XXX - not documented: a `-diag' without a body does not + * assert a vspace prior to the next element. + */ + if (arg_hasattr(MDOC_Diag, bl)) + if (node->prev && MDOC_It == node->prev->tok) { + assert(node->prev->body); + if (NULL == node->prev->body->child) + return; + } + + term_vspace(p); } @@ -728,8 +748,10 @@ termp_it_pre(DECL_ARGS) int i, type, keys[3], vals[3]; size_t width, offset; - if (MDOC_BLOCK == node->type) - return(fmt_block_vspace(p, node->parent->parent, node)); + if (MDOC_BLOCK == node->type) { + fmt_block_vspace(p, node->parent->parent, node); + return(1); + } bl = node->parent->parent->parent; @@ -1015,6 +1037,8 @@ termp_it_post(DECL_ARGS) switch (type) { case (MDOC_Item): /* FALLTHROUGH */ + case (MDOC_Diag): + /* FALLTHROUGH */ case (MDOC_Inset): if (MDOC_BODY == node->type) term_flushln(p); @@ -1530,10 +1554,11 @@ termp_bd_pre(DECL_ARGS) * line. Blank lines are allowed. */ - if (MDOC_BLOCK == node->type) - return(fmt_block_vspace(p, node, node)); - else if (MDOC_BODY != node->type) + if (MDOC_BLOCK == node->type) { + fmt_block_vspace(p, node, node); return(1); + } else if (MDOC_BODY != node->type) + return(1); /* FIXME: display type should be mandated by parser. */ @@ -1756,16 +1781,6 @@ termp_ss_post(DECL_ARGS) if (MDOC_HEAD == node->type) term_newln(p); -} - - -/* ARGSUSED */ -static int -termp_pa_pre(DECL_ARGS) -{ - - pair->flag |= ttypes[TTYPE_FILE]; - return(1); }