aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-04 16:43:16 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-04 16:43:16 +0000
commita381b76e862814c2d4734656d9148a5c26ee2e72 (patch)
tree9b8d13729cf38ff9c76e7c09eef028b78d6a1b99 /mandocdb.c
parent994580065e7e64895b2192324b068e553d90f7ba (diff)
downloadmandoc-a381b76e862814c2d4734656d9148a5c26ee2e72.tar.gz
mandoc-a381b76e862814c2d4734656d9148a5c26ee2e72.tar.zst
mandoc-a381b76e862814c2d4734656d9148a5c26ee2e72.zip
Warn about missing mlinks.
This is really expensive, more than tripling database build times, so only do it when the -p (picky) option was given, but none of the following options were given: -Q (quick), -d, -u, or -t.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 40f673fe..90bfd1ef 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.129 2014/04/04 15:55:19 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.130 2014/04/04 16:43:16 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -152,6 +152,7 @@ static void mlink_free(struct mlink *);
static void mlinks_undupe(struct mpage *);
static void mpages_free(void);
static void mpages_merge(struct mchars *, struct mparse *);
+static void names_check(void);
static void parse_cat(struct mpage *, int);
static void parse_man(struct mpage *, const struct man_node *);
static void parse_mdoc(struct mpage *, const struct mdoc_node *);
@@ -495,6 +496,9 @@ main(int argc, char *argv[])
goto out;
mpages_merge(mc, mp);
+ if (warnings &&
+ ! (MPARSE_QUICK & mparse_options))
+ names_check();
dbclose(0);
if (j + 1 < dirs.sz) {
@@ -1185,6 +1189,42 @@ nextpage:
}
static void
+names_check(void)
+{
+ sqlite3_stmt *stmt;
+ const char *name, *sec, *arch, *key;
+ size_t i;
+ int irc;
+
+ sqlite3_prepare_v2(db,
+ "SELECT name, sec, arch, key FROM ("
+ "SELECT key, pageid FROM keys "
+ "WHERE bits & ? AND NOT EXISTS ("
+ "SELECT pageid FROM mlinks "
+ "WHERE mlinks.pageid == keys.pageid "
+ "AND mlinks.name == keys.key"
+ ")"
+ ") JOIN ("
+ "SELECT * FROM mlinks GROUP BY pageid"
+ ") USING (pageid);",
+ -1, &stmt, NULL);
+
+ i = 1;
+ SQL_BIND_INT64(stmt, i, TYPE_NAME);
+
+ while (SQLITE_ROW == (irc = sqlite3_step(stmt))) {
+ name = sqlite3_column_text(stmt, 0);
+ sec = sqlite3_column_text(stmt, 1);
+ arch = sqlite3_column_text(stmt, 2);
+ key = sqlite3_column_text(stmt, 3);
+ say("", "%s(%s%s%s) lacks mlink \"%s\"", name, sec,
+ '\0' == *arch ? "" : "/",
+ '\0' == *arch ? "" : arch, key);
+ }
+ sqlite3_finalize(stmt);
+}
+
+static void
parse_cat(struct mpage *mpage, int fd)
{
FILE *stream;