summaryrefslogtreecommitdiffstats
path: root/roff_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-12-31 07:08:12 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-12-31 07:08:12 +0000
commitc307b01e3d5709e7d34106b6fe8e98b468bf33f8 (patch)
tree939b2a1acb043c38c2dacc70855f028e163b6f42 /roff_validate.c
parentc0cea6817b9d23d8e5e4a752fc1dff8dfb604cdc (diff)
downloadmandoc-c307b01e3d5709e7d34106b6fe8e98b468bf33f8.tar.gz
Move parsing of the .nf and .fi (fill mode) requests from the man(7)
parser to the roff(7) parser. As a side effect, .nf and .fi are now also parsed in mdoc(7) input, though the mdoc(7) formatters still ignore most of their effect.
Diffstat (limited to 'roff_validate.c')
-rw-r--r--roff_validate.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/roff_validate.c b/roff_validate.c
index 0aaace13..6fb60057 100644
--- a/roff_validate.c
+++ b/roff_validate.c
@@ -30,15 +30,19 @@
typedef void (*roff_valid_fp)(ROFF_VALID_ARGS);
static void roff_valid_br(ROFF_VALID_ARGS);
+static void roff_valid_fi(ROFF_VALID_ARGS);
static void roff_valid_ft(ROFF_VALID_ARGS);
+static void roff_valid_nf(ROFF_VALID_ARGS);
static void roff_valid_sp(ROFF_VALID_ARGS);
static const roff_valid_fp roff_valids[ROFF_MAX] = {
roff_valid_br, /* br */
NULL, /* ce */
+ roff_valid_fi, /* fi */
roff_valid_ft, /* ft */
NULL, /* ll */
NULL, /* mc */
+ roff_valid_nf, /* nf */
NULL, /* po */
NULL, /* rj */
roff_valid_sp, /* sp */
@@ -63,10 +67,6 @@ roff_valid_br(ROFF_VALID_ARGS)
{
struct roff_node *np;
- if (n->child != NULL)
- mandoc_msg(MANDOCERR_ARG_SKIP,
- n->line, n->pos, "br %s", n->child->string);
-
if (n->next != NULL && n->next->type == ROFFT_TEXT &&
*n->next->string == ' ') {
mandoc_msg(MANDOCERR_PAR_SKIP, n->line, n->pos,
@@ -92,6 +92,13 @@ roff_valid_br(ROFF_VALID_ARGS)
}
static void
+roff_valid_fi(ROFF_VALID_ARGS)
+{
+ if ((man->flags & ROFF_NOFILL) == 0)
+ mandoc_msg(MANDOCERR_FI_SKIP, n->line, n->pos, "fi");
+}
+
+static void
roff_valid_ft(ROFF_VALID_ARGS)
{
const char *cp;
@@ -111,15 +118,17 @@ roff_valid_ft(ROFF_VALID_ARGS)
}
static void
+roff_valid_nf(ROFF_VALID_ARGS)
+{
+ if (man->flags & ROFF_NOFILL)
+ mandoc_msg(MANDOCERR_NF_SKIP, n->line, n->pos, "nf");
+}
+
+static void
roff_valid_sp(ROFF_VALID_ARGS)
{
struct roff_node *np;
- if (n->child != NULL && n->child->next != NULL)
- mandoc_msg(MANDOCERR_ARG_EXCESS,
- n->child->next->line, n->child->next->pos,
- "sp ... %s", n->child->next->string);
-
if ((np = n->prev) == NULL)
return;