summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-11-27 01:57:43 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-11-27 01:57:43 +0000
commit2548776e9d8607097f4bc444f36621c887c6c31f (patch)
tree4c51c8a9a4f21d1fea2c0099664935abef7ed8d6 /usr.bin
parent514112a8ddec40d8e60f5dd232f6798f2b89367e (diff)
Make makewhatis(8) understand .so links to .gz pages.
Drop the FORM_GZ annotation in the mpages table; it is conceptually wrong because it ought to be in the mlinks table: An uncompressed .so link file can point to a compressed manual page file and vice versa. Besides, it is no longer needed because mparse_open() handles it all. Sprinkle some KNF while here.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/mandocdb.c34
-rw-r--r--usr.bin/mandoc/mansearch.c21
-rw-r--r--usr.bin/mandoc/mansearch.h3
3 files changed, 28 insertions, 30 deletions
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index 27f50740366..fc8ae4f4d46 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandocdb.c,v 1.125 2014/11/26 21:40:11 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.126 2014/11/27 01:57:42 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1083,13 +1083,13 @@ mpages_merge(struct mchars *mc, struct mparse *mp)
str_info.free = hash_free;
str_info.key_offset = offsetof(struct str, key);
- if (0 == nodb)
+ if ( ! nodb)
SQL_EXEC("BEGIN TRANSACTION");
mpage = ohash_first(&mpages, &pslot);
- while (NULL != mpage) {
+ while (mpage != NULL) {
mlinks_undupe(mpage);
- if (NULL == mpage->mlinks) {
+ if (mpage->mlinks == NULL) {
mpage = ohash_next(&mpages, &pslot);
continue;
}
@@ -1113,17 +1113,23 @@ mpages_merge(struct mchars *mc, struct mparse *mp)
* source code, unless it is already known to be
* formatted. Fall back to formatted mode.
*/
- if (FORM_CAT != mpage->mlinks->dform ||
- FORM_CAT != mpage->mlinks->fform) {
+ if (mpage->mlinks->dform != FORM_CAT ||
+ mpage->mlinks->fform != FORM_CAT) {
lvl = mparse_readfd(mp, fd, mpage->mlinks->file);
if (lvl < MANDOCLEVEL_FATAL)
mparse_result(mp, &mdoc, &man, &sodest);
}
- if (NULL != sodest) {
+ if (sodest != NULL) {
mlink_dest = ohash_find(&mlinks,
ohash_qlookup(&mlinks, sodest));
- if (NULL != mlink_dest) {
+ if (mlink_dest == NULL) {
+ mandoc_asprintf(&cp, "%s.gz", sodest);
+ mlink_dest = ohash_find(&mlinks,
+ ohash_qlookup(&mlinks, cp));
+ free(cp);
+ }
+ if (mlink_dest != NULL) {
/* The .so target exists. */
@@ -1144,7 +1150,7 @@ mpages_merge(struct mchars *mc, struct mparse *mp)
if (mpage_dest->pageid)
dbadd_mlink_name(mlink);
- if (NULL == mlink->next)
+ if (mlink->next == NULL)
break;
mlink = mlink->next;
}
@@ -1156,17 +1162,17 @@ mpages_merge(struct mchars *mc, struct mparse *mp)
mpage->mlinks = NULL;
}
goto nextpage;
- } else if (NULL != mdoc) {
+ } else if (mdoc != NULL) {
mpage->form = FORM_SRC;
mpage->sec = mdoc_meta(mdoc)->msec;
mpage->sec = mandoc_strdup(
- NULL == mpage->sec ? "" : mpage->sec);
+ mpage->sec == NULL ? "" : mpage->sec);
mpage->arch = mdoc_meta(mdoc)->arch;
mpage->arch = mandoc_strdup(
- NULL == mpage->arch ? "" : mpage->arch);
+ mpage->arch == NULL ? "" : mpage->arch);
mpage->title =
mandoc_strdup(mdoc_meta(mdoc)->title);
- } else if (NULL != man) {
+ } else if (man != NULL) {
mpage->form = FORM_SRC;
mpage->sec =
mandoc_strdup(man_meta(man)->msec);
@@ -1183,8 +1189,6 @@ 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);
if (*mpage->arch != '\0')
putkey(mpage, mpage->arch, TYPE_arch);
diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c
index 95a624955a3..1e45f016004 100644
--- a/usr.bin/mandoc/mansearch.c
+++ b/usr.bin/mandoc/mansearch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mansearch.c,v 1.37 2014/11/18 01:14:40 schwarze Exp $ */
+/* $OpenBSD: mansearch.c,v 1.38 2014/11/27 01:57:42 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -402,7 +402,6 @@ 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;
@@ -465,7 +464,7 @@ buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
/* Also save the first file name encountered. */
- if (NULL != mpage->file)
+ if (mpage->file != NULL)
continue;
if (form & FORM_SRC) {
@@ -475,22 +474,18 @@ buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
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%s",
- path, sep1, sec, sep2, arch, name, fsec, gzip);
+ sep2 = *arch == '\0' ? "" : "/";
+ mandoc_asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s",
+ path, sep1, sec, sep2, arch, name, fsec);
}
- if (SQLITE_DONE != c)
+ if (c != SQLITE_DONE)
fprintf(stderr, "%s\n", sqlite3_errmsg(db));
sqlite3_reset(s);
/* Append one final section to the names. */
- if (NULL != prevsec) {
- sep2 = '\0' == *prevarch ? "" : "/";
+ if (prevsec != NULL) {
+ sep2 = *prevarch == '\0' ? "" : "/";
mandoc_asprintf(&newnames, "%s(%s%s%s)",
mpage->names, prevsec, sep2, prevarch);
free(mpage->names);
diff --git a/usr.bin/mandoc/mansearch.h b/usr.bin/mandoc/mansearch.h
index e8dbd59786b..a62e1a9c362 100644
--- a/usr.bin/mandoc/mansearch.h
+++ b/usr.bin/mandoc/mansearch.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mansearch.h,v 1.16 2014/11/18 01:14:40 schwarze Exp $ */
+/* $OpenBSD: mansearch.h,v 1.17 2014/11/27 01:57:42 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -70,7 +70,6 @@
#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 {