source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Remove more pointer arithmetic passing via regions outside the
@ 2018-08-17 20:34 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2018-08-17 20:34 UTC (permalink / raw)
  To: source

Log Message:
-----------
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.

Modified Files:
--------------
    mandoc:
        libman.h
        libmdoc.h
        man.c
        man_html.c
        man_macro.c
        man_term.c
        mandocdb.c
        mdoc.c
        mdoc_argv.c
        mdoc_html.c
        mdoc_macro.c
        mdoc_man.c
        mdoc_markdown.c
        mdoc_state.c
        mdoc_term.c
        mdoc_validate.c

Revision Data
-------------
Index: libman.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/libman.h,v
retrieving revision 1.81
retrieving revision 1.82
diff -Llibman.h -Llibman.h -u -p -r1.81 -r1.82
--- libman.h
+++ libman.h
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014, 2015, 2018 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -32,8 +32,7 @@ struct	man_macro {
 #define	MAN_JOIN	 (1 << 3)  /* Join arguments together. */
 };
 
-extern	const struct man_macro *const man_macros;
-
+const struct man_macro *man_macro(enum roff_tok);
 
 void		  man_node_validate(struct roff_man *);
 void		  man_state(struct roff_man *, struct roff_node *);
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandocdb.c,v
retrieving revision 1.258
retrieving revision 1.259
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.258 -r1.259
--- mandocdb.c
+++ mandocdb.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2016 Ed Maste <emaste@freebsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -185,7 +185,7 @@ static	struct ohash	 names; /* table of 
 static	struct ohash	 strings; /* table of all strings */
 static	uint64_t	 name_mask;
 
-static	const struct mdoc_handler __mdocs[MDOC_MAX - MDOC_Dd] = {
+static	const struct mdoc_handler mdoc_handlers[MDOC_MAX - MDOC_Dd] = {
 	{ NULL, 0, NODE_NOPRT },  /* Dd */
 	{ NULL, 0, NODE_NOPRT },  /* Dt */
 	{ NULL, 0, NODE_NOPRT },  /* Os */
@@ -307,7 +307,6 @@ static	const struct mdoc_handler __mdocs
 	{ NULL, 0, 0 },  /* %U */
 	{ NULL, 0, 0 },  /* Ta */
 };
-static	const struct mdoc_handler *const mdocs = __mdocs - MDOC_Dd;
 
 
 int
@@ -1546,25 +1545,28 @@ static void
 parse_mdoc(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
+	const struct mdoc_handler *handler;
 
 	for (n = n->child; n != NULL; n = n->next) {
-		if (n->tok == TOKEN_NONE ||
-		    n->tok < ROFF_MAX ||
-		    n->flags & mdocs[n->tok].taboo)
+		if (n->tok == TOKEN_NONE || n->tok < ROFF_MAX)
 			continue;
 		assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
+		handler = mdoc_handlers + (n->tok - MDOC_Dd);
+		if (n->flags & handler->taboo)
+			continue;
+
 		switch (n->type) {
 		case ROFFT_ELEM:
 		case ROFFT_BLOCK:
 		case ROFFT_HEAD:
 		case ROFFT_BODY:
 		case ROFFT_TAIL:
-			if (mdocs[n->tok].fp != NULL &&
-			    (*mdocs[n->tok].fp)(mpage, meta, n) == 0)
+			if (handler->fp != NULL &&
+			    (*handler->fp)(mpage, meta, n) == 0)
 				break;
-			if (mdocs[n->tok].mask)
+			if (handler->mask)
 				putmdockey(mpage, n->child,
-				    mdocs[n->tok].mask, mdocs[n->tok].taboo);
+				    handler->mask, handler->taboo);
 			break;
 		default:
 			continue;
Index: mdoc_markdown.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_markdown.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -Lmdoc_markdown.c -Lmdoc_markdown.c -u -p -r1.25 -r1.26
--- mdoc_markdown.c
+++ mdoc_markdown.c
@@ -103,7 +103,7 @@ static	void	 md_post_Pf(struct roff_node
 static	void	 md_post_Vt(struct roff_node *);
 static	void	 md_post__T(struct roff_node *);
 
-static	const struct md_act __md_acts[MDOC_MAX - MDOC_Dd] = {
+static	const struct md_act md_acts[MDOC_MAX - MDOC_Dd] = {
 	{ NULL, NULL, NULL, NULL, NULL }, /* Dd */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Dt */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Os */
@@ -225,7 +225,7 @@ static	const struct md_act __md_acts[MDO
 	{ NULL, md_pre_Lk, md_post_pc, NULL, NULL }, /* %U */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Ta */
 };
-static	const struct md_act *const md_acts = __md_acts - MDOC_Dd;
+static const struct md_act *md_act(enum roff_tok);
 
 static	int	 outflags;
 #define	MD_spc		 (1 << 0)  /* Blank character before next word. */
@@ -250,6 +250,14 @@ static	int	 escflags; /* Escape in gener
 static	int	 code_blocks, quote_blocks, list_blocks;
 static	int	 outcount;
 
+
+static const struct md_act *
+md_act(enum roff_tok tok)
+{
+	assert(tok >= MDOC_Dd && tok <= MDOC_MAX);
+	return md_acts + (tok - MDOC_Dd);
+}
+
 void
 markdown_mdoc(void *arg, const struct roff_man *mdoc)
 {
@@ -330,8 +338,7 @@ md_node(struct roff_node *n)
 			break;
 		}
 	} else {
-		assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
-		act = md_acts + n->tok;
+		act = md_act(n->tok);
 		cond = act->cond == NULL || (*act->cond)(n);
 		if (cond && act->pre != NULL &&
 		    (n->end == ENDBODY_NOT || n->child != NULL))
@@ -719,7 +726,7 @@ md_pre_raw(struct roff_node *n)
 {
 	const char	*prefix;
 
-	if ((prefix = md_acts[n->tok].prefix) != NULL) {
+	if ((prefix = md_act(n->tok)->prefix) != NULL) {
 		md_rawword(prefix);
 		outflags &= ~MD_spc;
 		if (*prefix == '`')
@@ -733,7 +740,7 @@ md_post_raw(struct roff_node *n)
 {
 	const char	*suffix;
 
-	if ((suffix = md_acts[n->tok].suffix) != NULL) {
+	if ((suffix = md_act(n->tok)->suffix) != NULL) {
 		outflags &= ~(MD_spc | MD_nl);
 		md_rawword(suffix);
 		if (*suffix == '`')
@@ -746,7 +753,7 @@ md_pre_word(struct roff_node *n)
 {
 	const char	*prefix;
 
-	if ((prefix = md_acts[n->tok].prefix) != NULL) {
+	if ((prefix = md_act(n->tok)->prefix) != NULL) {
 		md_word(prefix);
 		outflags &= ~MD_spc;
 	}
@@ -758,7 +765,7 @@ md_post_word(struct roff_node *n)
 {
 	const char	*suffix;
 
-	if ((suffix = md_acts[n->tok].suffix) != NULL) {
+	if ((suffix = md_act(n->tok)->suffix) != NULL) {
 		outflags &= ~(MD_spc | MD_nl);
 		md_word(suffix);
 	}
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_validate.c,v
retrieving revision 1.361
retrieving revision 1.362
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.361 -r1.362
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -1990,7 +1990,7 @@ post_root(POST_ARGS)
 	while (n != NULL &&
 	    (n->type == ROFFT_COMMENT ||
 	     (n->tok >= MDOC_Dd &&
-	      mdoc_macros[n->tok].flags & MDOC_PROLOGUE)))
+	      mdoc_macro(n->tok)->flags & MDOC_PROLOGUE)))
 		n = n->next;
 
 	if (n == NULL)
Index: man_term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_term.c,v
retrieving revision 1.213
retrieving revision 1.214
diff -Lman_term.c -Lman_term.c -u -p -r1.213 -r1.214
--- man_term.c
+++ man_term.c
@@ -51,7 +51,7 @@ struct	mtermp {
 			  struct roff_node *n, \
 			  const struct roff_meta *meta
 
-struct	termact {
+struct	man_term_act {
 	int		(*pre)(DECL_ARGS);
 	void		(*post)(DECL_ARGS);
 	int		  flags;
@@ -93,7 +93,7 @@ static	void		  post_SS(DECL_ARGS);
 static	void		  post_TP(DECL_ARGS);
 static	void		  post_UR(DECL_ARGS);
 
-static	const struct termact __termacts[MAN_MAX - MAN_TH] = {
+static const struct man_term_act man_term_acts[MAN_MAX - MAN_TH] = {
 	{ NULL, NULL, 0 }, /* TH */
 	{ pre_SH, post_SH, 0 }, /* SH */
 	{ pre_SS, post_SS, 0 }, /* SS */
@@ -132,9 +132,16 @@ static	const struct termact __termacts[M
 	{ pre_UR, post_UR, 0 }, /* MT */
 	{ NULL, NULL, 0 }, /* ME */
 };
-static	const struct termact *termacts = __termacts - MAN_TH;
+static const struct man_term_act *man_term_act(enum roff_tok);
 
 
+static const struct man_term_act *
+man_term_act(enum roff_tok tok)
+{
+	assert(tok >= MAN_TH && tok <= MAN_MAX);
+	return man_term_acts + (tok - MAN_TH);
+}
+
 void
 terminal_man(void *arg, const struct roff_man *man)
 {
@@ -676,7 +683,7 @@ pre_SS(DECL_ARGS)
 		do {
 			n = n->prev;
 		} while (n != NULL && n->tok >= MAN_TH &&
-		    termacts[n->tok].flags & MAN_NOTEXT);
+		    man_term_act(n->tok)->flags & MAN_NOTEXT);
 		if (n == NULL || n->type == ROFFT_COMMENT ||
 		    (n->tok == MAN_SS && n->body->child == NULL))
 			break;
@@ -739,7 +746,7 @@ pre_SH(DECL_ARGS)
 		do {
 			n = n->prev;
 		} while (n != NULL && n->tok >= MAN_TH &&
-		    termacts[n->tok].flags & MAN_NOTEXT);
+		    man_term_act(n->tok)->flags & MAN_NOTEXT);
 		if (n == NULL || n->type == ROFFT_COMMENT ||
 		    (n->tok == MAN_SH && n->body->child == NULL))
 			break;
@@ -868,7 +875,8 @@ post_UR(DECL_ARGS)
 static void
 print_man_node(DECL_ARGS)
 {
-	int		 c;
+	const struct man_term_act *act;
+	int c;
 
 	switch (n->type) {
 	case ROFFT_TEXT:
@@ -914,20 +922,20 @@ print_man_node(DECL_ARGS)
 		return;
 	}
 
-	assert(n->tok >= MAN_TH && n->tok <= MAN_MAX);
-	if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
+	act = man_term_act(n->tok);
+	if ((act->flags & MAN_NOTEXT) == 0)
 		term_fontrepl(p, TERMFONT_NONE);
 
 	c = 1;
-	if (termacts[n->tok].pre)
-		c = (*termacts[n->tok].pre)(p, mt, n, meta);
+	if (act->pre != NULL)
+		c = (*act->pre)(p, mt, n, meta);
 
 	if (c && n->child)
 		print_man_nodelist(p, mt, n->child, meta);
 
-	if (termacts[n->tok].post)
-		(*termacts[n->tok].post)(p, mt, n, meta);
-	if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
+	if (act->post != NULL)
+		(*act->post)(p, mt, n, meta);
+	if ((act->flags & MAN_NOTEXT) == 0)
 		term_fontrepl(p, TERMFONT_NONE);
 
 out:
Index: mdoc_man.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_man.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.126 -r1.127
--- mdoc_man.c
+++ mdoc_man.c
@@ -36,7 +36,7 @@
 typedef	int	(*int_fp)(DECL_ARGS);
 typedef	void	(*void_fp)(DECL_ARGS);
 
-struct	manact {
+struct	mdoc_man_act {
 	int_fp		  cond; /* DON'T run actions */
 	int_fp		  pre; /* pre-node action */
 	void_fp		  post; /* post-node action */
@@ -124,7 +124,7 @@ static	void	  print_width(const struct m
 static	void	  print_count(int *);
 static	void	  print_node(DECL_ARGS);
 
-static	const void_fp roff_manacts[ROFF_MAX] = {
+static const void_fp roff_man_acts[ROFF_MAX] = {
 	pre_br,		/* br */
 	pre_onearg,	/* ce */
 	pre_ft,		/* ft */
@@ -137,7 +137,7 @@ static	const void_fp roff_manacts[ROFF_M
 	pre_onearg,	/* ti */
 };
 
-static	const struct manact __manacts[MDOC_MAX - MDOC_Dd] = {
+static const struct mdoc_man_act mdoc_man_acts[MDOC_MAX - MDOC_Dd] = {
 	{ NULL, NULL, NULL, NULL, NULL }, /* Dd */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Dt */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Os */
@@ -259,7 +259,7 @@ static	const struct manact __manacts[MDO
 	{ NULL, NULL, post_percent, NULL, NULL }, /* %U */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Ta */
 };
-static	const struct manact *const manacts = __manacts - MDOC_Dd;
+static const struct mdoc_man_act *mdoc_man_act(enum roff_tok);
 
 static	int		outflags;
 #define	MMAN_spc	(1 << 0)  /* blank character before next word */
@@ -290,6 +290,13 @@ static	struct {
 }	fontqueue;
 
 
+static const struct mdoc_man_act *
+mdoc_man_act(enum roff_tok tok)
+{
+	assert(tok >= MDOC_Dd && tok <= MDOC_MAX);
+	return mdoc_man_acts + (tok - MDOC_Dd);
+}
+
 static int
 man_strlen(const char *cp)
 {
@@ -640,9 +647,9 @@ man_mdoc(void *arg, const struct roff_ma
 static void
 print_node(DECL_ARGS)
 {
-	const struct manact	*act;
-	struct roff_node	*sub;
-	int			 cond, do_sub;
+	const struct mdoc_man_act	*act;
+	struct roff_node		*sub;
+	int				 cond, do_sub;
 
 	if (n->flags & NODE_NOPRT)
 		return;
@@ -680,15 +687,14 @@ print_node(DECL_ARGS)
 		else if (outflags & MMAN_Sm)
 			outflags |= MMAN_spc;
 	} else if (n->tok < ROFF_MAX) {
-		(*roff_manacts[n->tok])(meta, n);
+		(*roff_man_acts[n->tok])(meta, n);
 		return;
 	} else {
-		assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
 		/*
 		 * Conditionally run the pre-node action handler for a
 		 * node.
 		 */
-		act = manacts + n->tok;
+		act = mdoc_man_act(n->tok);
 		cond = act->cond == NULL || (*act->cond)(meta, n);
 		if (cond && act->pre != NULL &&
 		    (n->end == ENDBODY_NOT || n->child != NULL))
@@ -736,7 +742,7 @@ pre_enc(DECL_ARGS)
 {
 	const char	*prefix;
 
-	prefix = manacts[n->tok].prefix;
+	prefix = mdoc_man_act(n->tok)->prefix;
 	if (NULL == prefix)
 		return 1;
 	print_word(prefix);
@@ -749,7 +755,7 @@ post_enc(DECL_ARGS)
 {
 	const char *suffix;
 
-	suffix = manacts[n->tok].suffix;
+	suffix = mdoc_man_act(n->tok)->suffix;
 	if (NULL == suffix)
 		return;
 	outflags &= ~(MMAN_spc | MMAN_nl);
@@ -774,7 +780,7 @@ static void
 post_percent(DECL_ARGS)
 {
 
-	if (pre_em == manacts[n->tok].pre)
+	if (mdoc_man_act(n->tok)->pre == pre_em)
 		font_pop();
 	if (n->next) {
 		print_word(",");
@@ -820,7 +826,7 @@ pre_sect(DECL_ARGS)
 
 	if (n->type == ROFFT_HEAD) {
 		outflags |= MMAN_sp;
-		print_block(manacts[n->tok].prefix, 0);
+		print_block(mdoc_man_act(n->tok)->prefix, 0);
 		print_word("");
 		putchar('\"');
 		outflags &= ~MMAN_spc;
Index: mdoc_state.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_state.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -Lmdoc_state.c -Lmdoc_state.c -u -p -r1.9 -r1.10
--- mdoc_state.c
+++ mdoc_state.c
@@ -36,7 +36,7 @@ static	void	 state_dl(STATE_ARGS);
 static	void	 state_sh(STATE_ARGS);
 static	void	 state_sm(STATE_ARGS);
 
-static	const state_handler __state_handlers[MDOC_MAX - MDOC_Dd] = {
+static	const state_handler state_handlers[MDOC_MAX - MDOC_Dd] = {
 	NULL,		/* Dd */
 	NULL,		/* Dt */
 	NULL,		/* Os */
@@ -158,7 +158,6 @@ static	const state_handler __state_handl
 	NULL,		/* %U */
 	NULL,		/* Ta */
 };
-static const state_handler *const state_handlers = __state_handlers - MDOC_Dd;
 
 
 void
@@ -170,10 +169,10 @@ mdoc_state(struct roff_man *mdoc, struct
 		return;
 
 	assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
-	if ( ! (mdoc_macros[n->tok].flags & MDOC_PROLOGUE))
+	if ((mdoc_macro(n->tok)->flags & MDOC_PROLOGUE) == 0)
 		mdoc->flags |= MDOC_PBODY;
 
-	handler = state_handlers[n->tok];
+	handler = state_handlers[n->tok - MDOC_Dd];
 	if (*handler)
 		(*handler)(mdoc, n);
 }
Index: mdoc_argv.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_argv.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -Lmdoc_argv.c -Lmdoc_argv.c -u -p -r1.115 -r1.116
--- mdoc_argv.c
+++ mdoc_argv.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -144,7 +144,7 @@ static	const enum mdocargt args_Bl[] = {
 	MDOC_ARG_MAX
 };
 
-static	const struct mdocarg __mdocargs[MDOC_MAX - MDOC_Dd] = {
+static	const struct mdocarg mdocargs[MDOC_MAX - MDOC_Dd] = {
 	{ ARGSFL_NONE, NULL }, /* Dd */
 	{ ARGSFL_NONE, NULL }, /* Dt */
 	{ ARGSFL_NONE, NULL }, /* Os */
@@ -266,7 +266,6 @@ static	const struct mdocarg __mdocargs[M
 	{ ARGSFL_NONE, NULL }, /* %U */
 	{ ARGSFL_NONE, NULL }, /* Ta */
 };
-static	const struct mdocarg *const mdocargs = __mdocargs - MDOC_Dd;
 
 
 /*
@@ -290,7 +289,7 @@ mdoc_argv(struct roff_man *mdoc, int lin
 	/* Which flags does this macro support? */
 
 	assert(tok >= MDOC_Dd && tok < MDOC_MAX);
-	argtable = mdocargs[tok].argvs;
+	argtable = mdocargs[tok - MDOC_Dd].argvs;
 	if (argtable == NULL)
 		return;
 
@@ -368,7 +367,7 @@ mdoc_argv(struct roff_man *mdoc, int lin
 		/* Prepare for parsing the next flag. */
 
 		*pos = ipos;
-		argtable = mdocargs[tok].argvs;
+		argtable = mdocargs[tok - MDOC_Dd].argvs;
 	}
 }
 
@@ -422,7 +421,7 @@ mdoc_args(struct roff_man *mdoc, int lin
 
 	if (v == NULL)
 		v = &v_local;
-	fl = tok == TOKEN_NONE ? ARGSFL_NONE : mdocargs[tok].flags;
+	fl = tok == TOKEN_NONE ? ARGSFL_NONE : mdocargs[tok - MDOC_Dd].flags;
 
 	/*
 	 * We know that we're in an `It', so it's reasonable to expect
Index: man_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_html.c,v
retrieving revision 1.154
retrieving revision 1.155
diff -Lman_html.c -Lman_html.c -u -p -r1.154 -r1.155
--- man_html.c
+++ man_html.c
@@ -39,7 +39,7 @@
 			  const struct roff_node *n, \
 			  struct html *h
 
-struct	htmlman {
+struct	man_html_act {
 	int		(*pre)(MAN_ARGS);
 	int		(*post)(MAN_ARGS);
 };
@@ -70,7 +70,7 @@ static	void		  man_root_post(const struc
 static	void		  man_root_pre(const struct roff_meta *,
 				struct html *);
 
-static	const struct htmlman __mans[MAN_MAX - MAN_TH] = {
+static	const struct man_html_act man_html_acts[MAN_MAX - MAN_TH] = {
 	{ NULL, NULL }, /* TH */
 	{ man_SH_pre, NULL }, /* SH */
 	{ man_SS_pre, NULL }, /* SS */
@@ -109,7 +109,6 @@ static	const struct htmlman __mans[MAN_M
 	{ man_UR_pre, NULL }, /* MT */
 	{ NULL, NULL }, /* ME */
 };
-static	const struct htmlman *const mans = __mans - MAN_TH;
 
 
 /*
@@ -318,8 +317,9 @@ print_man_node(MAN_ARGS)
 		}
 
 		assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
-		if (mans[n->tok].pre)
-			child = (*mans[n->tok].pre)(man, n, h);
+		if (man_html_acts[n->tok - MAN_TH].pre != NULL)
+			child = (*man_html_acts[n->tok - MAN_TH].pre)(man,
+			    n, h);
 
 		/* Some block macros resume .nf in the body. */
 		if (save_fillmode && n->type == ROFFT_BODY)
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_html.c,v
retrieving revision 1.310
retrieving revision 1.311
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.310 -r1.311
--- mdoc_html.c
+++ mdoc_html.c
@@ -42,7 +42,7 @@
 #define	MIN(a,b)	((/*CONSTCOND*/(a)<(b))?(a):(b))
 #endif
 
-struct	htmlmdoc {
+struct	mdoc_html_act {
 	int		(*pre)(MDOC_ARGS);
 	void		(*post)(MDOC_ARGS);
 };
@@ -119,7 +119,7 @@ static	int		  mdoc_vt_pre(MDOC_ARGS);
 static	int		  mdoc_xr_pre(MDOC_ARGS);
 static	int		  mdoc_xx_pre(MDOC_ARGS);
 
-static	const struct htmlmdoc __mdocs[MDOC_MAX - MDOC_Dd] = {
+static const struct mdoc_html_act mdoc_html_acts[MDOC_MAX - MDOC_Dd] = {
 	{NULL, NULL}, /* Dd */
 	{NULL, NULL}, /* Dt */
 	{NULL, NULL}, /* Os */
@@ -241,7 +241,6 @@ static	const struct htmlmdoc __mdocs[MDO
 	{mdoc__x_pre, mdoc__x_post}, /* %U */
 	{NULL, NULL}, /* Ta */
 };
-static	const struct htmlmdoc *const mdocs = __mdocs - MDOC_Dd;
 
 
 /*
@@ -402,9 +401,10 @@ print_mdoc_node(MDOC_ARGS)
 			break;
 		}
 		assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
-		if (mdocs[n->tok].pre != NULL &&
+		if (mdoc_html_acts[n->tok - MDOC_Dd].pre != NULL &&
 		    (n->end == ENDBODY_NOT || n->child != NULL))
-			child = (*mdocs[n->tok].pre)(meta, n, h);
+			child = (*mdoc_html_acts[n->tok - MDOC_Dd].pre)(meta,
+			    n, h);
 		break;
 	}
 
@@ -423,10 +423,10 @@ print_mdoc_node(MDOC_ARGS)
 		break;
 	default:
 		if (n->tok < ROFF_MAX ||
-		    mdocs[n->tok].post == NULL ||
+		    mdoc_html_acts[n->tok - MDOC_Dd].post == NULL ||
 		    n->flags & NODE_ENDED)
 			break;
-		(*mdocs[n->tok].post)(meta, n, h);
+		(*mdoc_html_acts[n->tok - MDOC_Dd].post)(meta, n, h);
 		if (n->end != ENDBODY_NOT)
 			n->body->flags |= NODE_ENDED;
 		break;
Index: mdoc.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc.c,v
retrieving revision 1.268
retrieving revision 1.269
diff -Lmdoc.c -Lmdoc.c -u -p -r1.268 -r1.269
--- mdoc.c
+++ mdoc.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -80,13 +80,6 @@ mdoc_parseln(struct roff_man *mdoc, int 
 }
 
 void
-mdoc_macro(MACRO_PROT_ARGS)
-{
-	assert(tok >= MDOC_Dd && tok < MDOC_MAX);
-	(*mdoc_macros[tok].fp)(mdoc, tok, line, ppos, pos, buf);
-}
-
-void
 mdoc_tail_alloc(struct roff_man *mdoc, int line, int pos, enum roff_tok tok)
 {
 	struct roff_node *p;
@@ -196,7 +189,8 @@ mdoc_ptext(struct roff_man *mdoc, int li
 	    (n->parent != NULL && n->parent->tok == MDOC_Bl &&
 	     n->parent->norm->Bl.type == LIST_column)) {
 		mdoc->flags |= MDOC_FREECOL;
-		mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf);
+		(*mdoc_macro(MDOC_It)->fp)(mdoc, MDOC_It,
+		    line, offs, &offs, buf);
 		return 1;
 	}
 
@@ -378,7 +372,7 @@ mdoc_pmacro(struct roff_man *mdoc, int l
 
 	n = mdoc->last;
 	if (n == NULL || tok == MDOC_It || tok == MDOC_El) {
-		mdoc_macro(mdoc, tok, ln, sv, &offs, buf);
+		(*mdoc_macro(tok)->fp)(mdoc, tok, ln, sv, &offs, buf);
 		return 1;
 	}
 
@@ -394,13 +388,13 @@ mdoc_pmacro(struct roff_man *mdoc, int l
 	    (n->parent != NULL && n->parent->tok == MDOC_Bl &&
 	     n->parent->norm->Bl.type == LIST_column)) {
 		mdoc->flags |= MDOC_FREECOL;
-		mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf);
+		(*mdoc_macro(MDOC_It)->fp)(mdoc, MDOC_It, ln, sv, &sv, buf);
 		return 1;
 	}
 
 	/* Normal processing of a macro. */
 
-	mdoc_macro(mdoc, tok, ln, sv, &offs, buf);
+	(*mdoc_macro(tok)->fp)(mdoc, tok, ln, sv, &offs, buf);
 
 	/* In quick mode (for mandocdb), abort after the NAME section. */
 
Index: man.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man.c,v
retrieving revision 1.176
retrieving revision 1.177
diff -Lman.c -Lman.c -u -p -r1.176 -r1.177
--- man.c
+++ man.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2011 Joerg Sonnenberger <joerg@netbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -238,8 +238,8 @@ man_pmacro(struct roff_man *man, int ln,
 
 	/* Call to handler... */
 
-	assert(man_macros[tok].fp);
-	(*man_macros[tok].fp)(man, tok, ln, ppos, &offs, buf);
+	assert(man_macro(tok)->fp != NULL);
+	(*man_macro(tok)->fp)(man, tok, ln, ppos, &offs, buf);
 
 	/* In quick mode (for mandocdb), abort after the NAME section. */
 
@@ -257,7 +257,7 @@ man_pmacro(struct roff_man *man, int ln,
 	 */
 
 	if ( ! bline || man->flags & MAN_ELINE ||
-	    man_macros[tok].flags & MAN_NSCOPED)
+	    man_macro(tok)->flags & MAN_NSCOPED)
 		return 1;
 
 	assert(man->flags & MAN_BLINE);
@@ -280,12 +280,12 @@ man_breakscope(struct roff_man *man, int
 	 */
 
 	if (man->flags & MAN_ELINE && (tok < MAN_TH ||
-	    ! (man_macros[tok].flags & MAN_NSCOPED))) {
+	    (man_macro(tok)->flags & MAN_NSCOPED) == 0)) {
 		n = man->last;
 		if (n->type == ROFFT_TEXT)
 			n = n->parent;
 		if (n->tok < MAN_TH ||
-		    man_macros[n->tok].flags & MAN_NSCOPED)
+		    man_macro(n->tok)->flags & MAN_NSCOPED)
 			n = n->parent;
 
 		mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse,
@@ -317,18 +317,18 @@ man_breakscope(struct roff_man *man, int
 	 */
 
 	if (man->flags & MAN_BLINE && (tok < MAN_TH ||
-	    man_macros[tok].flags & MAN_BSCOPE)) {
+	    man_macro(tok)->flags & MAN_BSCOPE)) {
 		n = man->last;
 		if (n->type == ROFFT_TEXT)
 			n = n->parent;
 		if (n->tok < MAN_TH ||
-		    (man_macros[n->tok].flags & MAN_BSCOPE) == 0)
+		    (man_macro(n->tok)->flags & MAN_BSCOPE) == 0)
 			n = n->parent;
 
 		assert(n->type == ROFFT_HEAD);
 		n = n->parent;
 		assert(n->type == ROFFT_BLOCK);
-		assert(man_macros[n->tok].flags & MAN_SCOPED);
+		assert(man_macro(n->tok)->flags & MAN_SCOPED);
 
 		mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse,
 		    n->line, n->pos, "%s breaks %s",
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_term.c,v
retrieving revision 1.367
retrieving revision 1.368
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.367 -r1.368
--- mdoc_term.c
+++ 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[M
 	{ 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
Index: man_macro.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_macro.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -Lman_macro.c -Lman_macro.c -u -p -r1.126 -r1.127
--- man_macro.c
+++ man_macro.c
@@ -40,7 +40,7 @@ static	int		 man_args(struct roff_man *,
 				int *, char *, char **);
 static	void		 rew_scope(struct roff_man *, enum roff_tok);
 
-const	struct man_macro __man_macros[MAN_MAX - MAN_TH] = {
+static const struct man_macro man_macros[MAN_MAX - MAN_TH] = {
 	{ in_line_eoln, MAN_BSCOPE }, /* TH */
 	{ blk_imp, MAN_BSCOPE | MAN_SCOPED }, /* SH */
 	{ blk_imp, MAN_BSCOPE | MAN_SCOPED }, /* SS */
@@ -79,9 +79,15 @@ const	struct man_macro __man_macros[MAN_
 	{ blk_exp, MAN_BSCOPE }, /* MT */
 	{ blk_close, MAN_BSCOPE }, /* ME */
 };
-const	struct man_macro *const man_macros = __man_macros - MAN_TH;
 
 
+const struct man_macro *
+man_macro(enum roff_tok tok)
+{
+	assert(tok >= MAN_TH && tok <= MAN_MAX);
+	return man_macros + (tok - MAN_TH);
+}
+
 void
 man_unscope(struct roff_man *man, const struct roff_node *to)
 {
@@ -95,7 +101,7 @@ man_unscope(struct roff_man *man, const 
 
 		if (to == NULL && ! (n->flags & NODE_VALID)) {
 			if (man->flags & (MAN_BLINE | MAN_ELINE) &&
-			    man_macros[n->tok].flags & MAN_SCOPED) {
+			    man_macro(n->tok)->flags & MAN_SCOPED) {
 				mandoc_vmsg(MANDOCERR_BLK_LINE,
 				    man->parse, n->line, n->pos,
 				    "EOF breaks %s", roff_name[n->tok]);
@@ -112,7 +118,7 @@ man_unscope(struct roff_man *man, const 
 				continue;
 			}
 			if (n->type == ROFFT_BLOCK &&
-			    man_macros[n->tok].fp == blk_exp)
+			    man_macro(n->tok)->fp == blk_exp)
 				mandoc_msg(MANDOCERR_BLK_NOEND,
 				    man->parse, n->line, n->pos,
 				    roff_name[n->tok]);
@@ -176,7 +182,7 @@ rew_scope(struct roff_man *man, enum rof
 		}
 		if (tok != MAN_SH && (n->tok == MAN_SH ||
 		    (tok != MAN_SS && (n->tok == MAN_SS ||
-		     man_macros[n->tok].fp == blk_exp))))
+		     man_macro(n->tok)->fp == blk_exp))))
 			return;
 		man_unscope(man, n);
 		n = man->last;
@@ -327,7 +333,7 @@ blk_imp(MACRO_PROT_ARGS)
 	 * For `TP', always keep the head open.
 	 */
 
-	if (man_macros[tok].flags & MAN_SCOPED &&
+	if (man_macro(tok)->flags & MAN_SCOPED &&
 	    (tok == MAN_TP || tok == MAN_TQ || n == man->last)) {
 		man->flags |= MAN_BLINE;
 		return;
@@ -365,7 +371,7 @@ in_line_eoln(MACRO_PROT_ARGS)
 		la = *pos;
 		if ( ! man_args(man, line, pos, buf, &p))
 			break;
-		if (man_macros[tok].flags & MAN_JOIN &&
+		if (man_macro(tok)->flags & MAN_JOIN &&
 		    man->last->type == ROFFT_TEXT)
 			roff_word_append(man, p);
 		else
@@ -387,8 +393,8 @@ in_line_eoln(MACRO_PROT_ARGS)
 	 * waiting for terms to load into our context.
 	 */
 
-	if (n == man->last && man_macros[tok].flags & MAN_SCOPED) {
-		assert( ! (man_macros[tok].flags & MAN_NSCOPED));
+	if (n == man->last && man_macro(tok)->flags & MAN_SCOPED) {
+		assert((man_macro(tok)->flags & MAN_NSCOPED) == 0);
 		man->flags |= MAN_ELINE;
 		return;
 	}
Index: mdoc_macro.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_macro.c,v
retrieving revision 1.224
retrieving revision 1.225
diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.224 -r1.225
--- mdoc_macro.c
+++ mdoc_macro.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -60,7 +60,7 @@ static	void		rew_last(struct roff_man *,
 static	void		rew_pending(struct roff_man *,
 				const struct roff_node *);
 
-const	struct mdoc_macro __mdoc_macros[MDOC_MAX - MDOC_Dd] = {
+static const struct mdoc_macro mdoc_macros[MDOC_MAX - MDOC_Dd] = {
 	{ in_line_eoln, MDOC_PROLOGUE }, /* Dd */
 	{ in_line_eoln, MDOC_PROLOGUE }, /* Dt */
 	{ in_line_eoln, MDOC_PROLOGUE }, /* Os */
@@ -201,9 +201,15 @@ const	struct mdoc_macro __mdoc_macros[MD
 	{ in_line_eoln, 0 }, /* %U */
 	{ phrase_ta, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ta */
 };
-const	struct mdoc_macro *const mdoc_macros = __mdoc_macros - MDOC_Dd;
 
 
+const struct mdoc_macro *
+mdoc_macro(enum roff_tok tok)
+{
+	assert(tok >= MDOC_Dd && tok < MDOC_MAX);
+	return mdoc_macros + (tok - MDOC_Dd);
+}
+
 /*
  * This is called at the end of parsing.  It must traverse up the tree,
  * closing out open [implicit] scopes.  Obviously, open explicit scopes
@@ -221,7 +227,7 @@ mdoc_endparse(struct roff_man *mdoc)
 
 	for ( ; n; n = n->parent)
 		if (n->type == ROFFT_BLOCK &&
-		    mdoc_macros[n->tok].flags & MDOC_EXPLICIT)
+		    mdoc_macro(n->tok)->flags & MDOC_EXPLICIT)
 			mandoc_msg(MANDOCERR_BLK_NOEND, mdoc->parse,
 			    n->line, n->pos, roff_name[n->tok]);
 
@@ -244,10 +250,10 @@ lookup(struct roff_man *mdoc, int from, 
 		mdoc->flags &= ~MDOC_PHRASEQF;
 		return TOKEN_NONE;
 	}
-	if (from == TOKEN_NONE || mdoc_macros[from].flags & MDOC_PARSED) {
+	if (from == TOKEN_NONE || mdoc_macro(from)->flags & MDOC_PARSED) {
 		res = roffhash_find(mdoc->mdocmac, p, 0);
 		if (res != TOKEN_NONE) {
-			if (mdoc_macros[res].flags & MDOC_CALLABLE)
+			if (mdoc_macro(res)->flags & MDOC_CALLABLE)
 				return res;
 			mandoc_msg(MANDOCERR_MACRO_CALL,
 			    mdoc->parse, line, ppos, p);
@@ -409,7 +415,7 @@ find_pending(struct roff_man *mdoc, enum
 		if (n->flags & NODE_ENDED)
 			continue;
 		if (n->type == ROFFT_BLOCK &&
-		    mdoc_macros[n->tok].flags & MDOC_EXPLICIT) {
+		    mdoc_macro(n->tok)->flags & MDOC_EXPLICIT) {
 			irc = 1;
 			break_intermediate(mdoc->last, target);
 			if (target->type == ROFFT_HEAD)
@@ -518,13 +524,13 @@ macro_or_word(MACRO_PROT_ARGS, int parse
 
 	if (ntok == TOKEN_NONE) {
 		dword(mdoc, line, ppos, p, DELIM_MAX, tok == TOKEN_NONE ||
-		    mdoc_macros[tok].flags & MDOC_JOIN);
+		    mdoc_macro(tok)->flags & MDOC_JOIN);
 		return 0;
 	} else {
 		if (tok != TOKEN_NONE &&
-		    mdoc_macros[tok].fp == in_line_eoln)
+		    mdoc_macro(tok)->fp == in_line_eoln)
 			rew_elem(mdoc, tok);
-		mdoc_macro(mdoc, ntok, line, ppos, pos, buf);
+		(*mdoc_macro(ntok)->fp)(mdoc, ntok, line, ppos, pos, buf);
 		if (tok == TOKEN_NONE)
 			append_delims(mdoc, line, pos, buf);
 		return 1;
@@ -688,7 +694,7 @@ blk_exp_close(MACRO_PROT_ARGS)
 			mdoc_tail_alloc(mdoc, line, ppos, atok);
 	}
 
-	if ( ! (mdoc_macros[tok].flags & MDOC_PARSED)) {
+	if ((mdoc_macro(tok)->flags & MDOC_PARSED) == 0) {
 		if (buf[*pos] != '\0')
 			mandoc_vmsg(MANDOCERR_ARG_SKIP,
 			    mdoc->parse, line, ppos,
@@ -717,14 +723,14 @@ blk_exp_close(MACRO_PROT_ARGS)
 
 		if (ntok == TOKEN_NONE) {
 			dword(mdoc, line, lastarg, p, DELIM_MAX,
-			    MDOC_JOIN & mdoc_macros[tok].flags);
+			    mdoc_macro(tok)->flags & MDOC_JOIN);
 			continue;
 		}
 
 		if (n != NULL)
 			rew_last(mdoc, n);
 		mdoc->flags &= ~MDOC_NEWLINE;
-		mdoc_macro(mdoc, ntok, line, lastarg, pos, buf);
+		(*mdoc_macro(ntok)->fp)(mdoc, ntok, line, lastarg, pos, buf);
 		break;
 	}
 
@@ -831,7 +837,8 @@ in_line(MACRO_PROT_ARGS)
 				    mdoc->parse, line, ppos,
 				    roff_name[tok]);
 			}
-			mdoc_macro(mdoc, ntok, line, la, pos, buf);
+			(*mdoc_macro(ntok)->fp)(mdoc, ntok,
+			    line, la, pos, buf);
 			if (nl)
 				append_delims(mdoc, line, pos, buf);
 			return;
@@ -875,7 +882,7 @@ in_line(MACRO_PROT_ARGS)
 		}
 
 		dword(mdoc, line, la, p, d,
-		    mdoc_macros[tok].flags & MDOC_JOIN);
+		    mdoc_macro(tok)->flags & MDOC_JOIN);
 
 		/*
 		 * If the first argument is a closing delimiter,
@@ -944,7 +951,7 @@ blk_full(MACRO_PROT_ARGS)
 		return;
 	}
 
-	if ( ! (mdoc_macros[tok].flags & MDOC_EXPLICIT)) {
+	if ((mdoc_macro(tok)->flags & MDOC_EXPLICIT) == 0) {
 
 		/* Here, tok is one of Sh Ss Nm Nd It. */
 
@@ -969,7 +976,7 @@ blk_full(MACRO_PROT_ARGS)
 				break;
 			}
 
-			if (mdoc_macros[n->tok].flags & MDOC_EXPLICIT) {
+			if (mdoc_macro(n->tok)->flags & MDOC_EXPLICIT) {
 				switch (tok) {
 				case MDOC_Sh:
 				case MDOC_Ss:
@@ -1339,7 +1346,7 @@ in_line_argn(MACRO_PROT_ARGS)
 		ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
 
 		if (ac == ARGS_WORD && state == -1 &&
-		    ! (mdoc_macros[tok].flags & MDOC_IGNDELIM) &&
+		    (mdoc_macro(tok)->flags & MDOC_IGNDELIM) == 0 &&
 		    mdoc_isdelim(p) == DELIM_OPEN) {
 			dword(mdoc, line, la, p, DELIM_OPEN, 0);
 			continue;
@@ -1372,11 +1379,12 @@ in_line_argn(MACRO_PROT_ARGS)
 				rew_elem(mdoc, tok);
 				state = -2;
 			}
-			mdoc_macro(mdoc, ntok, line, la, pos, buf);
+			(*mdoc_macro(ntok)->fp)(mdoc, ntok,
+			    line, la, pos, buf);
 			break;
 		}
 
-		if (mdoc_macros[tok].flags & MDOC_IGNDELIM ||
+		if (mdoc_macro(tok)->flags & MDOC_IGNDELIM ||
 		    mdoc_isdelim(p) == DELIM_NONE) {
 			if (state == -1) {
 				mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
@@ -1389,7 +1397,7 @@ in_line_argn(MACRO_PROT_ARGS)
 		}
 
 		dword(mdoc, line, la, p, DELIM_MAX,
-		    mdoc_macros[tok].flags & MDOC_JOIN);
+		    mdoc_macro(tok)->flags & MDOC_JOIN);
 	}
 
 	if (state == -1) {
Index: libmdoc.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/libmdoc.h,v
retrieving revision 1.112
retrieving revision 1.113
diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.112 -r1.113
--- libmdoc.h
+++ libmdoc.h
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -59,10 +59,8 @@ enum	mdelim {
 	DELIM_MAX
 };
 
-extern	const struct mdoc_macro *const mdoc_macros;
+const struct mdoc_macro *mdoc_macro(enum roff_tok);
 
-
-void		  mdoc_macro(MACRO_PROT_ARGS);
 void		  mdoc_elem_alloc(struct roff_man *, int, int,
 			enum roff_tok, struct mdoc_arg *);
 struct roff_node *mdoc_block_alloc(struct roff_man *, int, int,
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-08-17 20:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-17 20:34 mandoc: Remove more pointer arithmetic passing via regions outside the schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).