source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Improve parsing of function names.
@ 2014-12-05 16:18 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-12-05 16:18 UTC (permalink / raw)
  To: source

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

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

only message in thread, other threads:[~2014-12-05 16:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-05 16:18 mdocml: Improve parsing of function names 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).