aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_validate.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
commit924c4755ac64b780903344b188653f513990a771 (patch)
tree8790707d642423006b0f909baf400a6dc333adcb /man_validate.c
parentc2d0e548871bfed103ed040312a4333026ee10f1 (diff)
downloadmandoc-924c4755ac64b780903344b188653f513990a771.tar.gz
mandoc-924c4755ac64b780903344b188653f513990a771.tar.zst
mandoc-924c4755ac64b780903344b188653f513990a771.zip
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 'man_validate.c')
-rw-r--r--man_validate.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/man_validate.c b/man_validate.c
index ad8206b6..16d99635 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012-2016 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -180,10 +180,10 @@ static void
post_OP(CHKARGS)
{
- if (n->nchild == 0)
+ if (n->child == NULL)
mandoc_msg(MANDOCERR_OP_EMPTY, man->parse,
n->line, n->pos, "OP");
- else if (n->nchild > 2) {
+ else if (n->child->next != NULL && n->child->next->next != NULL) {
n = n->child->next->next;
mandoc_vmsg(MANDOCERR_ARG_EXCESS, man->parse,
n->line, n->pos, "OP ... %s", n->string);
@@ -206,7 +206,7 @@ post_ft(CHKARGS)
char *cp;
int ok;
- if (0 == n->nchild)
+ if (n->child == NULL)
return;
ok = 0;
@@ -256,22 +256,22 @@ check_par(CHKARGS)
switch (n->type) {
case ROFFT_BLOCK:
- if (0 == n->body->nchild)
+ if (n->body->child == NULL)
roff_node_delete(man, n);
break;
case ROFFT_BODY:
- if (0 == n->nchild)
+ if (n->child == NULL)
mandoc_vmsg(MANDOCERR_PAR_SKIP,
man->parse, n->line, n->pos,
"%s empty", man_macronames[n->tok]);
break;
case ROFFT_HEAD:
- if (n->nchild)
+ if (n->child != NULL)
mandoc_vmsg(MANDOCERR_ARG_SKIP,
man->parse, n->line, n->pos,
"%s %s%s", man_macronames[n->tok],
n->child->string,
- n->nchild > 1 ? " ..." : "");
+ n->child->next != NULL ? " ..." : "");
break;
default:
break;
@@ -284,11 +284,11 @@ post_IP(CHKARGS)
switch (n->type) {
case ROFFT_BLOCK:
- if (0 == n->head->nchild && 0 == n->body->nchild)
+ if (n->head->child == NULL && n->body->child == NULL)
roff_node_delete(man, n);
break;
case ROFFT_BODY:
- if (0 == n->parent->head->nchild && 0 == n->nchild)
+ if (n->parent->head->child == NULL && n->child == NULL)
mandoc_vmsg(MANDOCERR_PAR_SKIP,
man->parse, n->line, n->pos,
"%s empty", man_macronames[n->tok]);