summaryrefslogtreecommitdiffstats
path: root/man_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-04-02 21:36:49 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-04-02 21:36:49 +0000
commitdd569c39747096c781c1cbec49b48a85ba29f23d (patch)
tree70767fb6dfe3f18d949151c1456b3d798a4976cb /man_validate.c
parent2ee27038d09a5b1d2c51fbc67bf127f6a8c5800a (diff)
downloadmandoc-dd569c39747096c781c1cbec49b48a85ba29f23d.tar.gz
First step towards parser unification:
Replace enum mdoc_type and enum man_type by a unified enum roff_type. Almost mechanical, no functional change. Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.
Diffstat (limited to 'man_validate.c')
-rw-r--r--man_validate.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/man_validate.c b/man_validate.c
index 93ee9b3f..8614708b 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -28,11 +28,12 @@
#include <string.h>
#include <time.h>
-#include "man.h"
-#include "mandoc.h"
#include "mandoc_aux.h"
-#include "libman.h"
+#include "mandoc.h"
+#include "roff.h"
+#include "man.h"
#include "libmandoc.h"
+#include "libman.h"
#define CHKARGS struct man *man, struct man_node *n
@@ -108,15 +109,15 @@ man_valid_post(struct man *man)
n->flags |= MAN_VALID;
switch (n->type) {
- case MAN_TEXT:
+ case ROFFT_TEXT:
check_text(man, n);
break;
- case MAN_ROOT:
+ case ROFFT_ROOT:
check_root(man, n);
break;
- case MAN_EQN:
+ case ROFFT_EQN:
/* FALLTHROUGH */
- case MAN_TBL:
+ case ROFFT_TBL:
break;
default:
cp = man_valids + n->tok;
@@ -186,7 +187,7 @@ static void
post_UR(CHKARGS)
{
- if (n->type == MAN_HEAD && n->child == NULL)
+ if (n->type == ROFFT_HEAD && n->child == NULL)
mandoc_vmsg(MANDOCERR_UR_NOHEAD, man->parse,
n->line, n->pos, "UR");
check_part(man, n);
@@ -243,7 +244,7 @@ static void
check_part(CHKARGS)
{
- if (n->type == MAN_BODY && n->child == NULL)
+ if (n->type == ROFFT_BODY && n->child == NULL)
mandoc_msg(MANDOCERR_BLK_EMPTY, man->parse,
n->line, n->pos, man_macronames[n->tok]);
}
@@ -253,17 +254,17 @@ check_par(CHKARGS)
{
switch (n->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
if (0 == n->body->nchild)
man_node_delete(man, n);
break;
- case MAN_BODY:
+ case ROFFT_BODY:
if (0 == n->nchild)
mandoc_vmsg(MANDOCERR_PAR_SKIP,
man->parse, n->line, n->pos,
"%s empty", man_macronames[n->tok]);
break;
- case MAN_HEAD:
+ case ROFFT_HEAD:
if (n->nchild)
mandoc_vmsg(MANDOCERR_ARG_SKIP,
man->parse, n->line, n->pos,
@@ -281,11 +282,11 @@ post_IP(CHKARGS)
{
switch (n->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
if (0 == n->head->nchild && 0 == n->body->nchild)
man_node_delete(man, n);
break;
- case MAN_BODY:
+ case ROFFT_BODY:
if (0 == n->parent->head->nchild && 0 == n->nchild)
mandoc_vmsg(MANDOCERR_PAR_SKIP,
man->parse, n->line, n->pos,
@@ -427,7 +428,7 @@ post_UC(CHKARGS)
n = n->child;
- if (NULL == n || MAN_TEXT != n->type)
+ if (n == NULL || n->type != ROFFT_TEXT)
p = bsd_versions[0];
else {
s = n->string;
@@ -464,7 +465,7 @@ post_AT(CHKARGS)
n = n->child;
- if (NULL == n || MAN_TEXT != n->type)
+ if (n == NULL || n->type != ROFFT_TEXT)
p = unix_versions[0];
else {
s = n->string;
@@ -474,7 +475,9 @@ post_AT(CHKARGS)
p = unix_versions[1];
else if (0 == strcmp(s, "5")) {
nn = n->next;
- if (nn && MAN_TEXT == nn->type && nn->string[0])
+ if (nn != NULL &&
+ nn->type == ROFFT_TEXT &&
+ nn->string[0] != '\0')
p = unix_versions[3];
else
p = unix_versions[2];