summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-12-05 16:18:14 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-12-05 16:18:14 +0000
commitb3ad7718d1bb1f24324eaed392efbf6df95674ec (patch)
tree5207c378297e745655908586748396f285601979
parent385d605a0d5badafcade110bd877213f1d7df0d9 (diff)
downloadmandoc-b3ad7718d1bb1f24324eaed392efbf6df95674ec.tar.gz
Improve parsing of function names.
This gets rid of the last bogus entries in base and Xenocara.
-rw-r--r--mandocdb.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/mandocdb.c b/mandocdb.c
index d174306a..c5289167 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -165,6 +165,7 @@ static int parse_mdoc_head(struct mpage *, const struct mdoc_meta *,
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 struct mdoc_meta *meta,
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 struct mdoc_meta *meta,
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);
}