=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.280 retrieving revision 1.283 diff -u -p -r1.280 -r1.283 --- mandoc/mdoc_term.c 2014/08/21 12:57:17 1.280 +++ mandoc/mdoc_term.c 2014/10/13 22:00:47 1.283 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.280 2014/08/21 12:57:17 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.283 2014/10/13 22:00:47 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -65,7 +65,6 @@ static void synopsis_pre(struct termp *, static void termp____post(DECL_ARGS); static void termp__t_post(DECL_ARGS); -static void termp_an_post(DECL_ARGS); static void termp_bd_post(DECL_ARGS); static void termp_bk_post(DECL_ARGS); static void termp_bl_post(DECL_ARGS); @@ -138,7 +137,7 @@ static const struct termact termacts[MDOC_MAX] = { { NULL, NULL }, /* El */ { termp_it_pre, termp_it_post }, /* It */ { termp_under_pre, NULL }, /* Ad */ - { termp_an_pre, termp_an_post }, /* An */ + { termp_an_pre, NULL }, /* An */ { termp_under_pre, NULL }, /* Ar */ { termp_cd_pre, NULL }, /* Cd */ { termp_bold_pre, NULL }, /* Cm */ @@ -252,34 +251,44 @@ static const struct termact termacts[MDOC_MAX] = { void terminal_mdoc(void *arg, const struct mdoc *mdoc) { - const struct mdoc_node *n; const struct mdoc_meta *meta; + struct mdoc_node *n; struct termp *p; p = (struct termp *)arg; - if (0 == p->defindent) - p->defindent = 5; - p->overstep = 0; - p->maxrmargin = p->defrmargin; + p->rmargin = p->maxrmargin = p->defrmargin; p->tabwidth = term_len(p, 5); if (NULL == p->symtab) p->symtab = mchars_alloc(); - n = mdoc_node(mdoc); + n = mdoc_node(mdoc)->child; meta = mdoc_meta(mdoc); - term_begin(p, print_mdoc_head, print_mdoc_foot, meta); - - if (n->child) { - if (MDOC_Sh != n->child->tok) - term_vspace(p); - print_mdoc_nodelist(p, NULL, meta, n->child); + if (p->synopsisonly) { + while (n != NULL) { + if (n->tok == MDOC_Sh && n->sec == SEC_SYNOPSIS) { + if (n->child->next->child != NULL) + print_mdoc_nodelist(p, NULL, + meta, n->child->next->child); + term_newln(p); + break; + } + n = n->next; + } + } else { + if (p->defindent == 0) + p->defindent = 5; + term_begin(p, print_mdoc_head, print_mdoc_foot, meta); + if (n != NULL) { + if (n->tok != MDOC_Sh) + term_vspace(p); + print_mdoc_nodelist(p, NULL, meta, n); + } + term_end(p); } - - term_end(p); } static void @@ -463,9 +472,6 @@ print_mdoc_head(struct termp *p, const void *arg) * switches on the manual section. */ - p->offset = 0; - p->rmargin = p->maxrmargin; - assert(meta->vol); if (NULL == meta->arch) volume = mandoc_strdup(meta->vol); @@ -535,8 +541,10 @@ a2width(const struct termp *p, const char *v) struct roffsu su; assert(v); - if ( ! a2roffsu(v, &su, SCALE_MAX)) + if ( ! a2roffsu(v, &su, SCALE_MAX)) { SCALE_HS_INIT(&su, term_strlen(p, v)); + su.scale /= term_strlen(p, "0"); + } return(term_hspan(p, &su)); } @@ -554,8 +562,10 @@ a2offs(const struct termp *p, const char *v) return(term_len(p, p->defindent + 1)); else if (0 == strcmp(v, "indent-two")) return(term_len(p, (p->defindent + 1) * 2)); - else if ( ! a2roffsu(v, &su, SCALE_MAX)) + else if ( ! a2roffsu(v, &su, SCALE_MAX)) { SCALE_HS_INIT(&su, term_strlen(p, v)); + su.scale /= term_strlen(p, "0"); + } return(term_hspan(p, &su)); } @@ -1099,54 +1109,27 @@ static int termp_an_pre(DECL_ARGS) { - if (NULL == n->child) - return(1); - - /* - * If not in the AUTHORS section, `An -split' will cause - * newlines to occur before the author name. If in the AUTHORS - * section, by default, the first `An' invocation is nosplit, - * then all subsequent ones, regardless of whether interspersed - * with other macros/text, are split. -split, in this case, - * will override the condition of the implied first -nosplit. - */ - - if (n->sec == SEC_AUTHORS) { - if ( ! (TERMP_ANPREC & p->flags)) { - if (TERMP_SPLIT & p->flags) - term_newln(p); - return(1); - } - if (TERMP_NOSPLIT & p->flags) - return(1); - term_newln(p); - return(1); - } - - if (TERMP_SPLIT & p->flags) - term_newln(p); - - return(1); -} - -static void -termp_an_post(DECL_ARGS) -{ - - if (n->child) { - if (SEC_AUTHORS == n->sec) - p->flags |= TERMP_ANPREC; - return; - } - - if (AUTH_split == n->norm->An.auth) { + if (n->norm->An.auth == AUTH_split) { p->flags &= ~TERMP_NOSPLIT; p->flags |= TERMP_SPLIT; - } else if (AUTH_nosplit == n->norm->An.auth) { + return(0); + } + if (n->norm->An.auth == AUTH_nosplit) { p->flags &= ~TERMP_SPLIT; p->flags |= TERMP_NOSPLIT; + return(0); } + if (n->child == NULL) + return(0); + + if (p->flags & TERMP_SPLIT) + term_newln(p); + + if (n->sec == SEC_AUTHORS && ! (p->flags & TERMP_NOSPLIT)) + p->flags |= TERMP_SPLIT; + + return(1); } static int