diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-01-19 00:09:38 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-01-19 00:09:38 +0000 |
commit | 6393b8aa8c51b1fee01ea7cab08064b7098255e5 (patch) | |
tree | b0757ef27d78df38ae686f3a4b839158e5082287 | |
parent | 172a6f5a12e7614d3c52f6331657926b06a384cc (diff) | |
download | mandoc-6393b8aa8c51b1fee01ea7cab08064b7098255e5.tar.gz |
Support a second -v on mandocdb(8) to show keys while they are being added;
i need that for debugging, in particular to be used with -t.
To be able to do so, provide a global table of key names, for reuse.
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | mandocdb.c | 17 | ||||
-rw-r--r-- | mansearch_const.c | 31 |
3 files changed, 49 insertions, 2 deletions
@@ -128,6 +128,7 @@ SRCS = Makefile \ manpath.h \ mansearch.c \ mansearch.h \ + mansearch_const.c \ mdoc.7 \ mdoc.c \ mdoc.h \ @@ -249,7 +250,7 @@ MANDOC_OBJS = $(MANDOC_HTML_OBJS) \ tree.o $(MANDOC_OBJS): main.h mandoc.h mdoc.h man.h config.h out.h -MANDOCDB_OBJS = mandocdb.o manpath.o +MANDOCDB_OBJS = mandocdb.o mansearch_const.o manpath.o $(MANDOCDB_OBJS): mansearch.h mandoc.h mdoc.h man.h config.h manpath.h PRECONV_OBJS = preconv.o @@ -48,6 +48,9 @@ #include "manpath.h" #include "mansearch.h" +extern int mansearch_keymax; +extern const char *const mansearch_keynames[]; + #define SQL_EXEC(_v) \ if (SQLITE_OK != sqlite3_exec(db, (_v), NULL, NULL, NULL)) \ fprintf(stderr, "%s\n", sqlite3_errmsg(db)) @@ -1562,12 +1565,24 @@ putkeys(const struct mpage *mpage, const char *cp, size_t sz, uint64_t v) { struct str *s; - unsigned int slot; const char *end; + uint64_t mask; + unsigned int slot; + int i; if (0 == sz) return; + if (verb > 1) { + for (i = 0, mask = 1; + i < mansearch_keymax; + i++, mask <<= 1) + if (mask & v) + break; + say(mpage->mlinks->file, "Adding key %s=%*s", + mansearch_keynames[i], sz, cp); + } + end = cp + sz; slot = ohash_qlookupi(&strings, cp, &end); s = ohash_find(&strings, slot); diff --git a/mansearch_const.c b/mansearch_const.c new file mode 100644 index 00000000..01e63a26 --- /dev/null +++ b/mansearch_const.c @@ -0,0 +1,31 @@ +/* $Id$ */ +/* + * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include <sys/types.h> +#include <stdint.h> + +#include "manpath.h" +#include "mansearch.h" + +const int mansearch_keymax = 40; + +const char *const mansearch_keynames[40] = { + "Nm", "Nd", "arch", "sec", "Xr", "Ar", "Fa", "Fl", + "Dv", "Fn", "Ic", "Pa", "Cm", "Li", "Em", "Cd", + "Va", "Ft", "Tn", "Er", "Ev", "Sy", "Sh", "In", + "Ss", "Ox", "An", "Mt", "St", "Bx", "At", "Nx", + "Fx", "Lk", "Ms", "Bsx", "Dx", "Rs", "Vt", "Lb" +}; |