summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-01-08 17:48:09 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-01-08 17:48:09 +0000
commit991e8ce56edd88e765887e8769dc2bfb9d7ae72e (patch)
tree96011b1282ce4792cdd546993fcf39ccb14807c3 /mandocdb.c
parent299687341193ef2f4290c7f376f73f92c6948fbf (diff)
downloadmandoc-991e8ce56edd88e765887e8769dc2bfb9d7ae72e.tar.gz
Delete the redundant "nchild" member of struct roff_node, replacing
most uses by one, a few by two pointer checks, and only one by a tiny loop - not only making data smaller, but code shorter as well. This gets rid of an implicit invariant that confused both static analysis tools and human auditors. No functional change.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 8d9781a7..c2507267 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1446,7 +1446,7 @@ parse_man(struct mpage *mpage, const struct roff_meta *meta,
char byte;
size_t sz;
- if (NULL == n)
+ if (n == NULL)
return;
/*
@@ -1458,13 +1458,12 @@ parse_man(struct mpage *mpage, const struct roff_meta *meta,
if (n->type == ROFFT_BODY && n->tok == MAN_SH) {
body = n;
- assert(body->parent);
- if (NULL != (head = body->parent->head) &&
- 1 == head->nchild &&
- NULL != (head = (head->child)) &&
+ if ((head = body->parent->head) != NULL &&
+ (head = head->child) != NULL &&
+ head->next == NULL &&
head->type == ROFFT_TEXT &&
- 0 == strcmp(head->string, "NAME") &&
- NULL != body->child) {
+ strcmp(head->string, "NAME") == 0 &&
+ body->child != NULL) {
/*
* Suck the entire NAME section into memory.
@@ -1697,7 +1696,9 @@ parse_mdoc_Va(struct mpage *mpage, const struct roff_meta *meta,
if (n->type != ROFFT_ELEM && n->type != ROFFT_BODY)
return 0;
- if (n->nchild == 1 && n->child->type == ROFFT_TEXT)
+ if (n->child != NULL &&
+ n->child->next == NULL &&
+ n->child->type == ROFFT_TEXT)
return 1;
cp = NULL;