]> git.cameronkatri.com Git - mandoc.git/blobdiff - man_validate.c
Do not prematurely close .Nd containing a broken child.
[mandoc.git] / man_validate.c
index ad8206b65bc928ed2f67975807ba8f1d98ea2bc1..16d996355eb769af9460f1ebe36ec49f1bd72c12 100644 (file)
@@ -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]);