aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-09-03 18:09:14 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-09-03 18:09:14 +0000
commit248398820acb6a81f0d92b7a33dc1e449dda483b (patch)
tree93066814e716198d92cc1458fab4a2eca07bea9a
parent02046d75d7ec4c27ec31d04e15c9d9fe018a01ab (diff)
downloadmandoc-248398820acb6a81f0d92b7a33dc1e449dda483b.tar.gz
mandoc-248398820acb6a81f0d92b7a33dc1e449dda483b.tar.zst
mandoc-248398820acb6a81f0d92b7a33dc1e449dda483b.zip
If a manual page is installed gzip(1)ed, let makewhatis(8) take
note in mandoc.db(5), such that man(1) -w and apropos(1) -w can report the correct filename. This is a prerequisite for letting apropos -a and man support gzip'ed manuals in the future, which doesn't work yet.
-rw-r--r--main.c4
-rw-r--r--mandoc.db.523
-rw-r--r--mandocdb.c19
-rw-r--r--mansearch.c15
-rw-r--r--mansearch.h7
5 files changed, 44 insertions, 24 deletions
diff --git a/main.c b/main.c
index 81f2d0c9..5e596603 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.190 2014/09/03 05:22:45 schwarze Exp $ */
+/* $Id: main.c,v 1.191 2014/09/03 18:09:14 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -370,7 +370,7 @@ main(int argc, char *argv[])
while (argc) {
#if HAVE_SQLITE3
if (resp != NULL) {
- if (resp->form) {
+ if (resp->form & FORM_SRC) {
/* For .so only; ignore failure. */
chdir(paths.paths[resp->ipath]);
parse(&curp, -1, resp->file, &rc);
diff --git a/mandoc.db.5 b/mandoc.db.5
index 8d564957..e3452ffe 100644
--- a/mandoc.db.5
+++ b/mandoc.db.5
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.db.5,v 1.1 2014/04/15 20:18:26 schwarze Exp $
+.\" $Id: mandoc.db.5,v 1.2 2014/09/03 18:09:14 schwarze Exp $
.\"
.\" Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 15 2014 $
+.Dd $Mdocdate: September 3 2014 $
.Dt MANDOC.DB 5
.Os
.Sh NAME
@@ -67,13 +67,26 @@ The description line
.Pq Sq \&Nd
of the page.
.It Sy mpages.form
-The
+An
.Vt INTEGER
-1 if the page is unformatted, i.e. in
+bit field.
+If bit
+.Dv FORM_GZ
+is set, the page is compressed and requires
+.Xr gunzip 1
+for display.
+If bit
+.Dv FORM_SRC
+is set, the page is unformatted, that is in
.Xr mdoc 7
or
.Xr man 7
-format, and 2 if it is formatted, i.e. a
+format, and requires
+.Xr mandoc 1
+for display.
+If bit
+.Dv FORM_SRC
+is not set, the page is formatted, i.e. a
.Sq cat
page.
.It Sy mlinks.sec
diff --git a/mandocdb.c b/mandocdb.c
index 7ad55a50..e1c744d7 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.160 2014/09/01 23:47:59 schwarze Exp $ */
+/* $OpenBSD$ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -83,12 +83,6 @@ enum op {
OP_TEST /* change no databases, report potential problems */
};
-enum form {
- FORM_NONE, /* format is unknown */
- FORM_SRC, /* format is -man or -mdoc */
- FORM_CAT /* format is cat */
-};
-
struct str {
char *rendered; /* key in UTF-8 or ASCII form */
const struct mpage *mpage; /* if set, the owning parse */
@@ -104,24 +98,24 @@ struct inodev {
struct mpage {
struct inodev inodev; /* used for hashing routine */
int64_t pageid; /* pageid in mpages SQL table */
- enum form form; /* format from file content */
char *sec; /* section from file content */
char *arch; /* architecture from file content */
char *title; /* title from file content */
char *desc; /* description from file content */
struct mlink *mlinks; /* singly linked list */
+ int form; /* format from file content */
};
struct mlink {
char file[PATH_MAX]; /* filename rel. to manpath */
- enum form dform; /* format from directory */
- enum form fform; /* format from file name suffix */
char *dsec; /* section from directory */
char *arch; /* architecture from directory */
char *name; /* name from file name (not empty) */
char *fsec; /* section from file name suffix */
struct mlink *next; /* singly linked list */
struct mpage *mpage; /* parent */
+ int dform; /* format from directory */
+ int fform; /* format from file name suffix */
int gzip; /* filename has a .gz suffix */
};
@@ -838,6 +832,7 @@ filescan(const char *file)
}
mlink = mandoc_calloc(1, sizeof(struct mlink));
+ mlink->dform = FORM_NONE;
if (strlcpy(mlink->file, start, sizeof(mlink->file)) >=
sizeof(mlink->file)) {
say(start, "Filename too long");
@@ -1226,6 +1221,8 @@ mpages_merge(struct mchars *mc, struct mparse *mp)
mpage->title =
mandoc_strdup(mpage->mlinks->name);
}
+ if (mpage->mlinks->gzip)
+ mpage->form |= FORM_GZ;
putkey(mpage, mpage->sec, TYPE_sec);
putkey(mpage, '\0' == *mpage->arch ?
any : mpage->arch, TYPE_arch);
@@ -2057,7 +2054,7 @@ dbadd(struct mpage *mpage, struct mchars *mc)
i = 1;
SQL_BIND_TEXT(stmts[STMT_INSERT_PAGE], i, key->rendered);
- SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, FORM_SRC == mpage->form);
+ SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, mpage->form);
SQL_STEP(stmts[STMT_INSERT_PAGE]);
mpage->pageid = sqlite3_last_insert_rowid(db);
sqlite3_reset(stmts[STMT_INSERT_PAGE]);
diff --git a/mansearch.c b/mansearch.c
index a8a37a96..9c88fac8 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -1,4 +1,4 @@
-/* $Id: mansearch.c,v 1.47 2014/09/01 22:45:53 schwarze Exp $ */
+/* $Id: mansearch.c,v 1.48 2014/09/03 18:09:14 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -80,7 +80,7 @@ struct expr {
struct match {
uint64_t pageid; /* identifier in database */
char *desc; /* manual page description */
- int form; /* 0 == catpage */
+ int form; /* bit field: formatted, zipped? */
};
static void buildnames(struct manpage *, sqlite3 *,
@@ -398,6 +398,7 @@ buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
{
char *newnames, *prevsec, *prevarch;
const char *oldnames, *sep1, *name, *sec, *sep2, *arch, *fsec;
+ const char *gzip;
size_t i;
int c;
@@ -463,16 +464,20 @@ buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
if (NULL != mpage->file)
continue;
- if (form) {
+ if (form & FORM_SRC) {
sep1 = "man";
fsec = sec;
} else {
sep1 = "cat";
fsec = "0";
}
+ if (form & FORM_GZ)
+ gzip = ".gz";
+ else
+ gzip = "";
sep2 = '\0' == *arch ? "" : "/";
- mandoc_asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s",
- path, sep1, sec, sep2, arch, name, fsec);
+ mandoc_asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s%s",
+ path, sep1, sec, sep2, arch, name, fsec, gzip);
}
if (SQLITE_DONE != c)
fprintf(stderr, "%s\n", sqlite3_errmsg(db));
diff --git a/mansearch.h b/mansearch.h
index 6cc6f410..0aab4e76 100644
--- a/mansearch.h
+++ b/mansearch.h
@@ -1,4 +1,4 @@
-/* $Id: mansearch.h,v 1.17 2014/09/01 22:45:53 schwarze Exp $ */
+/* $Id: mansearch.h,v 1.18 2014/09/03 18:09:14 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -68,6 +68,11 @@
#define NAME_HEAD 0x0000004000000010ULL
#define NAME_MASK 0x000000000000001fULL
+#define FORM_CAT 0 /* manual page is preformatted */
+#define FORM_SRC 1 /* format is mdoc(7) or man(7) */
+#define FORM_GZ 2 /* compressed with gzip(1) */
+#define FORM_NONE 4 /* format is unknown */
+
enum argmode {
ARG_FILE = 0,
ARG_NAME,