diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-12-16 12:06:35 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-12-16 12:06:35 +0000 |
commit | b38a0e9bb59f9ee62120de914198368fdba24c0c (patch) | |
tree | 24c19eb546e5b07faed09e9802c8811df81176a3 /catman.c | |
parent | a4ad6737e73b3efeb9ad854f1f4323ba3a43833a (diff) | |
download | mandoc-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 'catman.c')
-rw-r--r-- | catman.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -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'; |