summaryrefslogtreecommitdiffstats
path: root/mansearch.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-01-06 03:52:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-01-06 03:52:13 +0000
commit64f5d2e4e90fd817523e78c27a8ca9e758dc909d (patch)
tree684f847525f82c95870dc245169276285547407d /mansearch.c
parentbde6b6e5fe1b391dac65511440cb88c4501b17c6 (diff)
downloadmandoc-64f5d2e4e90fd817523e78c27a8ca9e758dc909d.tar.gz
Remove the redundant "file" column from the "mlinks" table.
The contents can easily be reconstructed from sec, arch, name, form. Shrinks the database by another 3% in standard mode and 9% in -Q mode.
Diffstat (limited to 'mansearch.c')
-rw-r--r--mansearch.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/mansearch.c b/mansearch.c
index 835cd436..6d0c49e7 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -125,7 +125,8 @@ static const struct type types[] = {
};
static void buildnames(struct manpage *, sqlite3 *,
- sqlite3_stmt *, uint64_t, const char *);
+ sqlite3_stmt *, uint64_t,
+ const char *, int form);
static char *buildoutput(sqlite3 *, sqlite3_stmt *,
uint64_t, uint64_t);
static void *hash_alloc(size_t, void *);
@@ -319,7 +320,8 @@ mansearch(const struct mansearch *search,
}
mpage = *res + cur;
mpage->form = mp->form;
- buildnames(mpage, db, s, mp->id, paths->paths[i]);
+ buildnames(mpage, db, s, mp->id,
+ paths->paths[i], mp->form);
mpage->output = outbit ?
buildoutput(db, s2, mp->id, outbit) : NULL;
@@ -344,10 +346,10 @@ out:
static void
buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
- uint64_t id, const char *path)
+ uint64_t id, const char *path, int form)
{
char *newnames;
- const char *oldnames, *sep1, *name, *sec, *sep2, *arch;
+ const char *oldnames, *sep1, *name, *sec, *sep2, *arch, *fsec;
size_t i;
int c;
@@ -365,9 +367,9 @@ buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
oldnames = mpage->names;
sep1 = ", ";
}
- sec = sqlite3_column_text(s, 1);
- arch = sqlite3_column_text(s, 2);
- name = sqlite3_column_text(s, 3);
+ sec = sqlite3_column_text(s, 0);
+ arch = sqlite3_column_text(s, 1);
+ name = sqlite3_column_text(s, 2);
sep2 = '\0' == *arch ? "" : "/";
if (-1 == asprintf(&newnames, "%s%s%s(%s%s%s)",
oldnames, sep1, name, sec, sep2, arch)) {
@@ -382,8 +384,15 @@ buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
if (NULL != mpage->file)
continue;
- name = sqlite3_column_text(s, 0);
- if (-1 == asprintf(&mpage->file, "%s/%s", path, name)) {
+ if (form) {
+ sep1 = "man";
+ fsec = sec;
+ } else {
+ sep1 = "cat";
+ fsec = "0";
+ }
+ if (-1 == asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s",
+ path, sep1, sec, sep2, arch, name, fsec)) {
perror(0);
exit((int)MANDOCLEVEL_SYSERR);
}