aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apropos_db.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-11-23 09:55:28 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-11-23 09:55:28 +0000
commit4ca47c10dfff73e3dd44a44f4fa39d8228a71d23 (patch)
tree7a1473aada7e6f7f36d08a8c7d1d280e67e2bf5b /apropos_db.c
parent62dc4f949b755b4b88b3f476e7da3ae0827618a6 (diff)
downloadmandoc-4ca47c10dfff73e3dd44a44f4fa39d8228a71d23.tar.gz
mandoc-4ca47c10dfff73e3dd44a44f4fa39d8228a71d23.tar.zst
mandoc-4ca47c10dfff73e3dd44a44f4fa39d8228a71d23.zip
Let apropos_db.h export the volume of manpages for a parsed record.
This is necessary since an array of records can have duplicate record numbers in different mandoc.index files. The volume [right now] is just the index of the parsed mandoc.index in the manpaths. This is sensible because the order of the manpath is significant (it's the order of duplicate-named manuals displayed by man(1)) and is thus not likely to change.
Diffstat (limited to 'apropos_db.c')
-rw-r--r--apropos_db.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/apropos_db.c b/apropos_db.c
index 53418532..de577d5f 100644
--- a/apropos_db.c
+++ b/apropos_db.c
@@ -1,4 +1,4 @@
-/* $Id: apropos_db.c,v 1.10 2011/11/20 16:29:50 kristaps Exp $ */
+/* $Id: apropos_db.c,v 1.11 2011/11/23 09:55:28 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -125,7 +125,7 @@ static int exprmark(const struct expr *,
static struct expr *exprexpr(int, char *[], int *, int *, size_t *);
static struct expr *exprterm(char *, int);
static DB *index_open(void);
-static int index_read(const DBT *, const DBT *,
+static int index_read(const DBT *, const DBT *, int,
const struct mchars *, struct rec *);
static void norm_string(const char *,
const struct mchars *, char **);
@@ -133,7 +133,7 @@ static size_t norm_utf8(unsigned int, char[7]);
static void recfree(struct rec *);
static int single_search(struct rectree *, const struct opts *,
const struct expr *, size_t terms,
- struct mchars *);
+ struct mchars *, int);
/*
* Open the keyword mandoc-db database.
@@ -345,7 +345,7 @@ index_open(void)
* Returns 1 if an entry was unpacked, 0 if the database is insane.
*/
static int
-index_read(const DBT *key, const DBT *val,
+index_read(const DBT *key, const DBT *val, int index,
const struct mchars *mc, struct rec *rec)
{
size_t left;
@@ -364,6 +364,7 @@ index_read(const DBT *key, const DBT *val,
cp = (char *)val->data;
rec->res.rec = *(recno_t *)key->data;
+ rec->res.volume = index;
INDEX_BREAD(rec->res.file);
INDEX_BREAD(rec->res.cat);
@@ -402,7 +403,7 @@ apropos_search(int pathsz, char **paths, const struct opts *opts,
for (i = 0; i < pathsz; i++) {
if (chdir(paths[i]))
continue;
- if ( ! single_search(&tree, opts, expr, terms, mc))
+ if ( ! single_search(&tree, opts, expr, terms, mc, i))
goto out;
}
@@ -438,7 +439,7 @@ out:
static int
single_search(struct rectree *tree, const struct opts *opts,
const struct expr *expr, size_t terms,
- struct mchars *mc)
+ struct mchars *mc, int vol)
{
int root, leaf, ch;
uint64_t mask;
@@ -525,7 +526,7 @@ single_search(struct rectree *tree, const struct opts *opts,
break;
r.lhs = r.rhs = -1;
- if ( ! index_read(&key, &val, mc, &r))
+ if ( ! index_read(&key, &val, vol, mc, &r))
break;
/* XXX: this should be elsewhere, I guess? */