summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-13 22:03:04 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-13 22:03:04 +0000
commit1f64ec4845827384e677e18f5e6fbeb68822741f (patch)
treef52f81bac0a6d6b7e17e5c181803fee9322ef8e2
parent8c335297757d885c6bce155f5d8cd2a32d80931b (diff)
downloadmandoc-1f64ec4845827384e677e18f5e6fbeb68822741f.tar.gz
Unify description handling across all document types (mdoc, man, cat).
Assert that the description is unset right before calling the parse_* handler, and assign a default if it's still unset right afterwards. Remove all stray asserts and default assignments found elsewhere. This fixes SQL_STEP failures for man(7) pages lacking descriptions.
-rw-r--r--mandocdb.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 6ad2b9ae..cef53214 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1154,18 +1154,17 @@ mpages_merge(struct mchars *mc, struct mparse *mp)
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(NULL == mpage->desc);
parse_mdoc(mpage, mdoc_node(mdoc));
- if (NULL == mpage->desc)
- mpage->desc = mandoc_strdup(
- mpage->mlinks->name);
} else if (NULL != man)
parse_man(mpage, man_node(man));
else
parse_cat(mpage, fd[0]);
+ if (NULL == mpage->desc)
+ mpage->desc = mandoc_strdup(mpage->mlinks->name);
if (warnings && !use_all)
for (mlink = mpage->mlinks; mlink;
@@ -1302,8 +1301,6 @@ parse_cat(struct mpage *mpage, int fd)
if (warnings)
say(mpage->mlinks->file,
"Cannot find NAME section");
- assert(NULL == mpage->desc);
- mpage->desc = mandoc_strdup(mpage->mlinks->name);
fclose(stream);
free(title);
return;
@@ -1342,7 +1339,6 @@ parse_cat(struct mpage *mpage, int fd)
plen -= 2;
}
- assert(NULL == mpage->desc);
mpage->desc = mandoc_strdup(p);
fclose(stream);
free(title);
@@ -1482,7 +1478,6 @@ parse_man(struct mpage *mpage, const struct man_node *n)
while (' ' == *start)
start++;
- assert(NULL == mpage->desc);
mpage->desc = mandoc_strdup(start);
free(title);
return;