source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: correctly store .Dt and .TH information in the names table
Date: Thu, 4 Dec 2014 15:13:56 -0500 (EST)	[thread overview]
Message-ID: <16706607910891500866.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
correctly store .Dt and .TH information in the names table

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

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.173
retrieving revision 1.174
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.173 -r1.174
--- mandocdb.c
+++ mandocdb.c
@@ -104,6 +104,7 @@ struct	mpage {
 	char		*desc;    /* description from file content */
 	struct mlink	*mlinks;  /* singly linked list */
 	int		 form;    /* format from file content */
+	int		 name_head_done;
 };
 
 struct	mlink {
@@ -154,7 +155,8 @@ 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_man(struct mpage *, const struct man_meta *,
+			const struct man_node *);
 static	void	 parse_mdoc(struct mpage *, const struct mdoc_meta *,
 			const struct mdoc_node *);
 static	int	 parse_mdoc_body(struct mpage *, const struct mdoc_meta *,
@@ -1225,16 +1227,14 @@ mpages_merge(struct mchars *mc, struct m
 			putkey(mpage, mlink->name, NAME_FILE);
 		}
 
-		assert(NULL == mpage->desc);
-		if (NULL != mdoc) {
-			if (NULL != (cp = mdoc_meta(mdoc)->name))
-				putkey(mpage, cp, NAME_HEAD);
+		assert(mpage->desc == NULL);
+		if (mdoc != NULL)
 			parse_mdoc(mpage, mdoc_meta(mdoc), mdoc_node(mdoc));
-		} else if (NULL != man)
-			parse_man(mpage, man_node(man));
+		else if (man != NULL)
+			parse_man(mpage, man_meta(man), man_node(man));
 		else
 			parse_cat(mpage, fd);
-		if (NULL == mpage->desc)
+		if (mpage->desc == NULL)
 			mpage->desc = mandoc_strdup(mpage->mlinks->name);
 
 		if (warnings && !use_all)
@@ -1439,7 +1439,8 @@ putmdockey(const struct mpage *mpage,
 }
 
 static void
-parse_man(struct mpage *mpage, const struct man_node *n)
+parse_man(struct mpage *mpage, const struct man_meta *meta,
+	const struct man_node *n)
 {
 	const struct man_node *head, *body;
 	char		*start, *title;
@@ -1505,6 +1506,11 @@ parse_man(struct mpage *mpage, const str
 					break;
 
 				putkey(mpage, start, NAME_TITLE);
+				if ( ! (mpage->name_head_done ||
+				    strcasecmp(start, meta->title))) {
+					putkey(mpage, start, NAME_HEAD);
+					mpage->name_head_done = 1;
+				}
 
 				if (' ' == byte) {
 					start += sz + 1;
@@ -1519,6 +1525,11 @@ parse_man(struct mpage *mpage, const str
 
 			if (start == title) {
 				putkey(mpage, start, NAME_TITLE);
+				if ( ! (mpage->name_head_done ||
+				    strcasecmp(start, meta->title))) {
+					putkey(mpage, start, NAME_HEAD);
+					mpage->name_head_done = 1;
+				}
 				free(title);
 				return;
 			}
@@ -1549,7 +1560,7 @@ parse_man(struct mpage *mpage, const str
 	for (n = n->child; n; n = n->next) {
 		if (NULL != mpage->desc)
 			break;
-		parse_man(mpage, n);
+		parse_man(mpage, meta, n);
 	}
 }
 
@@ -1719,6 +1730,12 @@ parse_mdoc_Nm(struct mpage *mpage, const
 			putkey(mpage, meta->name, NAME_SYN);
 		else
 			putmdockey(mpage, n->child, NAME_SYN);
+	}
+	if ( ! (mpage->name_head_done ||
+	    n->child == NULL || n->child->string == NULL ||
+	    strcasecmp(n->child->string, meta->title))) {
+		putkey(mpage, n->child->string, NAME_HEAD);
+		mpage->name_head_done = 1;
 	}
 	return(0);
 }
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-12-04 20:13 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=16706607910891500866.enqueue@fantadrom.bsd.lv \
    --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).