summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/man_validate.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2015-04-02 21:03:18 +0000
committerschwarze <schwarze@openbsd.org>2015-04-02 21:03:18 +0000
commitd1982c71f56a0339cf367753d1e1b041d168b36d (patch)
treec83c97602d07cad8b3112e543ed123b9618c6b04 /usr.bin/mandoc/man_validate.c
parentFixed whitespace issues. (diff)
downloadwireguard-openbsd-d1982c71f56a0339cf367753d1e1b041d168b36d.tar.xz
wireguard-openbsd-d1982c71f56a0339cf367753d1e1b041d168b36d.zip
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 'usr.bin/mandoc/man_validate.c')
-rw-r--r--usr.bin/mandoc/man_validate.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c
index d1c99fb98c2..a0e408cac5c 100644
--- a/usr.bin/mandoc/man_validate.c
+++ b/usr.bin/mandoc/man_validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_validate.c,v 1.84 2015/02/06 11:54:03 schwarze Exp $ */
+/* $OpenBSD: man_validate.c,v 1.85 2015/04/02 21:03:18 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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
@@ -26,11 +26,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
@@ -106,15 +107,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;
@@ -184,7 +185,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);
@@ -241,7 +242,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]);
}
@@ -251,17 +252,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,
@@ -279,11 +280,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,
@@ -425,7 +426,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;
@@ -462,7 +463,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;
@@ -472,7 +473,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];