aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--mandocdb.c19
-rw-r--r--mansearch_const.c31
3 files changed, 50 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index f763dff3..ddcae273 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/mandocdb.c b/mandocdb.c
index 5118894c..467e8f86 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.110 2014/01/18 08:55:17 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.111 2014/01/19 00:09:38 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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..b4d47200
--- /dev/null
+++ b/mansearch_const.c
@@ -0,0 +1,31 @@
+/* $Id: mansearch_const.c,v 1.1 2014/01/19 00:09:38 schwarze Exp $ */
+/*
+ * 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"
+};