aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cgi.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-12-16 08:04:34 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-12-16 08:04:34 +0000
commit385adb0d5fa1bc2a7c177241fa3d9671d7af1582 (patch)
treecd450bbc7357f95079637736b512f7dbd198fa07 /cgi.c
parent3ea09b162e3e01af08ef1b7bae07ceb30981f83f (diff)
downloadmandoc-385adb0d5fa1bc2a7c177241fa3d9671d7af1582.tar.gz
mandoc-385adb0d5fa1bc2a7c177241fa3d9671d7af1582.tar.zst
mandoc-385adb0d5fa1bc2a7c177241fa3d9671d7af1582.zip
Make paths in the mandocdb(8) index relative to the databases' path
prefix. This means that an index in, say, /usr/share/man will point to man1/foo.1 instead of /usr/share/man/man1/foo.1. Not only does this save a lot of space, it also allows manual trees to be moved around without any side effects to the mandocdb(8) databases.
Diffstat (limited to 'cgi.c')
-rw-r--r--cgi.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/cgi.c b/cgi.c
index 2ed654d8..002855d7 100644
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-/* $Id: cgi.c,v 1.33 2011/12/15 12:18:57 kristaps Exp $ */
+/* $Id: cgi.c,v 1.34 2011/12/16 08:04:34 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -749,6 +749,7 @@ static void
pg_show(const struct req *req, char *path)
{
struct manpaths ps;
+ size_t sz;
char *sub;
char file[MAXPATHLEN];
const char *fn, *cp;
@@ -804,7 +805,8 @@ pg_show(const struct req *req, char *path)
goto out;
}
- strlcpy(file, ps.paths[vol], MAXPATHLEN);
+ sz = strlcpy(file, ps.paths[vol], MAXPATHLEN);
+ assert(sz < MAXPATHLEN);
strlcat(file, "/mandoc.index", MAXPATHLEN);
/* Open the index recno(3) database. */
@@ -833,10 +835,13 @@ pg_show(const struct req *req, char *path)
else if (NULL == memchr(fn, '\0', val.size - (fn - cp)))
resp_baddb();
else {
+ file[(int)sz] = '\0';
+ strlcat(file, "/", MAXPATHLEN);
+ strlcat(file, fn, MAXPATHLEN);
if (0 == strcmp(cp, "cat"))
- catman(req, fn + 1);
+ catman(req, file);
else
- format(req, fn + 1);
+ format(req, file);
}
out:
if (idx)