From 35c319dedab41299e8ad1ec62697c36315fb88da Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 13 Oct 2015 22:59:54 +0000 Subject: 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. --- main.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index e4d42b55..b4d8d934 100644 --- a/main.c +++ b/main.c @@ -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 * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze @@ -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: -- cgit v1.2.3