=================================================================== RCS file: /cvs/mandoc/man_term.c,v retrieving revision 1.118 retrieving revision 1.122 diff -u -p -r1.118 -r1.122 --- mandoc/man_term.c 2011/09/20 09:02:23 1.118 +++ mandoc/man_term.c 2011/11/13 13:15:14 1.122 @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.118 2011/09/20 09:02:23 schwarze Exp $ */ +/* $Id: man_term.c,v 1.122 2011/11/13 13:15:14 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -33,8 +33,6 @@ #include "term.h" #include "main.h" -#define INDENT 7 /* fixed-width char full-indent */ -#define HALFINDENT 3 /* fixed-width char half-indent */ #define MAXMARGINS 64 /* maximum number of indented scopes */ /* FIXME: have PD set the default vspace width. */ @@ -141,6 +139,9 @@ terminal_man(void *arg, const struct man *man) p = (struct termp *)arg; + if (0 == p->defindent) + p->defindent = 7; + p->overstep = 0; p->maxrmargin = p->defrmargin; p->tabwidth = term_len(p, 5); @@ -156,8 +157,8 @@ terminal_man(void *arg, const struct man *man) memset(&mt, 0, sizeof(struct mtermp)); - mt.lmargin[mt.lmargincur] = term_len(p, INDENT); - mt.offset = term_len(p, INDENT); + mt.lmargin[mt.lmargincur] = term_len(p, p->defindent); + mt.offset = term_len(p, p->defindent); if (n->child) print_man_nodelist(p, &mt, n->child, m); @@ -251,7 +252,7 @@ pre_literal(DECL_ARGS) * indentation has to be set up explicitly. */ if (MAN_HP == n->parent->tok && p->rmargin < p->maxrmargin) { - p->offset = p->rmargin + 1; + p->offset = p->rmargin; p->rmargin = p->maxrmargin; p->flags &= ~(TERMP_NOBREAK | TERMP_TWOSPACE); p->flags |= TERMP_NOSPACE; @@ -469,9 +470,7 @@ pre_HP(DECL_ARGS) len = (size_t)ival; one = term_len(p, 1); - if (len > one) - len -= one; - else + if (len < one) len = one; p->offset = mt->offset; @@ -513,7 +512,7 @@ pre_PP(DECL_ARGS) switch (n->type) { case (MAN_BLOCK): - mt->lmargin[mt->lmargincur] = term_len(p, INDENT); + mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); print_bvspace(p, n); break; default: @@ -640,7 +639,7 @@ pre_TP(DECL_ARGS) /* Calculate offset. */ if (NULL != (nn = n->parent->head->child)) - if (nn->parent->line == nn->line) + if (nn->string && nn->parent->line == nn->line) if ((ival = a2width(p, nn->string)) >= 0) len = (size_t)ival; @@ -708,8 +707,8 @@ pre_SS(DECL_ARGS) switch (n->type) { case (MAN_BLOCK): mt->fl &= ~MANT_LITERAL; - mt->lmargin[mt->lmargincur] = term_len(p, INDENT); - mt->offset = term_len(p, INDENT); + 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) @@ -720,7 +719,7 @@ pre_SS(DECL_ARGS) break; case (MAN_HEAD): term_fontrepl(p, TERMFONT_BOLD); - p->offset = term_len(p, HALFINDENT); + p->offset = term_len(p, p->defindent/2); break; case (MAN_BODY): p->offset = mt->offset; @@ -759,8 +758,8 @@ pre_SH(DECL_ARGS) switch (n->type) { case (MAN_BLOCK): mt->fl &= ~MANT_LITERAL; - mt->lmargin[mt->lmargincur] = term_len(p, INDENT); - mt->offset = term_len(p, INDENT); + 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) @@ -819,14 +818,15 @@ pre_RS(DECL_ARGS) break; } - sz = term_len(p, INDENT); + sz = term_len(p, p->defindent); if (NULL != (n = n->parent->head->child)) if ((ival = a2width(p, n->string)) >= 0) sz = (size_t)ival; mt->offset += sz; - p->offset = mt->offset; + p->rmargin = p->maxrmargin; + p->offset = mt->offset < p->rmargin ? mt->offset : p->rmargin; if (++mt->lmarginsz < MAXMARGINS) mt->lmargincur = mt->lmarginsz; @@ -852,7 +852,7 @@ post_RS(DECL_ARGS) break; } - sz = term_len(p, INDENT); + sz = term_len(p, p->defindent); if (NULL != (n = n->parent->head->child)) if ((ival = a2width(p, n->string)) >= 0)