aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apropos_db.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-12-16 12:06:35 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-12-16 12:06:35 +0000
commit1cf41474327ca813976f622e8e0b73bb3841a44c (patch)
treefc81fa3b092a418c199ec9ce185c91c9be1a38bd /apropos_db.c
parent385adb0d5fa1bc2a7c177241fa3d9671d7af1582 (diff)
downloadmandoc-1cf41474327ca813976f622e8e0b73bb3841a44c.tar.gz
mandoc-1cf41474327ca813976f622e8e0b73bb3841a44c.tar.zst
mandoc-1cf41474327ca813976f622e8e0b73bb3841a44c.zip
Make the stored "cat"/"mdoc"/"man" strings just be c/d/a single-character
bytes. This cuts down a little in index size and allows for cleaner extraction of information.
Diffstat (limited to 'apropos_db.c')
-rw-r--r--apropos_db.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/apropos_db.c b/apropos_db.c
index fd657558..0d2b0728 100644
--- a/apropos_db.c
+++ b/apropos_db.c
@@ -1,4 +1,4 @@
-/* $Id: apropos_db.c,v 1.23 2011/12/10 21:46:59 kristaps Exp $ */
+/* $Id: apropos_db.c,v 1.24 2011/12/16 12:06:35 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -365,6 +365,7 @@ index_read(const DBT *key, const DBT *val, int index,
{
size_t left;
char *np, *cp;
+ char type;
#define INDEX_BREAD(_dst) \
do { \
@@ -375,13 +376,23 @@ index_read(const DBT *key, const DBT *val, int index,
cp = np + 1; \
} while (/* CONSTCOND */ 0)
- left = val->size;
- cp = (char *)val->data;
+ if (0 == (left = val->size))
+ return(0);
+ cp = val->data;
rec->res.rec = *(recno_t *)key->data;
rec->res.volume = index;
- INDEX_BREAD(rec->res.type);
+ if ('d' == (type = *cp++))
+ rec->res.type = RESTYPE_MDOC;
+ else if ('a' == type)
+ rec->res.type = RESTYPE_MAN;
+ else if ('c' == type)
+ rec->res.type = RESTYPE_CAT;
+ else
+ return(0);
+
+ left--;
INDEX_BREAD(rec->res.file);
INDEX_BREAD(rec->res.cat);
INDEX_BREAD(rec->res.title);
@@ -581,7 +592,6 @@ static void
recfree(struct rec *rec)
{
- free(rec->res.type);
free(rec->res.file);
free(rec->res.cat);
free(rec->res.title);