diff options
author | 2014-04-04 16:43:08 +0000 | |
---|---|---|
committer | 2014-04-04 16:43:08 +0000 | |
commit | c0befed7bb074885739b8eb8aa427fcbe2f19971 (patch) | |
tree | 4894204736dc001973ff29680378259a3f047b96 /usr.bin/mandoc/mandocdb.c | |
parent | Merge the mda, mta and smtp processes into a single unprivileged (diff) | |
download | wireguard-openbsd-c0befed7bb074885739b8eb8aa427fcbe2f19971.tar.xz wireguard-openbsd-c0befed7bb074885739b8eb8aa427fcbe2f19971.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 'usr.bin/mandoc/mandocdb.c')
-rw-r--r-- | usr.bin/mandoc/mandocdb.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index 4c72000b23d..9b828af8a11 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.86 2014/04/04 15:55:17 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.87 2014/04/04 16:43:08 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -144,6 +144,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 *); @@ -487,6 +488,9 @@ mandocdb(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) { @@ -1177,6 +1181,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; |