aboutsummaryrefslogtreecommitdiffstatshomepage
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
commite28ee7cf328a34bf7093917705979f206814e966 (patch)
treeba63a3155b2de65cc0667540eebc0985c99869ae
parent6d7c85a836b858fef745d7155c7346bbfad5f1c9 (diff)
downloadmandoc-e28ee7cf328a34bf7093917705979f206814e966.tar.gz
mandoc-e28ee7cf328a34bf7093917705979f206814e966.tar.zst
mandoc-e28ee7cf328a34bf7093917705979f206814e966.zip
Improve parsing of function names.
This gets rid of the last bogus entries in base and Xenocara.
-rw-r--r--mandocdb.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/mandocdb.c b/mandocdb.c
index a20e9199..2da8687f 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.177 2014/12/05 15:16:54 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.178 2014/12/05 16:18:14 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
}