summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mandoc.h3
-rw-r--r--mdoc_validate.c106
-rw-r--r--read.c1
3 files changed, 54 insertions, 56 deletions
diff --git a/mandoc.h b/mandoc.h
index 5fb411a2..d54777d7 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -87,6 +87,7 @@ enum mandocerr {
MANDOCERR_REQ_EMPTY, /* skipping empty request: request */
MANDOCERR_COND_EMPTY, /* conditional request controls empty scope */
MANDOCERR_MACRO_EMPTY, /* skipping empty macro: macro */
+ MANDOCERR_ARG_EMPTY, /* empty argument, using 0n: macro arg */
MANDOCERR_ARGCWARN, /* argument count wrong */
MANDOCERR_BD_NOTYPE, /* missing display type, using -ragged */
MANDOCERR_BL_LATETYPE, /* list type is not the first argument: arg */
@@ -99,7 +100,7 @@ enum mandocerr {
/* related to bad macro arguments */
MANDOCERR_IGNARGV, /* skipping argument */
- MANDOCERR_ARGVREP, /* duplicate argument */
+ MANDOCERR_ARG_REP, /* duplicate argument: macro arg */
MANDOCERR_DISPREP, /* duplicate display type */
MANDOCERR_LISTREP, /* duplicate list type */
MANDOCERR_BADATT, /* unknown AT&T UNIX version */
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 07b59cc1..6477cbcf 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -594,10 +594,10 @@ pre_display(PRE_ARGS)
static int
pre_bl(PRE_ARGS)
{
- int i, comp, dup;
- const char *offs, *width;
- enum mdoc_list lt;
struct mdoc_node *np;
+ struct mdoc_argv *argv;
+ int i;
+ enum mdoc_list lt;
if (MDOC_BLOCK != n->type) {
if (ENDBODY_NOT != n->end) {
@@ -619,10 +619,9 @@ pre_bl(PRE_ARGS)
*/
for (i = 0; n->args && i < (int)n->args->argc; i++) {
+ argv = n->args->argv + i;
lt = LIST__NONE;
- dup = comp = 0;
- width = offs = NULL;
- switch (n->args->argv[i].arg) {
+ switch (argv->arg) {
/* Set list types. */
case MDOC_Bullet:
lt = LIST_bullet;
@@ -659,43 +658,45 @@ pre_bl(PRE_ARGS)
break;
/* Set list arguments. */
case MDOC_Compact:
- dup = n->norm->Bl.comp;
- comp = 1;
+ if (n->norm->Bl.comp)
+ mandoc_msg(MANDOCERR_ARG_REP,
+ mdoc->parse, argv->line,
+ argv->pos, "Bl -compact");
+ n->norm->Bl.comp = 1;
break;
case MDOC_Width:
- /* NB: this can be empty! */
- if (n->args->argv[i].sz) {
- width = n->args->argv[i].value[0];
- dup = (NULL != n->norm->Bl.width);
+ if (0 == argv->sz) {
+ mandoc_msg(MANDOCERR_ARG_EMPTY,
+ mdoc->parse, argv->line,
+ argv->pos, "Bl -width");
+ n->norm->Bl.width = "0n";
break;
}
- mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV);
+ if (NULL != n->norm->Bl.width)
+ mandoc_vmsg(MANDOCERR_ARG_REP,
+ mdoc->parse, argv->line,
+ argv->pos, "Bl -width %s",
+ argv->value[0]);
+ n->norm->Bl.width = argv->value[0];
break;
case MDOC_Offset:
- /* NB: this can be empty! */
- if (n->args->argv[i].sz) {
- offs = n->args->argv[i].value[0];
- dup = (NULL != n->norm->Bl.offs);
+ if (0 == argv->sz) {
+ mandoc_msg(MANDOCERR_ARG_EMPTY,
+ mdoc->parse, argv->line,
+ argv->pos, "Bl -offset");
break;
}
- mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV);
+ if (NULL != n->norm->Bl.offs)
+ mandoc_vmsg(MANDOCERR_ARG_REP,
+ mdoc->parse, argv->line,
+ argv->pos, "Bl -offset %s",
+ argv->value[0]);
+ n->norm->Bl.offs = argv->value[0];
break;
default:
continue;
}
- /* Check: duplicate auxiliary arguments. */
-
- if (dup)
- mdoc_nmsg(mdoc, n, MANDOCERR_ARGVREP);
-
- if (comp && ! dup)
- n->norm->Bl.comp = comp;
- if (offs && ! dup)
- n->norm->Bl.offs = offs;
- if (width && ! dup)
- n->norm->Bl.width = width;
-
/* Check: multiple list types. */
if (LIST__NONE != lt && n->norm->Bl.type != LIST__NONE)
@@ -779,10 +780,10 @@ pre_bl(PRE_ARGS)
static int
pre_bd(PRE_ARGS)
{
- int i, dup, comp;
- enum mdoc_disp dt;
- const char *offs;
struct mdoc_node *np;
+ struct mdoc_argv *argv;
+ int i;
+ enum mdoc_disp dt;
if (MDOC_BLOCK != n->type) {
if (ENDBODY_NOT != n->end) {
@@ -798,11 +799,10 @@ pre_bd(PRE_ARGS)
}
for (i = 0; n->args && i < (int)n->args->argc; i++) {
+ argv = n->args->argv + i;
dt = DISP__NONE;
- dup = comp = 0;
- offs = NULL;
- switch (n->args->argv[i].arg) {
+ switch (argv->arg) {
case MDOC_Centred:
dt = DISP_centred;
break;
@@ -822,35 +822,31 @@ pre_bd(PRE_ARGS)
mdoc_nmsg(mdoc, n, MANDOCERR_BADDISP);
return(0);
case MDOC_Offset:
- /* NB: this can be empty! */
- if (n->args->argv[i].sz) {
- offs = n->args->argv[i].value[0];
- dup = (NULL != n->norm->Bd.offs);
+ if (0 == argv->sz) {
+ mandoc_msg(MANDOCERR_ARG_EMPTY,
+ mdoc->parse, argv->line,
+ argv->pos, "Bd -offset");
break;
}
- mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV);
+ if (NULL != n->norm->Bd.offs)
+ mandoc_vmsg(MANDOCERR_ARG_REP,
+ mdoc->parse, argv->line,
+ argv->pos, "Bd -offset %s",
+ argv->value[0]);
+ n->norm->Bd.offs = argv->value[0];
break;
case MDOC_Compact:
- comp = 1;
- dup = n->norm->Bd.comp;
+ if (n->norm->Bd.comp)
+ mandoc_msg(MANDOCERR_ARG_REP,
+ mdoc->parse, argv->line,
+ argv->pos, "Bd -compact");
+ n->norm->Bd.comp = 1;
break;
default:
abort();
/* NOTREACHED */
}
- /* Check whether we have duplicates. */
-
- if (dup)
- mdoc_nmsg(mdoc, n, MANDOCERR_ARGVREP);
-
- /* Make our auxiliary assignments. */
-
- if (offs && ! dup)
- n->norm->Bd.offs = offs;
- if (comp && ! dup)
- n->norm->Bd.comp = comp;
-
/* Check whether a type has already been assigned. */
if (DISP__NONE != dt && n->norm->Bd.type != DISP__NONE)
diff --git a/read.c b/read.c
index 43f4b650..d78f3d17 100644
--- a/read.c
+++ b/read.c
@@ -131,6 +131,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"skipping empty request",
"conditional request controls empty scope",
"skipping empty macro",
+ "empty argument, using 0n",
"argument count wrong",
"missing display type, using -ragged",
"list type is not the first argument",