summaryrefslogtreecommitdiffstats
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
commitc770387f803c840900502ca28d15d35e99650baf (patch)
tree08bbe0df94aca90459dd30338e163a1ce94dbb3a
parent23314f00a3de516604e28d2a34bde0428f6067fb (diff)
downloadmandoc-c770387f803c840900502ca28d15d35e99650baf.tar.gz
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.c2
-rw-r--r--mandoc.db.519
-rw-r--r--mandocdb.c19
-rw-r--r--mansearch.c13
-rw-r--r--mansearch.h5
5 files changed, 39 insertions, 19 deletions
diff --git a/main.c b/main.c
index 5c13d2f7..5a7db15e 100644
--- a/main.c
+++ b/main.c
@@ -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 0cae2fd0..3d383e9e 100644
--- a/mandoc.db.5
+++ b/mandoc.db.5
@@ -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 718d5420..e1c744d7 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $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 4455dc11..1d94937c 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -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 80c9e6a7..7e40ef45 100644
--- a/mansearch.h
+++ b/mansearch.h
@@ -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,