version 1.155, 2014/10/28 17:36:19 |
version 1.158, 2014/12/04 01:33:42 |
Line 123 static const struct termact termacts[MAN_MAX] = { |
|
Line 123 static const struct termact termacts[MAN_MAX] = { |
|
{ NULL, NULL, 0 }, /* RE */ |
{ NULL, NULL, 0 }, /* RE */ |
{ pre_RS, post_RS, 0 }, /* RS */ |
{ pre_RS, post_RS, 0 }, /* RS */ |
{ pre_ign, NULL, 0 }, /* DT */ |
{ pre_ign, NULL, 0 }, /* DT */ |
{ pre_ign, NULL, 0 }, /* UC */ |
{ pre_ign, NULL, MAN_NOTEXT }, /* UC */ |
{ pre_PD, NULL, MAN_NOTEXT }, /* PD */ |
{ pre_PD, NULL, MAN_NOTEXT }, /* PD */ |
{ pre_ign, NULL, 0 }, /* AT */ |
{ pre_ign, NULL, 0 }, /* AT */ |
{ pre_in, NULL, MAN_NOTEXT }, /* in */ |
{ pre_in, NULL, MAN_NOTEXT }, /* in */ |
Line 456 pre_in(DECL_ARGS) |
|
Line 456 pre_in(DECL_ARGS) |
|
else |
else |
p->offset = v; |
p->offset = v; |
|
|
/* Don't let this creep beyond the right margin. */ |
|
|
|
if (p->offset > p->rmargin) |
|
p->offset = p->rmargin; |
|
|
|
return(0); |
return(0); |
} |
} |
|
|
Line 654 pre_IP(DECL_ARGS) |
|
Line 649 pre_IP(DECL_ARGS) |
|
return(0); |
return(0); |
case MAN_BODY: |
case MAN_BODY: |
p->offset = mt->offset + len; |
p->offset = mt->offset + len; |
p->rmargin = p->maxrmargin > p->offset ? |
p->rmargin = p->maxrmargin; |
p->maxrmargin : p->offset; |
|
break; |
break; |
default: |
default: |
break; |
break; |
Line 746 pre_TP(DECL_ARGS) |
|
Line 740 pre_TP(DECL_ARGS) |
|
return(0); |
return(0); |
case MAN_BODY: |
case MAN_BODY: |
p->offset = mt->offset + len; |
p->offset = mt->offset + len; |
p->rmargin = p->maxrmargin > p->offset ? |
p->rmargin = p->maxrmargin; |
p->maxrmargin : p->offset; |
|
p->trailspace = 0; |
p->trailspace = 0; |
p->flags &= ~TERMP_NOBREAK; |
p->flags &= ~TERMP_NOBREAK; |
break; |
break; |
Line 785 pre_SS(DECL_ARGS) |
|
Line 778 pre_SS(DECL_ARGS) |
|
mt->fl &= ~MANT_LITERAL; |
mt->fl &= ~MANT_LITERAL; |
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); |
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); |
mt->offset = 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) |
* No vertical space before the first subsection |
break; |
* and after an empty subsection. |
if (NULL == n->prev) |
*/ |
|
|
|
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; |
break; |
|
|
for (i = 0; i < mt->pardist; i++) |
for (i = 0; i < mt->pardist; i++) |
term_vspace(p); |
term_vspace(p); |
break; |
break; |
Line 834 pre_SH(DECL_ARGS) |
|
Line 833 pre_SH(DECL_ARGS) |
|
mt->fl &= ~MANT_LITERAL; |
mt->fl &= ~MANT_LITERAL; |
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); |
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); |
mt->offset = 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) |
* No vertical space before the first section |
break; |
* and after an empty section. |
/* If the first macro, no vspae. */ |
*/ |
if (NULL == n->prev) |
|
|
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; |
break; |
|
|
for (i = 0; i < mt->pardist; i++) |
for (i = 0; i < mt->pardist; i++) |
term_vspace(p); |
term_vspace(p); |
break; |
break; |
Line 898 pre_RS(DECL_ARGS) |
|
Line 902 pre_RS(DECL_ARGS) |
|
|
|
mt->offset += sz; |
mt->offset += sz; |
p->offset = mt->offset; |
p->offset = mt->offset; |
p->rmargin = p->maxrmargin > p->offset ? |
p->rmargin = p->maxrmargin; |
p->maxrmargin : p->offset; |
|
|
|
if (++mt->lmarginsz < MAXMARGINS) |
if (++mt->lmarginsz < MAXMARGINS) |
mt->lmargincur = mt->lmarginsz; |
mt->lmargincur = mt->lmarginsz; |
|
|
* -man doesn't have nested macros, we don't need to be |
* -man doesn't have nested macros, we don't need to be |
* more specific than this. |
* more specific than this. |
*/ |
*/ |
if (MANT_LITERAL & mt->fl && ! (TERMP_NOBREAK & p->flags) && |
if (mt->fl & MANT_LITERAL && |
(NULL == n->next || MAN_LINE & n->next->flags)) { |
! (p->flags & (TERMP_NOBREAK | TERMP_NONEWLINE)) && |
|
(n->next == NULL || n->next->flags & MAN_LINE)) { |
rm = p->rmargin; |
rm = p->rmargin; |
rmax = p->maxrmargin; |
rmax = p->maxrmargin; |
p->rmargin = p->maxrmargin = TERM_MAXMARGIN; |
p->rmargin = p->maxrmargin = TERM_MAXMARGIN; |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
if (NULL != n->string && '\0' != *n->string) |
if (n->string != NULL && *n->string != '\0') |
term_flushln(p); |
term_flushln(p); |
else |
else |
term_newln(p); |
term_newln(p); |
Line 1063 print_man_foot(struct termp *p, const void *arg) |
|
Line 1067 print_man_foot(struct termp *p, const void *arg) |
|
{ |
{ |
const struct man_meta *meta; |
const struct man_meta *meta; |
char *title; |
char *title; |
size_t datelen; |
size_t datelen, titlen; |
|
|
meta = (const struct man_meta *)arg; |
meta = (const struct man_meta *)arg; |
assert(meta->title); |
assert(meta->title); |
Line 1100 print_man_foot(struct termp *p, const void *arg) |
|
Line 1104 print_man_foot(struct termp *p, const void *arg) |
|
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
p->trailspace = 1; |
p->trailspace = 1; |
p->offset = 0; |
p->offset = 0; |
p->rmargin = (p->maxrmargin - datelen + term_len(p, 1)) / 2; |
p->rmargin = p->maxrmargin > datelen ? |
|
(p->maxrmargin + term_len(p, 1) - datelen) / 2 : 0; |
|
|
if (meta->source) |
if (meta->source) |
term_word(p, meta->source); |
term_word(p, meta->source); |
Line 1108 print_man_foot(struct termp *p, const void *arg) |
|
Line 1113 print_man_foot(struct termp *p, const void *arg) |
|
|
|
/* At the bottom in the middle: manual date. */ |
/* At the bottom in the middle: manual date. */ |
|
|
p->flags |= TERMP_NOSPACE; |
|
p->offset = p->rmargin; |
p->offset = p->rmargin; |
p->rmargin = p->maxrmargin - term_strlen(p, title); |
titlen = term_strlen(p, title); |
if (p->offset + datelen >= p->rmargin) |
p->rmargin = p->maxrmargin > titlen ? p->maxrmargin - titlen : 0; |
p->rmargin = p->offset + datelen; |
p->flags |= TERMP_NOSPACE; |
|
|
term_word(p, meta->date); |
term_word(p, meta->date); |
term_flushln(p); |
term_flushln(p); |
Line 1155 print_man_head(struct termp *p, const void *arg) |
|
Line 1159 print_man_head(struct termp *p, const void *arg) |
|
p->offset = 0; |
p->offset = 0; |
p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ? |
p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ? |
(p->maxrmargin - vollen + term_len(p, 1)) / 2 : |
(p->maxrmargin - vollen + term_len(p, 1)) / 2 : |
p->maxrmargin - vollen; |
vollen < p->maxrmargin ? p->maxrmargin - vollen : 0; |
|
|
term_word(p, title); |
term_word(p, title); |
term_flushln(p); |
term_flushln(p); |