aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-10-13 22:59:54 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-10-13 22:59:54 +0000
commit35c319dedab41299e8ad1ec62697c36315fb88da (patch)
tree6d0023d2c650f7cadfa9c71eebdfd679f0bf3d51 /mandocdb.c
parente47784200392e2dea53b3decd3ceb23e1e2a0ca6 (diff)
downloadmandoc-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 'mandocdb.c')
-rw-r--r--mandocdb.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 228e2a0d..ff4df09a 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.202 2015/10/13 15:53:05 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.203 2015/10/13 22:59:54 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -195,7 +195,6 @@ static int write_utf8; /* write UTF-8 output; else ASCII */
static int exitcode; /* to be returned by main */
static enum op op; /* operational mode */
static char basedir[PATH_MAX]; /* current base directory */
-static struct mchars *mchars; /* table of named characters */
static struct ohash mpages; /* table of distinct manual pages */
static struct ohash mlinks; /* table of directory entries */
static struct ohash names; /* table of all names */
@@ -419,9 +418,8 @@ mandocdb(int argc, char *argv[])
}
exitcode = (int)MANDOCLEVEL_OK;
- mchars = mchars_alloc();
- mp = mparse_alloc(mparse_options, MANDOCLEVEL_BADARG, NULL,
- mchars, NULL);
+ mchars_alloc();
+ mp = mparse_alloc(mparse_options, MANDOCLEVEL_BADARG, NULL, NULL);
mandoc_ohash_init(&mpages, 6, offsetof(struct mpage, inodev));
mandoc_ohash_init(&mlinks, 6, offsetof(struct mlink, file));
@@ -522,7 +520,7 @@ mandocdb(int argc, char *argv[])
out:
manconf_free(&conf);
mparse_free(mp);
- mchars_free(mchars);
+ mchars_free();
mpages_free();
ohash_delete(&mpages);
ohash_delete(&mlinks);
@@ -1928,7 +1926,7 @@ render_string(char **public, size_t *psz)
*/
if (write_utf8) {
- unicode = mchars_spec2cp(mchars, seq, seqlen);
+ unicode = mchars_spec2cp(seq, seqlen);
if (unicode <= 0)
continue;
addsz = utf8(unicode, utfbuf);
@@ -1936,7 +1934,7 @@ render_string(char **public, size_t *psz)
continue;
addcp = utfbuf;
} else {
- addcp = mchars_spec2str(mchars, seq, seqlen, &addsz);
+ addcp = mchars_spec2str(seq, seqlen, &addsz);
if (addcp == NULL)
continue;
if (*addcp == ASCII_NBRSP) {