summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-01-02 18:52:15 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-01-02 18:52:15 +0000
commita7b51ad89006bf25e2d6beebf2fdc1dbe51d44e5 (patch)
treeea881bc8d51ff173e3f63b9a809843c3482dd6ae /mandocdb.c
parent3987d23445dfa7c29fc4de7e0010a176851038fa (diff)
downloadmandoc-a7b51ad89006bf25e2d6beebf2fdc1dbe51d44e5.tar.gz
Check all MLINKS for consistency with the content of the manual page,
not just the first one. This doesn't change how the check is done, but just which MLINKS are checked.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c101
1 files changed, 59 insertions, 42 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 237cb8c4..56575c03 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -143,6 +143,7 @@ static void *hash_alloc(size_t, void *);
static void hash_free(void *, size_t, void *);
static void *hash_halloc(size_t, void *);
static void mlink_add(struct mlink *, const struct stat *);
+static int mlink_check(struct mpage *, struct mlink *);
static void mlink_free(struct mlink *);
static void mlinks_undupe(struct mpage *);
static void mpages_free(void);
@@ -885,6 +886,54 @@ nextlink:
}
}
+static int
+mlink_check(struct mpage *mpage, struct mlink *mlink)
+{
+ int match;
+
+ match = 1;
+
+ /*
+ * Check whether the manual section given in a file
+ * agrees with the directory where the file is located.
+ * Some manuals have suffixes like (3p) on their
+ * section number either inside the file or in the
+ * directory name, some are linked into more than one
+ * section, like encrypt(1) = makekey(8).
+ */
+
+ if (FORM_SRC == mpage->form &&
+ strcasecmp(mpage->sec, mlink->dsec)) {
+ match = 0;
+ say(mlink->file, "Section \"%s\" manual in %s directory",
+ mpage->sec, mlink->dsec);
+ }
+
+ /*
+ * Manual page directories exist for each kernel
+ * architecture as returned by machine(1).
+ * However, many manuals only depend on the
+ * application architecture as returned by arch(1).
+ * For example, some (2/ARM) manuals are shared
+ * across the "armish" and "zaurus" kernel
+ * architectures.
+ * A few manuals are even shared across completely
+ * different architectures, for example fdformat(1)
+ * on amd64, i386, sparc, and sparc64.
+ */
+
+ if (strcasecmp(mpage->arch, mlink->arch)) {
+ match = 0;
+ say(mlink->file, "Architecture \"%s\" manual in "
+ "\"%s\" directory", mpage->arch, mlink->arch);
+ }
+
+ if (strcasecmp(mpage->title, mlink->name))
+ match = 0;
+
+ return(match);
+}
+
/*
* Run through the files in the global vector "mpages"
* and add them to the database specified in "basedir".
@@ -898,6 +947,7 @@ mpages_merge(struct mchars *mc, struct mparse *mp, int check_reachable)
struct ohash title_table;
struct ohash_info title_info, str_info;
struct mpage *mpage;
+ struct mlink *mlink;
struct mdoc *mdoc;
struct man *man;
struct title *title_entry;
@@ -932,7 +982,6 @@ mpages_merge(struct mchars *mc, struct mparse *mp, int check_reachable)
mparse_reset(mp);
mdoc = NULL;
man = NULL;
- match = 1;
/*
* Try interpreting the file as mdoc(7) or man(7)
@@ -973,49 +1022,17 @@ mpages_merge(struct mchars *mc, struct mparse *mp, int check_reachable)
mandoc_strdup(mpage->mlinks->name);
}
- /*
- * Check whether the manual section given in a file
- * agrees with the directory where the file is located.
- * Some manuals have suffixes like (3p) on their
- * section number either inside the file or in the
- * directory name, some are linked into more than one
- * section, like encrypt(1) = makekey(8). Do not skip
- * manuals for such reasons.
- */
- if (warnings && !use_all && FORM_SRC == mpage->form &&
- strcasecmp(mpage->sec, mpage->mlinks->dsec)) {
- match = 0;
- say(mpage->mlinks->file, "Section \"%s\" "
- "manual in %s directory",
- mpage->sec, mpage->mlinks->dsec);
- }
+ for (mlink = mpage->mlinks; mlink; mlink = mlink->next)
+ putkey(mpage, mlink->name, TYPE_Nm);
- /*
- * Manual page directories exist for each kernel
- * architecture as returned by machine(1).
- * However, many manuals only depend on the
- * application architecture as returned by arch(1).
- * For example, some (2/ARM) manuals are shared
- * across the "armish" and "zaurus" kernel
- * architectures.
- * A few manuals are even shared across completely
- * different architectures, for example fdformat(1)
- * on amd64, i386, sparc, and sparc64.
- * Thus, warn about architecture mismatches,
- * but don't skip manuals for this reason.
- */
- if (warnings && !use_all &&
- strcasecmp(mpage->arch, mpage->mlinks->arch)) {
- match = 0;
- say(mpage->mlinks->file, "Architecture \"%s\" "
- "manual in \"%s\" directory",
- mpage->arch, mpage->mlinks->arch);
- }
- if (warnings && !use_all &&
- strcasecmp(mpage->title, mpage->mlinks->name))
+ if (warnings && !use_all) {
match = 0;
-
- putkey(mpage, mpage->mlinks->name, TYPE_Nm);
+ for (mlink = mpage->mlinks; mlink;
+ mlink = mlink->next)
+ if (mlink_check(mpage, mlink))
+ match = 1;
+ } else
+ match = 1;
if (NULL != mdoc) {
if (NULL != (cp = mdoc_meta(mdoc)->name))