summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/usr.bin/mandoc/man/RS/Makefile4
-rw-r--r--regress/usr.bin/mandoc/man/RS/empty.out_lint1
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bd/blank.out_lint2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bk/badarg.out_lint2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/empty.out_lint22
-rw-r--r--regress/usr.bin/mandoc/mdoc/D1/spacing.out_lint2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Dl/spacing.out_lint2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Lb/badargs.out_lint1
-rw-r--r--usr.bin/mandoc/man_validate.c8
-rw-r--r--usr.bin/mandoc/mandoc.h4
-rw-r--r--usr.bin/mandoc/mdoc_macro.c7
-rw-r--r--usr.bin/mandoc/mdoc_validate.c100
-rw-r--r--usr.bin/mandoc/read.c4
13 files changed, 49 insertions, 110 deletions
diff --git a/regress/usr.bin/mandoc/man/RS/Makefile b/regress/usr.bin/mandoc/man/RS/Makefile
index 33457370b89..67efb7488d6 100644
--- a/regress/usr.bin/mandoc/man/RS/Makefile
+++ b/regress/usr.bin/mandoc/man/RS/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.9 2015/01/24 01:59:40 schwarze Exp $
+# $OpenBSD: Makefile,v 1.10 2015/02/06 07:12:34 schwarze Exp $
REGRESS_TARGETS = breaking broken empty literal lonelyRE
REGRESS_TARGETS += nested noRE REarg width
-LINT_TARGETS = lonelyRE noRE REarg
+LINT_TARGETS = empty lonelyRE noRE REarg
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/man/RS/empty.out_lint b/regress/usr.bin/mandoc/man/RS/empty.out_lint
new file mode 100644
index 00000000000..fe983c38986
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/RS/empty.out_lint
@@ -0,0 +1 @@
+mandoc: empty.in:7:2: WARNING: empty block: RS
diff --git a/regress/usr.bin/mandoc/mdoc/Bd/blank.out_lint b/regress/usr.bin/mandoc/mdoc/Bd/blank.out_lint
index 8bcfc3d265f..fde72ad0d8a 100644
--- a/regress/usr.bin/mandoc/mdoc/Bd/blank.out_lint
+++ b/regress/usr.bin/mandoc/mdoc/Bd/blank.out_lint
@@ -5,4 +5,4 @@ mandoc: blank.in:21:36: WARNING: whitespace at end of input line
mandoc: blank.in:22:37: WARNING: whitespace at end of input line
mandoc: blank.in:23:32: WARNING: whitespace at end of input line
mandoc: blank.in:30:8: WARNING: whitespace at end of input line
-mandoc: blank.in:30:2: WARNING: skipping empty macro: Dl
+mandoc: blank.in:30:2: WARNING: empty block: Dl
diff --git a/regress/usr.bin/mandoc/mdoc/Bk/badarg.out_lint b/regress/usr.bin/mandoc/mdoc/Bk/badarg.out_lint
index 310c156d58d..16918ae5720 100644
--- a/regress/usr.bin/mandoc/mdoc/Bk/badarg.out_lint
+++ b/regress/usr.bin/mandoc/mdoc/Bk/badarg.out_lint
@@ -3,4 +3,4 @@ mandoc: badarg.in:22:5: ERROR: skipping excess arguments: Bk ... -lines
mandoc: badarg.in:24:2: ERROR: skipping all arguments: Ek tail argument
mandoc: badarg.in:31:5: ERROR: skipping excess arguments: Bk ... -line
mandoc: badarg.in:49:12: ERROR: skipping excess arguments: Bk ... -murks
-mandoc: badarg.in:54:2: WARNING: skipping empty macro: Bk
+mandoc: badarg.in:54:2: WARNING: empty block: Bk
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/empty.out_lint b/regress/usr.bin/mandoc/mdoc/Bl/empty.out_lint
index 837f5f5ec97..3df60e6d5d2 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/empty.out_lint
+++ b/regress/usr.bin/mandoc/mdoc/Bl/empty.out_lint
@@ -1,11 +1,11 @@
-mandoc: empty.in:9:2: WARNING: skipping empty macro: Bl
-mandoc: empty.in:12:2: WARNING: skipping empty macro: Bl
-mandoc: empty.in:15:2: WARNING: skipping empty macro: Bl
-mandoc: empty.in:18:2: WARNING: skipping empty macro: Bl
-mandoc: empty.in:21:2: WARNING: skipping empty macro: Bl
-mandoc: empty.in:24:2: WARNING: skipping empty macro: Bl
-mandoc: empty.in:27:2: WARNING: skipping empty macro: Bl
-mandoc: empty.in:30:2: WARNING: skipping empty macro: Bl
-mandoc: empty.in:33:2: WARNING: skipping empty macro: Bl
-mandoc: empty.in:36:2: WARNING: skipping empty macro: Bl
-mandoc: empty.in:39:2: WARNING: skipping empty macro: Bl
+mandoc: empty.in:9:2: WARNING: empty block: Bl
+mandoc: empty.in:12:2: WARNING: empty block: Bl
+mandoc: empty.in:15:2: WARNING: empty block: Bl
+mandoc: empty.in:18:2: WARNING: empty block: Bl
+mandoc: empty.in:21:2: WARNING: empty block: Bl
+mandoc: empty.in:24:2: WARNING: empty block: Bl
+mandoc: empty.in:27:2: WARNING: empty block: Bl
+mandoc: empty.in:30:2: WARNING: empty block: Bl
+mandoc: empty.in:33:2: WARNING: empty block: Bl
+mandoc: empty.in:36:2: WARNING: empty block: Bl
+mandoc: empty.in:39:2: WARNING: empty block: Bl
diff --git a/regress/usr.bin/mandoc/mdoc/D1/spacing.out_lint b/regress/usr.bin/mandoc/mdoc/D1/spacing.out_lint
index 5b2e9475191..0817773485c 100644
--- a/regress/usr.bin/mandoc/mdoc/D1/spacing.out_lint
+++ b/regress/usr.bin/mandoc/mdoc/D1/spacing.out_lint
@@ -1 +1 @@
-mandoc: spacing.in:11:2: WARNING: skipping empty macro: D1
+mandoc: spacing.in:11:2: WARNING: empty block: D1
diff --git a/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_lint b/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_lint
index 937eae77481..7ee4919d592 100644
--- a/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_lint
+++ b/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_lint
@@ -1 +1 @@
-mandoc: spacing.in:11:2: WARNING: skipping empty macro: Dl
+mandoc: spacing.in:11:2: WARNING: empty block: Dl
diff --git a/regress/usr.bin/mandoc/mdoc/Lb/badargs.out_lint b/regress/usr.bin/mandoc/mdoc/Lb/badargs.out_lint
index 72dd6590cbc..52af647dee6 100644
--- a/regress/usr.bin/mandoc/mdoc/Lb/badargs.out_lint
+++ b/regress/usr.bin/mandoc/mdoc/Lb/badargs.out_lint
@@ -1,2 +1 @@
mandoc: badargs.in:9:2: WARNING: skipping empty macro: Lb
-mandoc: badargs.in:10:2: WARNING: argument count wrong: want 1 children (have 2)
diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c
index 2a21fb4669b..d16bdf2be69 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.80 2015/01/24 02:41:32 schwarze Exp $ */
+/* $OpenBSD: man_validate.c,v 1.81 2015/02/06 07:12:34 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -250,9 +250,9 @@ static void
check_part(CHKARGS)
{
- if (MAN_BODY == n->type && 0 == n->nchild)
- mandoc_msg(MANDOCERR_ARGCWARN, man->parse, n->line,
- n->pos, "want children (have none)");
+ if (n->type == MAN_BODY && n->child == NULL)
+ mandoc_msg(MANDOCERR_BLK_EMPTY, man->parse,
+ n->line, n->pos, man_macronames[n->tok]);
}
static void
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 3fc4aa4295b..e5bacda7f50 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.h,v 1.139 2015/02/06 03:31:11 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.140 2015/02/06 07:12:34 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -92,8 +92,8 @@ 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_BLK_EMPTY, /* empty block: macro */
MANDOCERR_ARG_EMPTY, /* empty argument, using 0n: macro arg */
- MANDOCERR_ARGCWARN, /* argument count wrong */
MANDOCERR_BD_NOTYPE, /* missing display type, using -ragged: Bd */
MANDOCERR_BL_LATETYPE, /* list type is not the first argument: Bl arg */
MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 8n */
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index 58be4b69f64..4dcd103c929 100644
--- a/usr.bin/mandoc/mdoc_macro.c
+++ b/usr.bin/mandoc/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_macro.c,v 1.134 2015/02/06 03:31:11 schwarze Exp $ */
+/* $OpenBSD: mdoc_macro.c,v 1.135 2015/02/06 07:12:34 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -1401,9 +1401,10 @@ in_line_eoln(MACRO_PROT_ARGS)
rew_last(mdoc, mdoc->last->parent);
}
- if (buf[*pos] == '\0' && tok == MDOC_Fd) {
+ if (buf[*pos] == '\0' &&
+ (tok == MDOC_Fd || mdoc_macronames[tok][0] == '%')) {
mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
- line, ppos, "Fd");
+ line, ppos, mdoc_macronames[tok]);
return;
}
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index da3b10946c1..328daf6566d 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_validate.c,v 1.190 2015/02/06 03:31:11 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.191 2015/02/06 07:12:34 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -54,8 +54,6 @@ struct valids {
v_post post;
};
-static void check_count(struct mdoc *, enum mdoc_type,
- enum check_ineq, int);
static void check_text(struct mdoc *, int, int, char *);
static void check_argv(struct mdoc *,
struct mdoc_node *, struct mdoc_argv *);
@@ -65,9 +63,6 @@ static enum mdoc_sec a2sec(const char *);
static size_t macro2len(enum mdoct);
static void rewrite_macro2len(char **);
-static void ewarn_eq1(POST_ARGS);
-static void ewarn_ge1(POST_ARGS);
-
static void post_an(POST_ARGS);
static void post_at(POST_ARGS);
static void post_bf(POST_ARGS);
@@ -90,7 +85,6 @@ static void post_fn(POST_ARGS);
static void post_fname(POST_ARGS);
static void post_fo(POST_ARGS);
static void post_hyph(POST_ARGS);
-static void post_hyphtext(POST_ARGS);
static void post_ignpar(POST_ARGS);
static void post_it(POST_ARGS);
static void post_lb(POST_ARGS);
@@ -165,17 +159,17 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Va */
{ NULL, post_vt }, /* Vt */
{ NULL, NULL }, /* Xr */
- { NULL, ewarn_ge1 }, /* %A */
- { NULL, post_hyphtext }, /* %B */ /* FIXME: can be used outside Rs/Re. */
- { NULL, ewarn_ge1 }, /* %D */
- { NULL, ewarn_ge1 }, /* %I */
- { NULL, ewarn_ge1 }, /* %J */
- { NULL, post_hyphtext }, /* %N */
- { NULL, post_hyphtext }, /* %O */
- { NULL, ewarn_ge1 }, /* %P */
- { NULL, post_hyphtext }, /* %R */
- { NULL, post_hyphtext }, /* %T */ /* FIXME: can be used outside Rs/Re. */
- { NULL, ewarn_ge1 }, /* %V */
+ { NULL, NULL }, /* %A */
+ { NULL, post_hyph }, /* %B */ /* FIXME: can be used outside Rs/Re. */
+ { NULL, NULL }, /* %D */
+ { NULL, NULL }, /* %I */
+ { NULL, NULL }, /* %J */
+ { NULL, post_hyph }, /* %N */
+ { NULL, post_hyph }, /* %O */
+ { NULL, NULL }, /* %P */
+ { NULL, post_hyph }, /* %R */
+ { NULL, post_hyph }, /* %T */ /* FIXME: can be used outside Rs/Re. */
+ { NULL, NULL }, /* %V */
{ NULL, NULL }, /* Ac */
{ NULL, NULL }, /* Ao */
{ NULL, NULL }, /* Aq */
@@ -237,14 +231,14 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Brq */
{ NULL, NULL }, /* Bro */
{ NULL, NULL }, /* Brc */
- { NULL, ewarn_ge1 }, /* %C */
+ { NULL, NULL }, /* %C */
{ pre_obsolete, post_es }, /* Es */
{ pre_obsolete, post_en }, /* En */
{ NULL, NULL }, /* Dx */
- { NULL, ewarn_ge1 }, /* %Q */
+ { NULL, NULL }, /* %Q */
{ NULL, post_par }, /* br */
{ NULL, post_par }, /* sp */
- { NULL, ewarn_eq1 }, /* %U */
+ { NULL, NULL }, /* %U */
{ NULL, NULL }, /* Ta */
{ NULL, NULL }, /* ll */
};
@@ -364,53 +358,6 @@ mdoc_valid_post(struct mdoc *mdoc)
}
static void
-check_count(struct mdoc *mdoc, enum mdoc_type type,
- enum check_ineq ineq, int val)
-{
- const char *p;
-
- if (mdoc->last->type != type)
- return;
-
- switch (ineq) {
- case CHECK_LT:
- p = "less than ";
- if (mdoc->last->nchild < val)
- return;
- break;
- case CHECK_GT:
- p = "more than ";
- if (mdoc->last->nchild > val)
- return;
- break;
- case CHECK_EQ:
- p = "";
- if (val == mdoc->last->nchild)
- return;
- break;
- default:
- abort();
- /* NOTREACHED */
- }
-
- mandoc_vmsg(MANDOCERR_ARGCWARN, mdoc->parse, mdoc->last->line,
- mdoc->last->pos, "want %s%d children (have %d)",
- p, val, mdoc->last->nchild);
-}
-
-static void
-ewarn_eq1(POST_ARGS)
-{
- check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1);
-}
-
-static void
-ewarn_ge1(POST_ARGS)
-{
- check_count(mdoc, MDOC_ELEM, CHECK_GT, 0);
-}
-
-static void
check_args(struct mdoc *mdoc, struct mdoc_node *n)
{
int i;
@@ -917,7 +864,6 @@ post_lb(POST_ARGS)
struct mdoc_node *n;
char *libname;
- check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1);
n = mdoc->last->child;
assert(MDOC_TEXT == n->type);
mandoc_asprintf(&libname, "library \\(lq%s\\(rq", n->string);
@@ -1080,7 +1026,7 @@ post_d1(POST_ARGS)
return;
if (n->child == NULL)
- mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
+ mandoc_msg(MANDOCERR_BLK_EMPTY, mdoc->parse,
n->line, n->pos, "D1");
post_hyph(mdoc);
@@ -1097,7 +1043,7 @@ post_literal(POST_ARGS)
return;
if (n->child == NULL)
- mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
+ mandoc_msg(MANDOCERR_BLK_EMPTY, mdoc->parse,
n->line, n->pos, mdoc_macronames[n->tok]);
if (n->tok == MDOC_Bd &&
@@ -1504,7 +1450,7 @@ post_bl(POST_ARGS)
nchild = nbody->child;
if (nchild == NULL) {
- mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
+ mandoc_msg(MANDOCERR_BLK_EMPTY, mdoc->parse,
nbody->line, nbody->pos, "Bl");
return;
}
@@ -1572,7 +1518,7 @@ post_bk(POST_ARGS)
n = mdoc->last;
if (n->type == MDOC_BLOCK && n->body->child == NULL) {
- mandoc_msg(MANDOCERR_MACRO_EMPTY,
+ mandoc_msg(MANDOCERR_BLK_EMPTY,
mdoc->parse, n->line, n->pos, "Bk");
mdoc_node_delete(mdoc, n);
}
@@ -1784,14 +1730,6 @@ post_hyph(POST_ARGS)
}
static void
-post_hyphtext(POST_ARGS)
-{
-
- ewarn_ge1(mdoc);
- post_hyph(mdoc);
-}
-
-static void
post_ns(POST_ARGS)
{
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 95fbee763f9..05bb1a4158f 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.98 2015/02/06 03:31:11 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.99 2015/02/06 07:12:34 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -131,8 +131,8 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"skipping empty request",
"conditional request controls empty scope",
"skipping empty macro",
+ "empty block",
"empty argument, using 0n",
- "argument count wrong",
"missing display type, using -ragged",
"list type is not the first argument",
"missing -width in -tag list, using 8n",