=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.73 retrieving revision 1.83 diff -u -p -r1.73 -r1.83 --- mandoc/mdoc_term.c 2009/09/20 17:24:57 1.73 +++ mandoc/mdoc_term.c 2009/09/24 15:01:06 1.83 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.73 2009/09/20 17:24:57 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.83 2009/09/24 15:01:06 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -113,7 +113,6 @@ static int termp_bd_pre(DECL_ARGS); static int termp_bf_pre(DECL_ARGS); static int termp_bold_pre(DECL_ARGS); static int termp_bq_pre(DECL_ARGS); -static int termp_br_pre(DECL_ARGS); static int termp_brq_pre(DECL_ARGS); static int termp_bt_pre(DECL_ARGS); static int termp_cd_pre(DECL_ARGS); @@ -133,7 +132,6 @@ static int termp_nm_pre(DECL_ARGS); static int termp_ns_pre(DECL_ARGS); static int termp_op_pre(DECL_ARGS); static int termp_pf_pre(DECL_ARGS); -static int termp_pp_pre(DECL_ARGS); static int termp_pq_pre(DECL_ARGS); static int termp_qq_pre(DECL_ARGS); static int termp_rs_pre(DECL_ARGS); @@ -155,7 +153,7 @@ static const struct termact termacts[MDOC_MAX] = { { NULL, NULL }, /* Os */ { termp_sh_pre, termp_sh_post }, /* Sh */ { termp_ss_pre, termp_ss_post }, /* Ss */ - { termp_pp_pre, NULL }, /* Pp */ + { termp_sp_pre, NULL }, /* Pp */ { termp_d1_pre, termp_d1_post }, /* D1 */ { termp_d1_pre, termp_d1_post }, /* Dl */ { termp_bd_pre, termp_bd_post }, /* Bd */ @@ -220,7 +218,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_under_pre, NULL }, /* Em */ { NULL, NULL }, /* Eo */ { termp_xx_pre, NULL }, /* Fx */ - { termp_bold_pre, NULL }, /* Ms */ + { termp_bold_pre, NULL }, /* Ms */ /* FIXME: convert to symbol? */ { NULL, NULL }, /* No */ { termp_ns_pre, NULL }, /* Ns */ { termp_xx_pre, NULL }, /* Nx */ @@ -256,18 +254,18 @@ static const struct termact termacts[MDOC_MAX] = { { NULL, NULL }, /* Fr */ { termp_ud_pre, NULL }, /* Ud */ { NULL, termp_lb_post }, /* Lb */ - { termp_pp_pre, NULL }, /* Lp */ + { termp_sp_pre, NULL }, /* Lp */ { termp_lk_pre, NULL }, /* Lk */ { termp_under_pre, NULL }, /* Mt */ { termp_brq_pre, termp_brq_post }, /* Brq */ { termp_brq_pre, termp_brq_post }, /* Bro */ { NULL, NULL }, /* Brc */ - { NULL, NULL }, /* %C */ - { NULL, NULL }, /* Es */ - { NULL, NULL }, /* En */ + { NULL, termp____post }, /* %C */ + { NULL, NULL }, /* Es */ /* TODO */ + { NULL, NULL }, /* En */ /* TODO */ { termp_xx_pre, NULL }, /* Dx */ - { NULL, NULL }, /* %Q */ - { termp_br_pre, NULL }, /* br */ + { NULL, termp____post }, /* %Q */ + { termp_sp_pre, NULL }, /* br */ { termp_sp_pre, NULL }, /* sp */ }; @@ -424,6 +422,7 @@ print_foot(DECL_ARGS) } +/* FIXME: put in utility library. */ /* ARGSUSED */ static void print_head(DECL_ARGS) @@ -762,14 +761,14 @@ termp_it_pre(DECL_ARGS) * the 0 will be adjusted to default 10 or, if in the * last column case, set to stretch to the margin). */ - for (i = 0, n = node->prev; n && n && - i < (int)bl->args[vals[2]].argv->sz; + for (i = 0, n = node->prev; n && + i < (int)bl->args->argv[vals[2]].sz; n = n->prev, i++) offset += arg_width (&bl->args->argv[vals[2]], i); /* Whether exceeds maximum column. */ - if (i < (int)bl->args[vals[2]].argv->sz) + if (i < (int)bl->args->argv[vals[2]].sz) width = arg_width(&bl->args->argv[vals[2]], i); else width = 0; @@ -1162,19 +1161,11 @@ termp_ns_pre(DECL_ARGS) /* ARGSUSED */ static int -termp_pp_pre(DECL_ARGS) -{ - - term_vspace(p); - return(1); -} - - -/* ARGSUSED */ -static int termp_rs_pre(DECL_ARGS) { + if (SEC_SEE_ALSO != node->sec) + return(1); if (MDOC_BLOCK == node->type && node->prev) term_vspace(p); return(1); @@ -1426,7 +1417,7 @@ termp_bt_pre(DECL_ARGS) { term_word(p, "is currently in beta test."); - return(1); + return(0); } @@ -1435,7 +1426,8 @@ static void termp_lb_post(DECL_ARGS) { - term_newln(p); + if (SEC_LIBRARY == node->sec) + term_newln(p); } @@ -1527,10 +1519,6 @@ termp_fn_pre(DECL_ARGS) { const struct mdoc_node *n; - assert(node->child && MDOC_TEXT == node->child->type); - - /* FIXME: can be "type funcname" "type varname"... */ - p->bold++; term_word(p, node->child->string); p->bold--; @@ -1853,6 +1841,7 @@ termp_in_post(DECL_ARGS) { p->bold++; + p->flags |= TERMP_NOSPACE; term_word(p, ">"); p->bold--; @@ -1877,12 +1866,18 @@ termp_sp_pre(DECL_ARGS) { int i, len; - if (NULL == node->child) { - term_vspace(p); - return(0); + switch (node->tok) { + case (MDOC_sp): + len = node->child ? atoi(node->child->string) : 1; + break; + case (MDOC_br): + len = 0; + break; + default: + len = 1; + break; } - len = atoi(node->child->string); if (0 == len) term_newln(p); for (i = 0; i < len; i++) @@ -1894,16 +1889,6 @@ termp_sp_pre(DECL_ARGS) /* ARGSUSED */ static int -termp_br_pre(DECL_ARGS) -{ - - term_newln(p); - return(1); -} - - -/* ARGSUSED */ -static int termp_brq_pre(DECL_ARGS) { @@ -2121,3 +2106,4 @@ termp_under_pre(DECL_ARGS) p->under++; return(1); } +