source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Improve parsing of function names.
Date: Fri, 5 Dec 2014 11:18:15 -0500 (EST)	[thread overview]
Message-ID: <7307996389125270303.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Improve parsing of function names.
This gets rid of the last bogus entries in base and Xenocara.

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

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.177
retrieving revision 1.178
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.177 -r1.178
--- mandocdb.c
+++ mandocdb.c
@@ -165,6 +165,7 @@ static	int	 parse_mdoc_head(struct mpage
 			const struct mdoc_node *);
 static	int	 parse_mdoc_Fd(struct mpage *, const struct mdoc_meta *,
 			const struct mdoc_node *);
+static	void	 parse_mdoc_fname(struct mpage *, const struct mdoc_node *);
 static	int	 parse_mdoc_Fn(struct mpage *, const struct mdoc_meta *,
 			const struct mdoc_node *);
 static	int	 parse_mdoc_Fo(struct mpage *, const struct mdoc_meta *,
@@ -1640,37 +1641,39 @@ parse_mdoc_Fd(struct mpage *mpage, const
 	return(0);
 }
 
-static int
-parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta,
-	const struct mdoc_node *n)
+static void
+parse_mdoc_fname(struct mpage *mpage, const struct mdoc_node *n)
 {
 	char	*cp;
+	size_t	 sz;
 
-	if (NULL == (n = n->child) || MDOC_TEXT != n->type)
-		return(0);
-
-	/*
-	 * Parse: .Fn "struct type *name" "char *arg".
-	 * First strip away pointer symbol.
-	 * Then store the function name, then type.
-	 * Finally, store the arguments.
-	 */
+	if (n->type != MDOC_TEXT)
+		return;
 
-	if (NULL == (cp = strrchr(n->string, ' ')))
-		cp = n->string;
+	/* Skip function pointer punctuation. */
 
-	while ('*' == *cp)
+	cp = n->string;
+	while (*cp == '(' || *cp == '*')
 		cp++;
+	sz = strcspn(cp, "()");
 
-	putkey(mpage, cp, TYPE_Fn);
+	putkeys(mpage, cp, sz, TYPE_Fn);
 	if (n->sec == SEC_SYNOPSIS)
-		putkey(mpage, cp, NAME_SYN);
+		putkeys(mpage, cp, sz, NAME_SYN);
+}
 
-	if (n->string < cp)
-		putkeys(mpage, n->string, cp - n->string, TYPE_Ft);
+static int
+parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta,
+	const struct mdoc_node *n)
+{
 
-	for (n = n->next; NULL != n; n = n->next)
-		if (MDOC_TEXT == n->type)
+	if (n->child == NULL)
+		return(0);
+
+	parse_mdoc_fname(mpage, n->child);
+
+	for (n = n->child->next; n != NULL; n = n->next)
+		if (n->type == MDOC_TEXT)
 			putkey(mpage, n->string, TYPE_Fa);
 
 	return(0);
@@ -1684,9 +1687,9 @@ parse_mdoc_Fo(struct mpage *mpage, const
 	if (n->type != MDOC_HEAD)
 		return(1);
 
-	putmdockey(mpage, n->child, TYPE_Fn);
-	if (n->sec == SEC_SYNOPSIS)
-		putmdockey(mpage, n->child, NAME_SYN);
+	if (n->child != NULL)
+		parse_mdoc_fname(mpage, n->child);
+
 	return(0);
 }
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-12-05 16:18 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=7307996389125270303.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).