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 /cgi.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 'cgi.c')
-rw-r--r-- | cgi.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -752,8 +752,8 @@ pg_show(const struct req *req, char *path) size_t sz; char *sub; char file[MAXPATHLEN]; - const char *fn, *cp; - int rc; + const char *cp; + int rc, catm; unsigned int vol, rec, mr; DB *idx; DBT key, val; @@ -824,21 +824,21 @@ pg_show(const struct req *req, char *path) if (0 != (rc = (*idx->get)(idx, &key, &val, 0))) { rc < 0 ? resp_baddb() : resp_error400(); goto out; - } + } else if (0 == val.size) { + resp_baddb(); + goto out; + } cp = (char *)val.data; + catm = 'c' == *cp++; - if (NULL == (fn = memchr(cp, '\0', val.size))) - resp_baddb(); - else if (++fn - cp >= (int)val.size) - resp_baddb(); - else if (NULL == memchr(fn, '\0', val.size - (fn - cp))) + if (NULL == memchr(cp, '\0', val.size - 1)) resp_baddb(); else { file[(int)sz] = '\0'; strlcat(file, "/", MAXPATHLEN); - strlcat(file, fn, MAXPATHLEN); - if (0 == strcmp(cp, "cat")) + strlcat(file, cp, MAXPATHLEN); + if (catm) catman(req, file); else format(req, file); |