source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Warn about missing mlinks.
@ 2014-04-04 16:43 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-04-04 16:43 UTC (permalink / raw)
  To: source

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        mandocdb.c

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.129 -r1.130
--- mandocdb.c
+++ mandocdb.c
@@ -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) {
@@ -1182,6 +1186,42 @@ nextpage:
 
 	if (0 == nodb)
 		SQL_EXEC("END TRANSACTION");
+}
+
+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
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-04 16:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-04 16:43 mdocml: Warn about missing mlinks schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).