summaryrefslogtreecommitdiffstats
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
commitb38a0e9bb59f9ee62120de914198368fdba24c0c (patch)
tree24c19eb546e5b07faed09e9802c8811df81176a3 /apropos_db.c
parenta4ad6737e73b3efeb9ad854f1f4323ba3a43833a (diff)
downloadmandoc-b38a0e9bb59f9ee62120de914198368fdba24c0c.tar.gz
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.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/apropos_db.c b/apropos_db.c
index 7684f27e..7c703323 100644
--- a/apropos_db.c
+++ b/apropos_db.c
@@ -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);