=================================================================== RCS file: /cvs/mandoc/man_term.c,v retrieving revision 1.157 retrieving revision 1.162 diff -u -p -r1.157 -r1.162 --- mandoc/man_term.c 2014/12/02 10:08:06 1.157 +++ mandoc/man_term.c 2014/12/23 09:31:46 1.162 @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.157 2014/12/02 10:08:06 schwarze Exp $ */ +/* $Id: man_term.c,v 1.162 2014/12/23 09:31:46 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -57,7 +57,6 @@ struct termact { }; static int a2width(const struct termp *, const char *); -static size_t a2height(const struct termp *, const char *); static void print_man_nodelist(DECL_ARGS); static void print_man_node(DECL_ARGS); @@ -123,7 +122,7 @@ static const struct termact termacts[MAN_MAX] = { { NULL, NULL, 0 }, /* RE */ { pre_RS, post_RS, 0 }, /* RS */ { pre_ign, NULL, 0 }, /* DT */ - { pre_ign, NULL, 0 }, /* UC */ + { pre_ign, NULL, MAN_NOTEXT }, /* UC */ { pre_PD, NULL, MAN_NOTEXT }, /* PD */ { pre_ign, NULL, 0 }, /* AT */ { pre_in, NULL, MAN_NOTEXT }, /* in */ @@ -184,24 +183,12 @@ terminal_man(void *arg, const struct man *man) } } - -static size_t -a2height(const struct termp *p, const char *cp) -{ - struct roffsu su; - - if ( ! a2roffsu(cp, &su, SCALE_VS)) - SCALE_VS_INIT(&su, atoi(cp)); - - return(term_vspan(p, &su)); -} - static int a2width(const struct termp *p, const char *cp) { struct roffsu su; - if ( ! a2roffsu(cp, &su, SCALE_BU)) + if ( ! a2roffsu(cp, &su, SCALE_EN)) return(-1); return((int)term_hspan(p, &su)); @@ -288,14 +275,16 @@ pre_literal(DECL_ARGS) static int pre_PD(DECL_ARGS) { + struct roffsu su; n = n->child; - if (0 == n) { + if (n == NULL) { mt->pardist = 1; return(0); } assert(MAN_TEXT == n->type); - mt->pardist = atoi(n->string); + if (a2roffsu(n->string, &su, SCALE_VS)) + mt->pardist = term_vspan(p, &su); return(0); } @@ -462,6 +451,7 @@ pre_in(DECL_ARGS) static int pre_sp(DECL_ARGS) { + struct roffsu su; char *s; size_t i, len; int neg; @@ -499,7 +489,9 @@ pre_sp(DECL_ARGS) neg = 1; s++; } - len = a2height(p, s); + if ( ! a2roffsu(s, &su, SCALE_VS)) + su.scale = 1.0; + len = term_vspan(p, &su); break; } @@ -631,11 +623,10 @@ pre_IP(DECL_ARGS) p->offset = mt->offset; p->rmargin = mt->offset + len; - if (ival < 0) - break; /* Set the saved left-margin. */ - mt->lmargin[mt->lmargincur] = (size_t)ival; + if (ival >= 0) + mt->lmargin[mt->lmargincur] = (size_t)ival; savelit = MANT_LITERAL & mt->fl; mt->fl &= ~MANT_LITERAL; @@ -778,12 +769,18 @@ pre_SS(DECL_ARGS) mt->fl &= ~MANT_LITERAL; mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); mt->offset = term_len(p, p->defindent); - /* If following a prior empty `SS', no vspace. */ - if (n->prev && MAN_SS == n->prev->tok) - if (NULL == n->prev->body->child) - break; - if (NULL == n->prev) + + /* + * No vertical space before the first subsection + * and after an empty subsection. + */ + + do { + n = n->prev; + } while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT); + if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL)) break; + for (i = 0; i < mt->pardist; i++) term_vspace(p); break; @@ -827,13 +824,18 @@ pre_SH(DECL_ARGS) mt->fl &= ~MANT_LITERAL; mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); mt->offset = term_len(p, p->defindent); - /* If following a prior empty `SH', no vspace. */ - if (n->prev && MAN_SH == n->prev->tok) - if (NULL == n->prev->body->child) - break; - /* If the first macro, no vspae. */ - if (NULL == n->prev) + + /* + * No vertical space before the first section + * and after an empty section. + */ + + do { + n = n->prev; + } while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT); + if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL)) break; + for (i = 0; i < mt->pardist; i++) term_vspace(p); break;