*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
const struct roff_node *, int);
static int pre_B(DECL_ARGS);
const struct roff_node *, int);
static int pre_B(DECL_ARGS);
static int pre_HP(DECL_ARGS);
static int pre_I(DECL_ARGS);
static int pre_IP(DECL_ARGS);
static int pre_HP(DECL_ARGS);
static int pre_I(DECL_ARGS);
static int pre_IP(DECL_ARGS);
static int pre_TP(DECL_ARGS);
static int pre_UR(DECL_ARGS);
static int pre_alternate(DECL_ARGS);
static int pre_TP(DECL_ARGS);
static int pre_UR(DECL_ARGS);
static int pre_alternate(DECL_ARGS);
static int pre_ign(DECL_ARGS);
static int pre_in(DECL_ARGS);
static int pre_literal(DECL_ARGS);
static int pre_ign(DECL_ARGS);
static int pre_in(DECL_ARGS);
static int pre_literal(DECL_ARGS);
-static const struct termact termacts[MAN_MAX] = {
- { pre_sp, NULL, MAN_NOTEXT }, /* br */
+static const struct termact __termacts[MAN_MAX - MAN_TH] = {
{ NULL, NULL, 0 }, /* TH */
{ pre_SH, post_SH, 0 }, /* SH */
{ pre_SS, post_SS, 0 }, /* SS */
{ NULL, NULL, 0 }, /* TH */
{ pre_SH, post_SH, 0 }, /* SH */
{ pre_SS, post_SS, 0 }, /* SS */
{ pre_I, NULL, 0 }, /* I */
{ pre_alternate, NULL, 0 }, /* IR */
{ pre_alternate, NULL, 0 }, /* RI */
{ pre_I, NULL, 0 }, /* I */
{ pre_alternate, NULL, 0 }, /* IR */
{ pre_alternate, NULL, 0 }, /* RI */
{ pre_literal, NULL, 0 }, /* nf */
{ pre_literal, NULL, 0 }, /* fi */
{ NULL, NULL, 0 }, /* RE */
{ pre_RS, post_RS, 0 }, /* RS */
{ pre_literal, NULL, 0 }, /* nf */
{ pre_literal, NULL, 0 }, /* fi */
{ NULL, NULL, 0 }, /* RE */
{ pre_RS, post_RS, 0 }, /* RS */
- { pre_ign, NULL, 0 }, /* DT */
+ { pre_DT, NULL, 0 }, /* DT */
{ pre_ign, NULL, MAN_NOTEXT }, /* UC */
{ pre_PD, NULL, MAN_NOTEXT }, /* PD */
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
{ pre_ign, NULL, MAN_NOTEXT }, /* UC */
{ pre_PD, NULL, MAN_NOTEXT }, /* PD */
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
{ pre_OP, NULL, 0 }, /* OP */
{ pre_literal, NULL, 0 }, /* EX */
{ pre_literal, NULL, 0 }, /* EE */
{ pre_UR, post_UR, 0 }, /* UR */
{ NULL, NULL, 0 }, /* UE */
{ pre_OP, NULL, 0 }, /* OP */
{ pre_literal, NULL, 0 }, /* EX */
{ pre_literal, NULL, 0 }, /* EE */
{ pre_UR, post_UR, 0 }, /* UR */
{ NULL, NULL, 0 }, /* UE */
- { pre_ll, NULL, MAN_NOTEXT }, /* ll */
+ { pre_UR, post_UR, 0 }, /* MT */
+ { NULL, NULL, 0 }, /* ME */
- p->overstep = 0;
- p->rmargin = p->maxrmargin = p->defrmargin;
- p->tabwidth = term_len(p, 5);
+ save_defindent = p->defindent;
+ if (p->synopsisonly == 0 && p->defindent == 0)
+ p->defindent = 7;
+ p->tcol->rmargin = p->maxrmargin = p->defrmargin;
+ term_tab_set(p, NULL);
+ term_tab_set(p, "T");
+ term_tab_set(p, ".5i");
memset(&mt, 0, sizeof(struct mtermp));
mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
memset(&mt, 0, sizeof(struct mtermp));
mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
term_begin(p, print_man_head, print_man_foot, &man->meta);
p->flags |= TERMP_NOSPACE;
if (n != NULL)
print_man_nodelist(p, &mt, n, &man->meta);
term_end(p);
}
term_begin(p, print_man_head, print_man_foot, &man->meta);
p->flags |= TERMP_NOSPACE;
if (n != NULL)
print_man_nodelist(p, &mt, n, &man->meta);
term_end(p);
}
* So in case a second call to term_flushln() is needed,
* indentation has to be set up explicitly.
*/
* So in case a second call to term_flushln() is needed,
* indentation has to be set up explicitly.
*/
- if (MAN_HP == n->parent->tok && p->rmargin < p->maxrmargin) {
- p->offset = p->rmargin;
- p->rmargin = p->maxrmargin;
+ if (n->parent->tok == MAN_HP && p->tcol->rmargin < p->maxrmargin) {
+ p->tcol->offset = p->tcol->rmargin;
+ p->tcol->rmargin = p->maxrmargin;
mt->fl |= MANT_LITERAL;
assert(nn->type == ROFFT_TEXT);
term_word(p, nn->string);
mt->fl |= MANT_LITERAL;
assert(nn->type == ROFFT_TEXT);
term_word(p, nn->string);
term_fontrepl(p, TERMFONT_NONE);
p->flags |= TERMP_NOSPACE;
term_word(p, "]");
term_fontrepl(p, TERMFONT_NONE);
p->flags |= TERMP_NOSPACE;
term_word(p, "]");
- return(0);
-}
-
-static int
-pre_ft(DECL_ARGS)
-{
- const char *cp;
-
- if (NULL == n->child) {
- term_fontlast(p);
- return(0);
- }
-
- cp = n->child->string;
- switch (*cp) {
- case '4':
- /* FALLTHROUGH */
- case '3':
- /* FALLTHROUGH */
- case 'B':
- term_fontrepl(p, TERMFONT_BOLD);
- break;
- case '2':
- /* FALLTHROUGH */
- case 'I':
- term_fontrepl(p, TERMFONT_UNDER);
- break;
- case 'P':
- term_fontlast(p);
- break;
- case '1':
- /* FALLTHROUGH */
- case 'C':
- /* FALLTHROUGH */
- case 'R':
- term_fontrepl(p, TERMFONT_NONE);
- break;
- default:
- break;
- }
- return(0);
- p->offset = v;
- if (p->offset > SHRT_MAX)
- p->offset = term_len(p, p->defindent);
+ p->tcol->offset = v;
+ if (p->tcol->offset > SHRT_MAX)
+ p->tcol->offset = term_len(p, p->defindent);
- struct roffsu su;
- int i, len;
-
- if ((NULL == n->prev && n->parent)) {
- switch (n->parent->tok) {
- case MAN_SH:
- /* FALLTHROUGH */
- case MAN_SS:
- /* FALLTHROUGH */
- case MAN_PP:
- /* FALLTHROUGH */
- case MAN_LP:
- /* FALLTHROUGH */
- case MAN_P:
- /* FALLTHROUGH */
- return(0);
- default:
- break;
- }
- }
-
- if (n->tok == MAN_br)
- len = 0;
- else if (n->child == NULL)
- len = 1;
- else {
- if ( ! a2roffsu(n->child->string, &su, SCALE_VS))
- su.scale = 1.0;
- len = term_vspan(p, &su);
- }
-
- if (len == 0)
- term_newln(p);
- else if (len < 0)
- p->skipvsp -= len;
- else
- for (i = 0; i < len; i++)
- term_vspace(p);
-
- return(0);
+ term_tab_set(p, NULL);
+ term_tab_set(p, "T");
+ term_tab_set(p, ".5i");
+ return 0;
- a2roffsu(nn->string, &su, SCALE_EN)) {
- len = term_hspan(p, &su) / 24;
+ a2roffsu(nn->string, &su, SCALE_EN) != NULL) {
+ len = term_hen(p, &su);
}
/* Calculate the offset from the optional second argument. */
if ((nn = n->parent->head->child) != NULL &&
(nn = nn->next) != NULL &&
}
/* Calculate the offset from the optional second argument. */
if ((nn = n->parent->head->child) != NULL &&
(nn = nn->next) != NULL &&
- a2roffsu(nn->string, &su, SCALE_EN)) {
- len = term_hspan(p, &su) / 24;
+ a2roffsu(nn->string, &su, SCALE_EN) != NULL) {
+ len = term_hen(p, &su);
- nn->string != NULL && ! (MAN_LINE & nn->flags) &&
- a2roffsu(nn->string, &su, SCALE_EN)) {
- len = term_hspan(p, &su) / 24;
+ nn->string != NULL && ! (NODE_LINE & nn->flags) &&
+ a2roffsu(nn->string, &su, SCALE_EN) != NULL) {
+ len = term_hen(p, &su);
- p->offset = term_len(p, 3);
- p->rmargin = mt->offset;
+ p->tcol->offset = term_len(p, 3);
+ p->tcol->rmargin = mt->offset;
- } while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT);
- if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL))
+ } while (n != NULL && n->tok >= MAN_TH &&
+ termacts[n->tok].flags & MAN_NOTEXT);
+ if (n == NULL || n->type == ROFFT_COMMENT ||
+ (n->tok == MAN_SH && n->body->child == NULL))
- else if (a2roffsu(n->child->string, &su, SCALE_EN))
- n->aux = term_hspan(p, &su) / 24;
+ else if (a2roffsu(n->child->string, &su, SCALE_EN) != NULL)
+ n->aux = term_hen(p, &su);
if (n->aux < 0 && (size_t)(-n->aux) > mt->offset)
n->aux = -mt->offset;
else if (n->aux > SHRT_MAX)
n->aux = term_len(p, p->defindent);
mt->offset += n->aux;
if (n->aux < 0 && (size_t)(-n->aux) > mt->offset)
n->aux = -mt->offset;
else if (n->aux > SHRT_MAX)
n->aux = term_len(p, p->defindent);
mt->offset += n->aux;
if (++mt->lmarginsz < MAXMARGINS)
mt->lmargincur = mt->lmarginsz;
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
if (++mt->lmarginsz < MAXMARGINS)
mt->lmargincur = mt->lmarginsz;
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
* If we have a space as the first character, break
* before printing the line's data.
*/
* If we have a space as the first character, break
* before printing the line's data.
*/
if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
term_fontrepl(p, TERMFONT_NONE);
if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
term_fontrepl(p, TERMFONT_NONE);
- (n->next == NULL || n->next->flags & MAN_LINE)) {
- rm = p->rmargin;
- rmax = p->maxrmargin;
- p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
- p->flags |= TERMP_NOSPACE;
+ (n->next == NULL || n->next->flags & NODE_LINE)) {
+ p->flags |= TERMP_BRNEVER | TERMP_NOSPACE;
- if (rm < rmax && n->parent->tok == MAN_HP) {
- p->offset = rm;
- p->rmargin = rmax;
- } else
- p->rmargin = rm;
- p->maxrmargin = rmax;
+ p->flags &= ~TERMP_BRNEVER;
+ if (p->tcol->rmargin < p->maxrmargin &&
+ n->parent->tok == MAN_HP) {
+ p->tcol->offset = p->tcol->rmargin;
+ p->tcol->rmargin = p->maxrmargin;
+ }
p->flags |= TERMP_NOSPACE;
term_word(p, meta->date);
p->flags |= TERMP_NOSPACE;
term_word(p, meta->date);
+
+ /*
+ * Reset the terminal state for more output after the footer:
+ * Some output modes, in particular PostScript and PDF, print
+ * the header and the footer into a buffer such that it can be
+ * reused for multiple output pages, then go on to format the
+ * main text.
+ */
+
+ p->tcol->offset = 0;
+ p->flags = 0;
+
(p->maxrmargin - vollen + term_len(p, 1)) / 2 :
vollen < p->maxrmargin ? p->maxrmargin - vollen : 0;
(p->maxrmargin - vollen + term_len(p, 1)) / 2 :
vollen < p->maxrmargin ? p->maxrmargin - vollen : 0;
- p->offset = p->rmargin;
- p->rmargin = p->offset + vollen + titlen < p->maxrmargin ?
- p->maxrmargin - titlen : p->maxrmargin;
+ p->tcol->offset = p->tcol->rmargin;
+ p->tcol->rmargin = p->tcol->offset + vollen + titlen <
+ p->maxrmargin ? p->maxrmargin - titlen : p->maxrmargin;