summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-12-31 08:38:21 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-12-31 08:38:21 +0000
commitf0d4886b46016e502843d08cf91ed8dc0e5bd086 (patch)
tree3b204fd3c3ee9b4cbda91678f7a24a1ebae8bfab
parentbb49c8a742a4e663709d44ec66f5eb01dbba930e (diff)
downloadmandoc-f0d4886b46016e502843d08cf91ed8dc0e5bd086.tar.gz
Use the new flag NODE_NOFILL in the validators, which is sometimes
simpler and always more robust. In particular, move the nesting warnings for .EX and .EE from man_state(), where they were misplaced, to the man(7) validator.
-rw-r--r--man.c5
-rw-r--r--man_validate.c22
-rw-r--r--mdoc_validate.c6
-rw-r--r--roff_validate.c2
4 files changed, 22 insertions, 13 deletions
diff --git a/man.c b/man.c
index 01b87835..54b56455 100644
--- a/man.c
+++ b/man.c
@@ -351,15 +351,10 @@ man_state(struct roff_man *man, struct roff_node *n)
switch(n->tok) {
case ROFF_nf:
case MAN_EX:
- if (man->flags & ROFF_NOFILL && (n->flags & NODE_VALID) == 0)
- mandoc_msg(MANDOCERR_NF_SKIP, n->line, n->pos, "nf");
man->flags |= ROFF_NOFILL;
break;
case ROFF_fi:
case MAN_EE:
- if ( (man->flags & ROFF_NOFILL) == 0 &&
- ! (n->flags & NODE_VALID))
- mandoc_msg(MANDOCERR_FI_SKIP, n->line, n->pos, "fi");
man->flags &= ~ROFF_NOFILL;
break;
default:
diff --git a/man_validate.c b/man_validate.c
index 2aa6a244..1407d7f4 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -48,6 +48,8 @@ static void check_root(CHKARGS);
static void check_text(CHKARGS);
static void post_AT(CHKARGS);
+static void post_EE(CHKARGS);
+static void post_EX(CHKARGS);
static void post_IP(CHKARGS);
static void post_OP(CHKARGS);
static void post_SH(CHKARGS);
@@ -88,8 +90,8 @@ static const v_check man_valids[MAN_MAX - MAN_TH] = {
NULL, /* SY */
NULL, /* YS */
post_OP, /* OP */
- NULL, /* EX */
- NULL, /* EE */
+ post_EX, /* EX */
+ post_EE, /* EE */
post_UR, /* UR */
NULL, /* UE */
post_UR, /* MT */
@@ -206,7 +208,7 @@ check_text(CHKARGS)
{
char *cp, *p;
- if (man->flags & ROFF_NOFILL)
+ if (n->flags & NODE_NOFILL)
return;
cp = n->string;
@@ -216,6 +218,20 @@ check_text(CHKARGS)
}
static void
+post_EE(CHKARGS)
+{
+ if ((n->flags & NODE_NOFILL) == 0)
+ mandoc_msg(MANDOCERR_FI_SKIP, n->line, n->pos, "EE");
+}
+
+static void
+post_EX(CHKARGS)
+{
+ if (n->flags & NODE_NOFILL)
+ mandoc_msg(MANDOCERR_NF_SKIP, n->line, n->pos, "EX");
+}
+
+static void
post_OP(CHKARGS)
{
diff --git a/mdoc_validate.c b/mdoc_validate.c
index b02c17ff..0d5bda4a 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -336,9 +336,7 @@ mdoc_validate(struct roff_man *mdoc)
if (n->sec != SEC_SYNOPSIS ||
(np->tok != MDOC_Cd && np->tok != MDOC_Fd))
check_text(mdoc, n->line, n->pos, n->string);
- if (np->tok != MDOC_Ql && np->tok != MDOC_Dl &&
- (np->tok != MDOC_Bd ||
- (mdoc->flags & ROFF_NOFILL) == 0) &&
+ if ((n->flags & NODE_NOFILL) == 0 &&
(np->tok != MDOC_It || np->type != ROFFT_HEAD ||
np->parent->parent->norm->Bl.type != LIST_diag))
check_text_em(mdoc, n->line, n->pos, n->string);
@@ -411,7 +409,7 @@ check_text(struct roff_man *mdoc, int ln, int pos, char *p)
{
char *cp;
- if (mdoc->flags & ROFF_NOFILL)
+ if (mdoc->last->flags & NODE_NOFILL)
return;
for (cp = p; NULL != (p = strchr(p, '\t')); p++)
diff --git a/roff_validate.c b/roff_validate.c
index 6fb60057..e705810c 100644
--- a/roff_validate.c
+++ b/roff_validate.c
@@ -94,7 +94,7 @@ roff_valid_br(ROFF_VALID_ARGS)
static void
roff_valid_fi(ROFF_VALID_ARGS)
{
- if ((man->flags & ROFF_NOFILL) == 0)
+ if ((n->flags & NODE_NOFILL) == 0)
mandoc_msg(MANDOCERR_FI_SKIP, n->line, n->pos, "fi");
}