diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/mandocdb.c | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/mansearch.c | 29 |
2 files changed, 21 insertions, 14 deletions
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index 0d398627573..fe954d1f2ec 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.60 2014/01/06 03:02:40 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.61 2014/01/06 03:52:05 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -1748,7 +1748,6 @@ dbindex(const struct mpage *mpage, struct mchars *mc) for (mlink = mpage->mlinks; mlink; mlink = mlink->next) { i = 1; - SQL_BIND_TEXT(stmts[STMT_INSERT_LINK], i, mlink->file); SQL_BIND_TEXT(stmts[STMT_INSERT_LINK], i, mlink->dsec); SQL_BIND_TEXT(stmts[STMT_INSERT_LINK], i, mlink->arch); SQL_BIND_TEXT(stmts[STMT_INSERT_LINK], i, mlink->name); @@ -1882,7 +1881,6 @@ dbopen(int real) ");\n" "\n" "CREATE TABLE \"mlinks\" (\n" - " \"file\" TEXT NOT NULL,\n" " \"sec\" TEXT NOT NULL,\n" " \"arch\" TEXT NOT NULL,\n" " \"name\" TEXT NOT NULL,\n" @@ -1915,7 +1913,7 @@ prepare_statements: "(form) VALUES (?)"; sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_INSERT_PAGE], NULL); sql = "INSERT INTO mlinks " - "(file,sec,arch,name,pageid) VALUES (?,?,?,?,?)"; + "(sec,arch,name,pageid) VALUES (?,?,?,?)"; sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_INSERT_LINK], NULL); sql = "INSERT INTO keys " "(bits,key,pageid) VALUES (?,?,?)"; diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c index aa67ae9955c..e0db97b4ce7 100644 --- a/usr.bin/mandoc/mansearch.c +++ b/usr.bin/mandoc/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.9 2014/01/06 03:02:40 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.10 2014/01/06 03:52:05 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -117,7 +117,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 *); @@ -311,7 +312,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; @@ -336,10 +338,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; @@ -357,9 +359,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)) { @@ -374,8 +376,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); } |