diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-04 16:43:16 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-04 16:43:16 +0000 |
commit | e98e5bdad0e1811e834bce2f1a74fd6d375482af (patch) | |
tree | a67c6aa195e62bc2dac0275e5502b994e0187c78 /mandocdb.c | |
parent | 612feaffd17f2c4aa1145f4d956d80bfcc44ee7b (diff) | |
download | mandoc-e98e5bdad0e1811e834bce2f1a74fd6d375482af.tar.gz |
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.c | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -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; |