aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cgi.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 /cgi.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 'cgi.c')
-rw-r--r--cgi.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/cgi.c b/cgi.c
index 002855d7..515b1162 100644
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-/* $Id: cgi.c,v 1.34 2011/12/16 08:04:34 kristaps Exp $ */
+/* $Id: cgi.c,v 1.35 2011/12/16 12:06:35 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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);