version 1.203, 2017/06/07 17:38:26 |
version 1.211, 2018/06/10 15:12:35 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 128 static const struct termact __termacts[MAN_MAX - MAN_T |
|
Line 128 static const struct termact __termacts[MAN_MAX - MAN_T |
|
{ pre_literal, NULL, 0 }, /* EE */ |
{ pre_literal, NULL, 0 }, /* EE */ |
{ pre_UR, post_UR, 0 }, /* UR */ |
{ pre_UR, post_UR, 0 }, /* UR */ |
{ NULL, NULL, 0 }, /* UE */ |
{ NULL, NULL, 0 }, /* UE */ |
|
{ pre_UR, post_UR, 0 }, /* MT */ |
|
{ NULL, NULL, 0 }, /* ME */ |
}; |
}; |
static const struct termact *termacts = __termacts - MAN_TH; |
static const struct termact *termacts = __termacts - MAN_TH; |
|
|
Line 141 terminal_man(void *arg, const struct roff_man *man) |
|
Line 143 terminal_man(void *arg, const struct roff_man *man) |
|
size_t save_defindent; |
size_t save_defindent; |
|
|
p = (struct termp *)arg; |
p = (struct termp *)arg; |
|
save_defindent = p->defindent; |
|
if (p->synopsisonly == 0 && p->defindent == 0) |
|
p->defindent = 7; |
p->tcol->rmargin = p->maxrmargin = p->defrmargin; |
p->tcol->rmargin = p->maxrmargin = p->defrmargin; |
term_tab_set(p, NULL); |
term_tab_set(p, NULL); |
term_tab_set(p, "T"); |
term_tab_set(p, "T"); |
Line 167 terminal_man(void *arg, const struct roff_man *man) |
|
Line 172 terminal_man(void *arg, const struct roff_man *man) |
|
n = n->next; |
n = n->next; |
} |
} |
} else { |
} else { |
save_defindent = p->defindent; |
|
if (p->defindent == 0) |
|
p->defindent = 7; |
|
term_begin(p, print_man_head, print_man_foot, &man->meta); |
term_begin(p, print_man_head, print_man_foot, &man->meta); |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
if (n != NULL) |
if (n != NULL) |
print_man_nodelist(p, &mt, n, &man->meta); |
print_man_nodelist(p, &mt, n, &man->meta); |
term_end(p); |
term_end(p); |
p->defindent = save_defindent; |
|
} |
} |
|
p->defindent = save_defindent; |
} |
} |
|
|
/* |
/* |
Line 260 pre_PD(DECL_ARGS) |
|
Line 262 pre_PD(DECL_ARGS) |
|
return 0; |
return 0; |
} |
} |
assert(n->type == ROFFT_TEXT); |
assert(n->type == ROFFT_TEXT); |
if (a2roffsu(n->string, &su, SCALE_VS)) |
if (a2roffsu(n->string, &su, SCALE_VS) != NULL) |
mt->pardist = term_vspan(p, &su); |
mt->pardist = term_vspan(p, &su); |
return 0; |
return 0; |
} |
} |
Line 374 pre_in(DECL_ARGS) |
|
Line 376 pre_in(DECL_ARGS) |
|
else |
else |
cp--; |
cp--; |
|
|
if ( ! a2roffsu(++cp, &su, SCALE_EN)) |
if (a2roffsu(++cp, &su, SCALE_EN) == NULL) |
return 0; |
return 0; |
|
|
v = (term_hspan(p, &su) + 11) / 24; |
v = term_hen(p, &su); |
|
|
if (less < 0) |
if (less < 0) |
p->tcol->offset -= p->tcol->offset > v ? v : p->tcol->offset; |
p->tcol->offset -= p->tcol->offset > v ? v : p->tcol->offset; |
Line 425 pre_HP(DECL_ARGS) |
|
Line 427 pre_HP(DECL_ARGS) |
|
/* Calculate offset. */ |
/* Calculate offset. */ |
|
|
if ((nn = n->parent->head->child) != NULL && |
if ((nn = n->parent->head->child) != NULL && |
a2roffsu(nn->string, &su, SCALE_EN)) { |
a2roffsu(nn->string, &su, SCALE_EN) != NULL) { |
len = term_hspan(p, &su) / 24; |
len = term_hen(p, &su); |
if (len < 0 && (size_t)(-len) > mt->offset) |
if (len < 0 && (size_t)(-len) > mt->offset) |
len = -mt->offset; |
len = -mt->offset; |
else if (len > SHRT_MAX) |
else if (len > SHRT_MAX) |
Line 510 pre_IP(DECL_ARGS) |
|
Line 512 pre_IP(DECL_ARGS) |
|
/* Calculate the offset from the optional second argument. */ |
/* Calculate the offset from the optional second argument. */ |
if ((nn = n->parent->head->child) != NULL && |
if ((nn = n->parent->head->child) != NULL && |
(nn = nn->next) != NULL && |
(nn = nn->next) != NULL && |
a2roffsu(nn->string, &su, SCALE_EN)) { |
a2roffsu(nn->string, &su, SCALE_EN) != NULL) { |
len = term_hspan(p, &su) / 24; |
len = term_hen(p, &su); |
if (len < 0 && (size_t)(-len) > mt->offset) |
if (len < 0 && (size_t)(-len) > mt->offset) |
len = -mt->offset; |
len = -mt->offset; |
else if (len > SHRT_MAX) |
else if (len > SHRT_MAX) |
Line 592 pre_TP(DECL_ARGS) |
|
Line 594 pre_TP(DECL_ARGS) |
|
|
|
if ((nn = n->parent->head->child) != NULL && |
if ((nn = n->parent->head->child) != NULL && |
nn->string != NULL && ! (NODE_LINE & nn->flags) && |
nn->string != NULL && ! (NODE_LINE & nn->flags) && |
a2roffsu(nn->string, &su, SCALE_EN)) { |
a2roffsu(nn->string, &su, SCALE_EN) != NULL) { |
len = term_hspan(p, &su) / 24; |
len = term_hen(p, &su); |
if (len < 0 && (size_t)(-len) > mt->offset) |
if (len < 0 && (size_t)(-len) > mt->offset) |
len = -mt->offset; |
len = -mt->offset; |
else if (len > SHRT_MAX) |
else if (len > SHRT_MAX) |
Line 671 pre_SS(DECL_ARGS) |
|
Line 673 pre_SS(DECL_ARGS) |
|
|
|
do { |
do { |
n = n->prev; |
n = n->prev; |
} while (n != NULL && n->tok != TOKEN_NONE && |
} while (n != NULL && n->tok >= MAN_TH && |
termacts[n->tok].flags & MAN_NOTEXT); |
termacts[n->tok].flags & MAN_NOTEXT); |
if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL)) |
if (n == NULL || n->type == ROFFT_COMMENT || |
|
(n->tok == MAN_SS && n->body->child == NULL)) |
break; |
break; |
|
|
for (i = 0; i < mt->pardist; i++) |
for (i = 0; i < mt->pardist; i++) |
Line 733 pre_SH(DECL_ARGS) |
|
Line 736 pre_SH(DECL_ARGS) |
|
|
|
do { |
do { |
n = n->prev; |
n = n->prev; |
} while (n != NULL && n->tok != TOKEN_NONE && |
} while (n != NULL && n->tok >= MAN_TH && |
termacts[n->tok].flags & MAN_NOTEXT); |
termacts[n->tok].flags & MAN_NOTEXT); |
if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL)) |
if (n == NULL || n->type == ROFFT_COMMENT || |
|
(n->tok == MAN_SH && n->body->child == NULL)) |
break; |
break; |
|
|
for (i = 0; i < mt->pardist; i++) |
for (i = 0; i < mt->pardist; i++) |
Line 796 pre_RS(DECL_ARGS) |
|
Line 800 pre_RS(DECL_ARGS) |
|
n->aux = SHRT_MAX + 1; |
n->aux = SHRT_MAX + 1; |
if (n->child == NULL) |
if (n->child == NULL) |
n->aux = mt->lmargin[mt->lmargincur]; |
n->aux = mt->lmargin[mt->lmargincur]; |
else if (a2roffsu(n->child->string, &su, SCALE_EN)) |
else if (a2roffsu(n->child->string, &su, SCALE_EN) != NULL) |
n->aux = term_hspan(p, &su) / 24; |
n->aux = term_hen(p, &su); |
if (n->aux < 0 && (size_t)(-n->aux) > mt->offset) |
if (n->aux < 0 && (size_t)(-n->aux) > mt->offset) |
n->aux = -mt->offset; |
n->aux = -mt->offset; |
else if (n->aux > SHRT_MAX) |
else if (n->aux > SHRT_MAX) |
Line 872 print_man_node(DECL_ARGS) |
|
Line 876 print_man_node(DECL_ARGS) |
|
* before printing the line's data. |
* before printing the line's data. |
*/ |
*/ |
if (*n->string == '\0') { |
if (*n->string == '\0') { |
term_vspace(p); |
if (p->flags & TERMP_NONEWLINE) |
|
term_newln(p); |
|
else |
|
term_vspace(p); |
return; |
return; |
} else if (*n->string == ' ' && n->flags & NODE_LINE && |
} else if (*n->string == ' ' && n->flags & NODE_LINE && |
(p->flags & TERMP_NONEWLINE) == 0) |
(p->flags & TERMP_NONEWLINE) == 0) |
Line 880 print_man_node(DECL_ARGS) |
|
Line 887 print_man_node(DECL_ARGS) |
|
|
|
term_word(p, n->string); |
term_word(p, n->string); |
goto out; |
goto out; |
|
case ROFFT_COMMENT: |
|
return; |
case ROFFT_EQN: |
case ROFFT_EQN: |
if ( ! (n->flags & NODE_LINE)) |
if ( ! (n->flags & NODE_LINE)) |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
Line 1024 print_man_foot(struct termp *p, const struct roff_meta |
|
Line 1032 print_man_foot(struct termp *p, const struct roff_meta |
|
|
|
term_word(p, title); |
term_word(p, title); |
term_flushln(p); |
term_flushln(p); |
|
|
|
/* |
|
* 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; |
|
|
free(title); |
free(title); |
} |
} |
|
|