aboutsummaryrefslogtreecommitdiffstatshomepage
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
commitde2a1122a661dd4bd4004854891d44e87d63c6c2 (patch)
tree79380a193e1374fd7e4b697152b0b7aea304ddf8 /mdoc_term.c
parent3f485a7ff74c3707363ed47362ccc8a7855b0f58 (diff)
downloadmandoc-de2a1122a661dd4bd4004854891d44e87d63c6c2.tar.gz
mandoc-de2a1122a661dd4bd4004854891d44e87d63c6c2.tar.zst
mandoc-de2a1122a661dd4bd4004854891d44e87d63c6c2.zip
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.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index cf3e7ef3..073cd4cb 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.367 2018/04/11 17:11:13 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.368 2018/08/17 20:33:38 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -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