=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.44 retrieving revision 1.48 diff -u -p -r1.44 -r1.48 --- mandoc/mdoc_term.c 2009/07/17 10:56:57 1.44 +++ mandoc/mdoc_term.c 2009/07/20 15:05:34 1.48 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.44 2009/07/17 10:56:57 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.48 2009/07/20 15:05:34 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -164,6 +164,7 @@ static int termp_rs_pre(DECL_ARGS); static int termp_rv_pre(DECL_ARGS); static int termp_sh_pre(DECL_ARGS); static int termp_sm_pre(DECL_ARGS); +static int termp_sp_pre(DECL_ARGS); static int termp_sq_pre(DECL_ARGS); static int termp_ss_pre(DECL_ARGS); static int termp_sx_pre(DECL_ARGS); @@ -294,7 +295,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_xx_pre, NULL }, /* Dx */ { NULL, NULL }, /* %Q */ { termp_br_pre, NULL }, /* br */ - { NULL, NULL }, /* sp */ + { termp_sp_pre, NULL }, /* sp */ }; #ifdef __linux__ @@ -363,6 +364,13 @@ print_node(DECL_ARGS) npair.flag = 0; npair.count = 0; + /* + * Note on termpair. This allows a pre function to set a termp + * flag that is automatically unset after the body, but before + * the post function. Thus, if a pre uses a termpair flag, it + * must be reapplied in the post for use. + */ + if (MDOC_TEXT != node->type) { if (termacts[node->tok].pre) if ( ! (*termacts[node->tok].pre)(p, &npair, meta, node)) @@ -377,6 +385,8 @@ print_node(DECL_ARGS) if (dochild && node->child) print_body(p, &npair, meta, node->child); + p->flags &= ~npair.flag; + /* Post-processing. */ if (MDOC_TEXT != node->type) @@ -385,7 +395,6 @@ print_node(DECL_ARGS) p->offset = offset; p->rmargin = rmargin; - p->flags &= ~npair.flag; } @@ -663,6 +672,9 @@ fmt_block_vspace(struct termp *p, if (arg_hasattr(MDOC_Compact, bl)) return(1); + /* XXX - not documented! */ + else if (arg_hasattr(MDOC_Column, bl)) + return(1); for (n = node; n; n = n->parent) { if (MDOC_BLOCK != n->type) @@ -1560,7 +1572,6 @@ termp_bd_pre(DECL_ARGS) * Ew. */ - p->flags |= TERMP_LITERAL; ln = node->child ? node->child->line : 0; for (node = node->child; node; node = node->next) { @@ -1583,10 +1594,7 @@ termp_bd_post(DECL_ARGS) if (MDOC_BODY != node->type) return; - term_flushln(p); - p->flags &= ~TERMP_LITERAL; - p->flags |= TERMP_NOSPACE; } @@ -1813,8 +1821,9 @@ static void termp_in_post(DECL_ARGS) { - p->flags |= TERMP_NOSPACE; + p->flags |= TERMP_NOSPACE | ttypes[TTYPE_INCLUDE]; term_word(p, ">"); + p->flags &= ~ttypes[TTYPE_INCLUDE]; if (SEC_SYNOPSIS != node->sec) return; @@ -1828,6 +1837,27 @@ termp_in_post(DECL_ARGS) */ if (node->next && MDOC_In != node->next->tok) term_vspace(p); +} + + +/* ARGSUSED */ +static int +termp_sp_pre(DECL_ARGS) +{ + int i, len; + + if (NULL == node->child) { + term_vspace(p); + return(0); + } + + len = atoi(node->child->string); + if (0 == len) + term_newln(p); + for (i = 0; i < len; i++) + term_vspace(p); + + return(0); }