aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/catman.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 /catman.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 'catman.c')
-rw-r--r--catman.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/catman.c b/catman.c
index 54971293..2ac27e5a 100644
--- a/catman.c
+++ b/catman.c
@@ -1,4 +1,4 @@
-/* $Id: catman.c,v 1.6 2011/12/16 08:04:34 kristaps Exp $ */
+/* $Id: catman.c,v 1.7 2011/12/16 12:06:35 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -204,7 +204,7 @@ indexhtml(char *src, size_t ssz, char *dst, size_t dsz)
DBT key, val;
int c, rc;
unsigned int fl;
- const char *f, *cp;
+ const char *f;
char *d;
char fname[MAXPATHLEN];
pid_t pid;
@@ -223,14 +223,15 @@ indexhtml(char *src, size_t ssz, char *dst, size_t dsz)
fl = R_FIRST;
while (0 == (c = (*idx->seq)(idx, &key, &val, fl))) {
fl = R_NEXT;
- cp = (const char *)val.data;
+ /*
+ * If the record is zero-length, then it's unassigned.
+ * Skip past these.
+ */
if (0 == val.size)
continue;
- if (NULL == (f = memchr(cp, '\0', val.size)))
- break;
- if (++f - cp >= (int)val.size)
- break;
- if (NULL == memchr(f, '\0', val.size - (f - cp)))
+
+ f = (const char *)val.data + 1;
+ if (NULL == memchr(f, '\0', val.size - 1))
break;
src[(int)ssz] = dst[(int)dsz] = '\0';