summaryrefslogtreecommitdiffstats
path: root/read.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-04-29 12:45:41 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-04-29 12:45:41 +0000
commit59d32b6b6f099db4e98d14846f92c95838026d6d (patch)
tree63c63032b5f693739f4b67978ba829797d59256c /read.c
parent68e287f8a84e78c626e8440ced37035bd5359eff (diff)
downloadmandoc-59d32b6b6f099db4e98d14846f92c95838026d6d.tar.gz
Parser unification: use nice ohashes for all three request and macro tables;
no functional change, minus two source files, minus 200 lines of code.
Diffstat (limited to 'read.c')
-rw-r--r--read.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/read.c b/read.c
index 6ffc1d91..dfa10e56 100644
--- a/read.c
+++ b/read.c
@@ -293,14 +293,15 @@ choose_parser(struct mparse *curp)
}
if (format == MPARSE_MDOC) {
- mdoc_hash_init();
curp->man->macroset = MACROSET_MDOC;
- curp->man->first->tok = TOKEN_NONE;
+ if (curp->man->mdocmac == NULL)
+ curp->man->mdocmac = roffhash_alloc(MDOC_Dd, MDOC_MAX);
} else {
- man_hash_init();
curp->man->macroset = MACROSET_MAN;
- curp->man->first->tok = TOKEN_NONE;
+ if (curp->man->manmac == NULL)
+ curp->man->manmac = roffhash_alloc(MAN_TH, MAN_MAX);
}
+ curp->man->first->tok = TOKEN_NONE;
}
/*
@@ -818,11 +819,13 @@ mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg,
curp->man = roff_man_alloc( curp->roff, curp, curp->defos,
curp->options & MPARSE_QUICK ? 1 : 0);
if (curp->options & MPARSE_MDOC) {
- mdoc_hash_init();
curp->man->macroset = MACROSET_MDOC;
+ if (curp->man->mdocmac == NULL)
+ curp->man->mdocmac = roffhash_alloc(MDOC_Dd, MDOC_MAX);
} else if (curp->options & MPARSE_MAN) {
- man_hash_init();
curp->man->macroset = MACROSET_MAN;
+ if (curp->man->manmac == NULL)
+ curp->man->manmac = roffhash_alloc(MAN_TH, MAN_MAX);
}
curp->man->first->tok = TOKEN_NONE;
return curp;
@@ -848,6 +851,8 @@ void
mparse_free(struct mparse *curp)
{
+ roffhash_free(curp->man->mdocmac);
+ roffhash_free(curp->man->manmac);
roff_man_free(curp->man);
roff_free(curp->roff);
if (curp->secondary)