source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Warn about missing mlinks.
Date: Fri, 4 Apr 2014 12:43:16 -0400 (EDT)	[thread overview]
Message-ID: <201404041643.s34GhGao012983@krisdoz.my.domain> (raw)

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

                 reply	other threads:[~2014-04-04 16:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201404041643.s34GhGao012983@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).