summaryrefslogtreecommitdiffstats
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-08-17 20:33:37 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-08-17 20:33:37 +0000
commita55868d2cb7c07237689f307d3a55b33b257de09 (patch)
tree6e622b38423ae091b6a8a02b0843ea2bfb7958b4 /mdoc_term.c
parentf6077aba4f0b9ece3ceff820c0c651d148df1a37 (diff)
downloadmandoc-a55868d2cb7c07237689f307d3a55b33b257de09.tar.gz
Remove more pointer arithmetic passing via regions outside the array
that is undefined according to the C standard. Robert Elz <kre at munnari dot oz dot au> pointed out i wasn't quite done yet.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index f61bbb1e..75ffd1d1 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -47,7 +47,7 @@ struct termpair {
const struct roff_meta *meta, \
struct roff_node *n
-struct termact {
+struct mdoc_term_act {
int (*pre)(DECL_ARGS);
void (*post)(DECL_ARGS);
};
@@ -124,7 +124,7 @@ static int termp_vt_pre(DECL_ARGS);
static int termp_xr_pre(DECL_ARGS);
static int termp_xx_pre(DECL_ARGS);
-static const struct termact __termacts[MDOC_MAX - MDOC_Dd] = {
+static const struct mdoc_term_act mdoc_term_acts[MDOC_MAX - MDOC_Dd] = {
{ NULL, NULL }, /* Dd */
{ NULL, NULL }, /* Dt */
{ NULL, NULL }, /* Os */
@@ -246,7 +246,6 @@ static const struct termact __termacts[MDOC_MAX - MDOC_Dd] = {
{ NULL, termp____post }, /* %U */
{ NULL, NULL }, /* Ta */
};
-static const struct termact *const termacts = __termacts - MDOC_Dd;
static int fn_prio;
@@ -310,9 +309,10 @@ print_mdoc_nodelist(DECL_ARGS)
static void
print_mdoc_node(DECL_ARGS)
{
- int chld;
+ const struct mdoc_term_act *act;
struct termpair npair;
size_t offset, rmargin;
+ int chld;
if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
return;
@@ -370,10 +370,10 @@ print_mdoc_node(DECL_ARGS)
return;
}
assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
- if (termacts[n->tok].pre != NULL &&
+ act = mdoc_term_acts + (n->tok - MDOC_Dd);
+ if (act->pre != NULL &&
(n->end == ENDBODY_NOT || n->child != NULL))
- chld = (*termacts[n->tok].pre)
- (p, &npair, meta, n);
+ chld = (*act->pre)(p, &npair, meta, n);
break;
}
@@ -391,9 +391,9 @@ print_mdoc_node(DECL_ARGS)
case ROFFT_EQN:
break;
default:
- if (termacts[n->tok].post == NULL || n->flags & NODE_ENDED)
+ if (act->post == NULL || n->flags & NODE_ENDED)
break;
- (void)(*termacts[n->tok].post)(p, &npair, meta, n);
+ (void)(*act->post)(p, &npair, meta, n);
/*
* Explicit end tokens not only call the post