=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_term.c,v retrieving revision 1.131 retrieving revision 1.132 diff -c -r1.131 -r1.132 *** src/usr.bin/mandoc/mdoc_term.c 2011/03/20 23:36:42 1.131 --- src/usr.bin/mandoc/mdoc_term.c 2011/04/24 16:22:02 1.132 *************** *** 1,4 **** ! /* $Id: mdoc_term.c,v 1.131 2011/03/20 23:36:42 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze --- 1,4 ---- ! /* $Id: mdoc_term.c,v 1.132 2011/04/24 16:22:02 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze *************** *** 28,34 **** #include "out.h" #include "term.h" #include "mdoc.h" - #include "chars.h" #include "main.h" #define INDENT 5 --- 28,33 ---- *************** *** 348,354 **** --- 347,357 ---- case (MDOC_TEXT): if (' ' == *n->string && MDOC_LINE & n->flags) term_newln(p); + if (MDOC_DELIMC & n->flags) + p->flags |= TERMP_NOSPACE; term_word(p, n->string); + if (MDOC_DELIMO & n->flags) + p->flags |= TERMP_NOSPACE; break; case (MDOC_EQN): term_word(p, n->eqn->data); *************** *** 1176,1200 **** static int termp_rv_pre(DECL_ARGS) { ! const struct mdoc_node *nn; term_newln(p); term_word(p, "The"); ! for (nn = n->child; nn; nn = nn->next) { term_fontpush(p, TERMFONT_BOLD); ! term_word(p, nn->string); term_fontpop(p); p->flags |= TERMP_NOSPACE; ! if (nn->next && NULL == nn->next->next) ! term_word(p, "(), and"); ! else if (nn->next) ! term_word(p, "(),"); ! else ! term_word(p, "()"); } ! if (n->child && n->child->next) term_word(p, "functions return"); else term_word(p, "function returns"); --- 1179,1208 ---- static int termp_rv_pre(DECL_ARGS) { ! int nchild; term_newln(p); term_word(p, "The"); ! nchild = n->nchild; ! for (n = n->child; n; n = n->next) { term_fontpush(p, TERMFONT_BOLD); ! term_word(p, n->string); term_fontpop(p); + p->flags |= TERMP_NOSPACE; ! term_word(p, "()"); ! ! if (nchild > 2 && n->next) { ! p->flags |= TERMP_NOSPACE; ! term_word(p, ","); ! } ! ! if (n->next && NULL == n->next->next) ! term_word(p, "and"); } ! if (nchild > 1) term_word(p, "functions return"); else term_word(p, "function returns"); *************** *** 1217,1247 **** static int termp_ex_pre(DECL_ARGS) { ! const struct mdoc_node *nn; term_word(p, "The"); ! for (nn = n->child; nn; nn = nn->next) { term_fontpush(p, TERMFONT_BOLD); ! term_word(p, nn->string); term_fontpop(p); ! p->flags |= TERMP_NOSPACE; ! if (nn->next && NULL == nn->next->next) ! term_word(p, ", and"); ! else if (nn->next) term_word(p, ","); ! else ! p->flags &= ~TERMP_NOSPACE; } ! if (n->child && n->child->next) term_word(p, "utilities exit"); else term_word(p, "utility exits"); term_word(p, "0 on success, and >0 if an error occurs."); - p->flags |= TERMP_SENTENCE; return(0); } --- 1225,1258 ---- static int termp_ex_pre(DECL_ARGS) { ! int nchild; + term_newln(p); term_word(p, "The"); ! nchild = n->nchild; ! for (n = n->child; n; n = n->next) { term_fontpush(p, TERMFONT_BOLD); ! term_word(p, n->string); term_fontpop(p); ! ! if (nchild > 2 && n->next) { ! p->flags |= TERMP_NOSPACE; term_word(p, ","); ! } ! ! if (n->next && NULL == n->next->next) ! term_word(p, "and"); } ! if (nchild > 1) term_word(p, "utilities exit"); else term_word(p, "utility exits"); term_word(p, "0 on success, and >0 if an error occurs."); + p->flags |= TERMP_SENTENCE; return(0); } *************** *** 1281,1311 **** term_newln(p); } - /* ARGSUSED */ static int termp_xr_pre(DECL_ARGS) { - const struct mdoc_node *nn; ! if (NULL == n->child) return(0); ! assert(MDOC_TEXT == n->child->type); ! nn = n->child; ! term_word(p, nn->string); ! if (NULL == (nn = nn->next)) return(0); p->flags |= TERMP_NOSPACE; term_word(p, "("); ! term_word(p, nn->string); term_word(p, ")"); return(0); } - /* * This decides how to assert whitespace before any of the SYNOPSIS set * of macros (which, as in the case of Ft/Fo and Ft/Fn, may contain --- 1292,1324 ---- term_newln(p); } /* ARGSUSED */ static int termp_xr_pre(DECL_ARGS) { ! if (NULL == (n = n->child)) return(0); ! assert(MDOC_TEXT == n->type); ! term_word(p, n->string); ! if (NULL == (n = n->next)) return(0); + p->flags |= TERMP_NOSPACE; term_word(p, "("); ! p->flags |= TERMP_NOSPACE; ! ! assert(MDOC_TEXT == n->type); ! term_word(p, n->string); ! ! p->flags |= TERMP_NOSPACE; term_word(p, ")"); return(0); } /* * This decides how to assert whitespace before any of the SYNOPSIS set * of macros (which, as in the case of Ft/Fo and Ft/Fn, may contain *************** *** 1519,1548 **** static int termp_fn_pre(DECL_ARGS) { ! const struct mdoc_node *nn; synopsis_pre(p, n); term_fontpush(p, TERMFONT_BOLD); ! term_word(p, n->child->string); term_fontpop(p); p->flags |= TERMP_NOSPACE; term_word(p, "("); ! for (nn = n->child->next; nn; nn = nn->next) { term_fontpush(p, TERMFONT_UNDER); ! term_word(p, nn->string); term_fontpop(p); ! if (nn->next) term_word(p, ","); } term_word(p, ")"); ! if (MDOC_SYNPRETTY & n->flags) term_word(p, ";"); return(0); } --- 1532,1574 ---- static int termp_fn_pre(DECL_ARGS) { ! int pretty; + pretty = MDOC_SYNPRETTY & n->flags; + synopsis_pre(p, n); + if (NULL == (n = n->child)) + return(0); + + assert(MDOC_TEXT == n->type); term_fontpush(p, TERMFONT_BOLD); ! term_word(p, n->string); term_fontpop(p); p->flags |= TERMP_NOSPACE; term_word(p, "("); + p->flags |= TERMP_NOSPACE; ! for (n = n->next; n; n = n->next) { ! assert(MDOC_TEXT == n->type); term_fontpush(p, TERMFONT_UNDER); ! term_word(p, n->string); term_fontpop(p); ! if (n->next) { ! p->flags |= TERMP_NOSPACE; term_word(p, ","); + } } + p->flags |= TERMP_NOSPACE; term_word(p, ")"); ! if (pretty) { ! p->flags |= TERMP_NOSPACE; term_word(p, ";"); + } return(0); } *************** *** 1564,1575 **** term_word(p, nn->string); term_fontpop(p); ! if (nn->next) term_word(p, ","); } ! if (n->child && n->next && n->next->tok == MDOC_Fa) term_word(p, ","); return(0); } --- 1590,1605 ---- term_word(p, nn->string); term_fontpop(p); ! if (nn->next) { ! p->flags |= TERMP_NOSPACE; term_word(p, ","); + } } ! if (n->child && n->next && n->next->tok == MDOC_Fa) { ! p->flags |= TERMP_NOSPACE; term_word(p, ","); + } return(0); } *************** *** 2004,2009 **** --- 2034,2040 ---- } else if (MDOC_BODY == n->type) { p->flags |= TERMP_NOSPACE; term_word(p, "("); + p->flags |= TERMP_NOSPACE; return(1); } *************** *** 2027,2036 **** if (MDOC_BODY != n->type) return; term_word(p, ")"); ! if (MDOC_SYNPRETTY & n->flags) term_word(p, ";"); } --- 2058,2070 ---- if (MDOC_BODY != n->type) return; + p->flags |= TERMP_NOSPACE; term_word(p, ")"); ! if (MDOC_SYNPRETTY & n->flags) { ! p->flags |= TERMP_NOSPACE; term_word(p, ";"); + } } *************** *** 2104,2109 **** --- 2138,2144 ---- if (NULL == n->parent || MDOC_Rs != n->parent->tok) return; + p->flags |= TERMP_NOSPACE; if (NULL == n->next) { term_word(p, "."); p->flags |= TERMP_SENTENCE; *************** *** 2140,2145 **** --- 2175,2181 ---- term_fontpop(p); + p->flags |= TERMP_NOSPACE; term_word(p, ":"); term_fontpush(p, TERMFONT_BOLD);