diff options
author | 2015-10-13 22:59:54 +0000 | |
---|---|---|
committer | 2015-10-13 22:59:54 +0000 | |
commit | 35c319dedab41299e8ad1ec62697c36315fb88da (patch) | |
tree | 6d0023d2c650f7cadfa9c71eebdfd679f0bf3d51 /main.c | |
parent | e47784200392e2dea53b3decd3ceb23e1e2a0ca6 (diff) | |
download | mandoc-35c319dedab41299e8ad1ec62697c36315fb88da.tar.gz mandoc-35c319dedab41299e8ad1ec62697c36315fb88da.tar.zst mandoc-35c319dedab41299e8ad1ec62697c36315fb88da.zip |
Major character table cleanup:
* Use ohash(3) rather than a hand-rolled hash table.
* Make the character table static in the chars.c module:
There is no need to pass a pointer around, we most certainly
never want to use two different character tables concurrently.
* No need to keep the characters in a separate file chars.in;
that merely encourages downstream porters to mess with them.
* Sort the characters to agree with the mandoc_chars(7) manual page.
* Specify Unicode codepoints in hex, not decimal (that's the detail
that originally triggered this patch).
No functional change, minus 100 LOC, and i don't see a performance change.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 28 |
1 files changed, 10 insertions, 18 deletions
@@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.248 2015/10/12 00:08:15 schwarze Exp $ */ +/* $Id: main.c,v 1.249 2015/10/13 22:59:54 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -77,7 +77,6 @@ enum outt { struct curparse { struct mparse *mp; - struct mchars *mchars; /* character table */ enum mandoclevel wlevel; /* ignore messages below this */ int wstop; /* stop after a file with a warning */ enum outt outtype; /* which output to use */ @@ -422,9 +421,8 @@ main(int argc, char *argv[]) if (search.argmode == ARG_FILE && ! moptions(&options, auxpaths)) return (int)MANDOCLEVEL_BADARG; - curp.mchars = mchars_alloc(); - curp.mp = mparse_alloc(options, curp.wlevel, mmsg, - curp.mchars, defos); + mchars_alloc(); + curp.mp = mparse_alloc(options, curp.wlevel, mmsg, defos); /* * Conditionally start up the lookaside buffer before parsing. @@ -478,7 +476,7 @@ main(int argc, char *argv[]) if (curp.outfree) (*curp.outfree)(curp.outdata); mparse_free(curp.mp); - mchars_free(curp.mchars); + mchars_free(); out: if (search.argmode != ARG_FILE) { @@ -662,33 +660,27 @@ parse(struct curparse *curp, int fd, const char *file) if ( ! (curp->outman && curp->outmdoc)) { switch (curp->outtype) { case OUTT_HTML: - curp->outdata = html_alloc(curp->mchars, - curp->outopts); + curp->outdata = html_alloc(curp->outopts); curp->outfree = html_free; break; case OUTT_UTF8: - curp->outdata = utf8_alloc(curp->mchars, - curp->outopts); + curp->outdata = utf8_alloc(curp->outopts); curp->outfree = ascii_free; break; case OUTT_LOCALE: - curp->outdata = locale_alloc(curp->mchars, - curp->outopts); + curp->outdata = locale_alloc(curp->outopts); curp->outfree = ascii_free; break; case OUTT_ASCII: - curp->outdata = ascii_alloc(curp->mchars, - curp->outopts); + curp->outdata = ascii_alloc(curp->outopts); curp->outfree = ascii_free; break; case OUTT_PDF: - curp->outdata = pdf_alloc(curp->mchars, - curp->outopts); + curp->outdata = pdf_alloc(curp->outopts); curp->outfree = pspdf_free; break; case OUTT_PS: - curp->outdata = ps_alloc(curp->mchars, - curp->outopts); + curp->outdata = ps_alloc(curp->outopts); curp->outfree = pspdf_free; break; default: |