=================================================================== RCS file: /cvs/mandoc/mdoc_man.c,v retrieving revision 1.126 retrieving revision 1.127 diff -u -p -r1.126 -r1.127 --- mandoc/mdoc_man.c 2018/04/11 17:11:13 1.126 +++ mandoc/mdoc_man.c 2018/08/17 20:33:37 1.127 @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.126 2018/04/11 17:11:13 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.127 2018/08/17 20:33:37 schwarze Exp $ */ /* * Copyright (c) 2011-2018 Ingo Schwarze * @@ -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 mdoc_bl *, 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_MAX] = { 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[MDOC_MAX - MDOC_D { 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_man *mdoc) 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;