source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: In -p (picky) mode, warn unless each filename (aka mlink)
Date: Fri, 4 Apr 2014 14:23:30 -0400 (EDT)	[thread overview]
Message-ID: <201404041823.s34INUKx002152@krisdoz.my.domain> (raw)

Log Message:
-----------
In -p (picky) mode, warn unless each filename (aka mlink) 
appears as a name in the NAME section.
While here, garbage collect two unused variables, both called "match".

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.130
retrieving revision 1.131
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.130 -r1.131
--- mandocdb.c
+++ mandocdb.c
@@ -147,7 +147,7 @@ static	void	*hash_alloc(size_t, void *);
 static	void	 hash_free(void *, size_t, void *);
 static	void	*hash_halloc(size_t, void *);
 static	void	 mlink_add(struct mlink *, const struct stat *);
-static	int	 mlink_check(struct mpage *, struct mlink *);
+static	void	 mlink_check(struct mpage *, struct mlink *);
 static	void	 mlink_free(struct mlink *);
 static	void	 mlinks_undupe(struct mpage *);
 static	void	 mpages_free(void);
@@ -924,12 +924,11 @@ nextlink:
 	}
 }
 
-static int
+static void
 mlink_check(struct mpage *mpage, struct mlink *mlink)
 {
-	int	 match;
-
-	match = 1;
+	struct str	*str;
+	unsigned int	 slot;
 
 	/*
 	 * Check whether the manual section given in a file
@@ -941,11 +940,9 @@ mlink_check(struct mpage *mpage, struct 
 	 */
 
 	if (FORM_SRC == mpage->form &&
-	    strcasecmp(mpage->sec, mlink->dsec)) {
-		match = 0;
+	    strcasecmp(mpage->sec, mlink->dsec))
 		say(mlink->file, "Section \"%s\" manual in %s directory",
 		    mpage->sec, mlink->dsec);
-	}
 
 	/*
 	 * Manual page directories exist for each kernel
@@ -960,16 +957,28 @@ mlink_check(struct mpage *mpage, struct 
 	 * on amd64, i386, sparc, and sparc64.
 	 */
 
-	if (strcasecmp(mpage->arch, mlink->arch)) {
-		match = 0;
+	if (strcasecmp(mpage->arch, mlink->arch))
 		say(mlink->file, "Architecture \"%s\" manual in "
 		    "\"%s\" directory", mpage->arch, mlink->arch);
-	}
 
-	if (strcasecmp(mpage->title, mlink->name))
-		match = 0;
+	/*
+	 * XXX
+	 * parse_cat() doesn't set TYPE_Nm and TYPE_NAME yet.
+	 */
+
+	if (FORM_CAT == mpage->form)
+		return;
+
+	/*
+	 * Check whether this mlink
+	 * appears as a name in the NAME section.
+	 */
 
-	return(match);
+	slot = ohash_qlookup(&strings, mlink->name);
+	str = ohash_find(&strings, slot);
+	assert(NULL != str);
+	if ( ! (TYPE_NAME & str->mask))
+		say(mlink->file, "Name missing in NAME section");
 }
 
 /*
@@ -992,7 +1001,7 @@ mpages_merge(struct mchars *mc, struct m
 	char			*sodest;
 	char			*cp;
 	pid_t			 child_pid;
-	int			 match, status;
+	int			 status;
 	unsigned int		 pslot;
 	enum mandoclevel	 lvl;
 
@@ -1140,15 +1149,6 @@ mpages_merge(struct mchars *mc, struct m
 			putkey(mpage, mlink->name, TYPE_Nm);
 		}
 
-		if (warnings && !use_all) {
-			match = 0;
-			for (mlink = mpage->mlinks; mlink;
-			     mlink = mlink->next)
-				if (mlink_check(mpage, mlink))
-					match = 1;
-		} else
-			match = 1;
-
 		if (NULL != mdoc) {
 			if (NULL != (cp = mdoc_meta(mdoc)->name))
 				putkey(mpage, cp, TYPE_Nm);
@@ -1160,6 +1160,11 @@ mpages_merge(struct mchars *mc, struct m
 			parse_man(mpage, man_node(man));
 		else
 			parse_cat(mpage, fd[0]);
+
+		if (warnings && !use_all)
+			for (mlink = mpage->mlinks; mlink;
+			     mlink = mlink->next)
+				mlink_check(mpage, mlink);
 
 		dbadd(mpage, mc);
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-04-04 18:23 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=201404041823.s34INUKx002152@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).