summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/man/man5/mandoc.db.523
-rw-r--r--usr.bin/mandoc/main.c4
-rw-r--r--usr.bin/mandoc/mandocdb.c19
-rw-r--r--usr.bin/mandoc/mansearch.c15
-rw-r--r--usr.bin/mandoc/mansearch.h7
5 files changed, 44 insertions, 24 deletions
diff --git a/share/man/man5/mandoc.db.5 b/share/man/man5/mandoc.db.5
index ace24417eb7..6ea94f886b7 100644
--- a/share/man/man5/mandoc.db.5
+++ b/share/man/man5/mandoc.db.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mandoc.db.5,v 1.1 2014/04/24 19:08:01 schwarze Exp $
+.\" $OpenBSD: mandoc.db.5,v 1.2 2014/09/03 18:08:26 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 24 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/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index 0b61eb90f0a..689a3c24a5f 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.98 2014/09/03 05:17:08 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.99 2014/09/03 18:08:26 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -357,7 +357,7 @@ main(int argc, char *argv[])
while (argc) {
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/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index d335b051529..6d473fd61bc 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.115 2014/09/01 23:47:56 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.116 2014/09/03 18:08:26 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -72,12 +72,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 */
@@ -93,24 +87,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 */
};
@@ -827,6 +821,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");
@@ -1215,6 +1210,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);
@@ -2046,7 +2043,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/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c
index 043bfdf13f5..04964ab7b83 100644
--- a/usr.bin/mandoc/mansearch.c
+++ b/usr.bin/mandoc/mansearch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mansearch.c,v 1.34 2014/09/01 22:45:11 schwarze Exp $ */
+/* $OpenBSD: mansearch.c,v 1.35 2014/09/03 18:08:26 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -72,7 +72,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 *,
@@ -390,6 +390,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;
@@ -455,16 +456,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/usr.bin/mandoc/mansearch.h b/usr.bin/mandoc/mansearch.h
index a24f9302105..fc8b46b7e1e 100644
--- a/usr.bin/mandoc/mansearch.h
+++ b/usr.bin/mandoc/mansearch.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mansearch.h,v 1.13 2014/09/01 22:45:11 schwarze Exp $ */
+/* $OpenBSD: mansearch.h,v 1.14 2014/09/03 18:08:26 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,