diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2016-01-08 17:48:09 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2016-01-08 17:48:09 +0000 |
commit | 991e8ce56edd88e765887e8769dc2bfb9d7ae72e (patch) | |
tree | 96011b1282ce4792cdd546993fcf39ccb14807c3 /man_validate.c | |
parent | 299687341193ef2f4290c7f376f73f92c6948fbf (diff) | |
download | mandoc-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 'man_validate.c')
-rw-r--r-- | man_validate.c | 20 |
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]); |