summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-06-20 22:58:41 +0000
committerschwarze <schwarze@openbsd.org>2014-06-20 22:58:41 +0000
commit43edbcc87ad052862caa5f4b8c2e632773e6e97d (patch)
tree5571e0a0d665c90d163218d5c70bb7498a8a2fba
parentRemove the OPENSSL_*cap getenv's. A program should not be able to (diff)
downloadwireguard-openbsd-43edbcc87ad052862caa5f4b8c2e632773e6e97d.tar.xz
wireguard-openbsd-43edbcc87ad052862caa5f4b8c2e632773e6e97d.zip
As suggested by jmc@, only include line and column numbers into messages
when they are meaningful, to avoid confusing stuff like this: $ mandoc /dev/null mandoc: /dev/null:0:1: FATAL: not a manual Instead, just say: mandoc: /dev/null: FATAL: not a manual Another example this applies to is documents having a prologue, but lacking a body. Do not throw a FATAL error for these; instead, issue a warning and show the empty document, in the man(7) case with the same amount of blank lines as groff does. Also downgrade mdoc(7) documents having content before the first .Sh from FATAL to WARNING.
-rw-r--r--regress/usr.bin/mandoc/man/TH/Makefile5
-rw-r--r--regress/usr.bin/mandoc/man/TH/emptydate.out_lint2
-rw-r--r--regress/usr.bin/mandoc/man/TH/noTH.out_lint4
-rw-r--r--regress/usr.bin/mandoc/man/TH/nobody.in1
-rw-r--r--regress/usr.bin/mandoc/man/TH/nobody.out_ascii5
-rw-r--r--regress/usr.bin/mandoc/man/TH/nobody.out_lint1
-rw-r--r--regress/usr.bin/mandoc/man/TH/twoargs.out_lint4
-rw-r--r--regress/usr.bin/mandoc/mdoc/Dt/Makefile13
-rw-r--r--regress/usr.bin/mandoc/mdoc/Dt/befSh.in9
-rw-r--r--regress/usr.bin/mandoc/mdoc/Dt/befSh.out_lint1
-rw-r--r--regress/usr.bin/mandoc/mdoc/Dt/nobody.in3
-rw-r--r--regress/usr.bin/mandoc/mdoc/Dt/nobody.out_ascii3
-rw-r--r--regress/usr.bin/mandoc/mdoc/Dt/nobody.out_lint1
-rw-r--r--usr.bin/mandoc/main.c12
-rw-r--r--usr.bin/mandoc/man.h3
-rw-r--r--usr.bin/mandoc/man_term.c11
-rw-r--r--usr.bin/mandoc/man_validate.c12
-rw-r--r--usr.bin/mandoc/mandoc.116
-rw-r--r--usr.bin/mandoc/mandoc.h5
-rw-r--r--usr.bin/mandoc/mdoc_validate.c24
-rw-r--r--usr.bin/mandoc/read.c7
21 files changed, 91 insertions, 51 deletions
diff --git a/regress/usr.bin/mandoc/man/TH/Makefile b/regress/usr.bin/mandoc/man/TH/Makefile
index c5c7219d3af..c6972dfddb3 100644
--- a/regress/usr.bin/mandoc/man/TH/Makefile
+++ b/regress/usr.bin/mandoc/man/TH/Makefile
@@ -1,8 +1,9 @@
-# $OpenBSD: Makefile,v 1.4 2014/06/20 18:32:51 schwarze Exp $
+# $OpenBSD: Makefile,v 1.5 2014/06/20 22:58:41 schwarze Exp $
REGRESS_TARGETS = noarg onearg twoargs sixargs case
REGRESS_TARGETS += emptydate onlyyear isodate mdocdate baddate
+REGRESS_TARGETS += nobody
-LINT_TARGETS = noTH case twoargs emptydate baddate
+LINT_TARGETS = noTH case twoargs emptydate baddate nobody
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/man/TH/emptydate.out_lint b/regress/usr.bin/mandoc/man/TH/emptydate.out_lint
index 864faa64e9f..1d656a980b1 100644
--- a/regress/usr.bin/mandoc/man/TH/emptydate.out_lint
+++ b/regress/usr.bin/mandoc/man/TH/emptydate.out_lint
@@ -1 +1 @@
-emptydate.in:1:20: WARNING: date missing, using today's date
+mandoc: emptydate.in:1:20: WARNING: date missing, using today's date
diff --git a/regress/usr.bin/mandoc/man/TH/noTH.out_lint b/regress/usr.bin/mandoc/man/TH/noTH.out_lint
index d0d2efe10bf..f618330d217 100644
--- a/regress/usr.bin/mandoc/man/TH/noTH.out_lint
+++ b/regress/usr.bin/mandoc/man/TH/noTH.out_lint
@@ -1,2 +1,2 @@
-noTH.in:0:1: WARNING: no TH macro in document
-noTH.in:0:1: WARNING: date missing, using today's date
+mandoc: noTH.in: WARNING: no TH macro in document
+mandoc: noTH.in: WARNING: date missing, using today's date
diff --git a/regress/usr.bin/mandoc/man/TH/nobody.in b/regress/usr.bin/mandoc/man/TH/nobody.in
new file mode 100644
index 00000000000..ab1a47b34ec
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/TH/nobody.in
@@ -0,0 +1 @@
+.TH TH-NOBODY 1 "June 20, 2014" OpenBSD
diff --git a/regress/usr.bin/mandoc/man/TH/nobody.out_ascii b/regress/usr.bin/mandoc/man/TH/nobody.out_ascii
new file mode 100644
index 00000000000..7b927ae63bd
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/TH/nobody.out_ascii
@@ -0,0 +1,5 @@
+TH-NOBODY(1) OpenBSD Reference Manual TH-NOBODY(1)
+
+
+
+OpenBSD June 20, 2014 TH-NOBODY(1)
diff --git a/regress/usr.bin/mandoc/man/TH/nobody.out_lint b/regress/usr.bin/mandoc/man/TH/nobody.out_lint
new file mode 100644
index 00000000000..3082b9bdc67
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/TH/nobody.out_lint
@@ -0,0 +1 @@
+mandoc: nobody.in: ERROR: no document body
diff --git a/regress/usr.bin/mandoc/man/TH/twoargs.out_lint b/regress/usr.bin/mandoc/man/TH/twoargs.out_lint
index dd3f8712374..b849d8b8d53 100644
--- a/regress/usr.bin/mandoc/man/TH/twoargs.out_lint
+++ b/regress/usr.bin/mandoc/man/TH/twoargs.out_lint
@@ -1,2 +1,2 @@
-twoargs.in:1:2: ERROR: argument count wrong: line arguments >= 2 (have 1)
-twoargs.in:1:2: WARNING: date missing, using today's date
+mandoc: twoargs.in:1:2: ERROR: argument count wrong: line arguments >= 2 (have 1)
+mandoc: twoargs.in:1:2: WARNING: date missing, using today's date
diff --git a/regress/usr.bin/mandoc/mdoc/Dt/Makefile b/regress/usr.bin/mandoc/mdoc/Dt/Makefile
index 5bdcef4d304..fb7c3110190 100644
--- a/regress/usr.bin/mandoc/mdoc/Dt/Makefile
+++ b/regress/usr.bin/mandoc/mdoc/Dt/Makefile
@@ -1,8 +1,11 @@
-# $OpenBSD: Makefile,v 1.1 2014/06/20 18:32:51 schwarze Exp $
+# $OpenBSD: Makefile,v 1.2 2014/06/20 22:58:41 schwarze Exp $
-REGRESS_TARGETS = case badsec badarch nodate baddate noos order dupe lateos
-LINT_TARGETS = case badsec badarch nodate baddate noos order dupe lateos
-SKIP_GROFF = badsec badarch nodate baddate noos
-SKIP_ASCII = badsec badarch nodate baddate noos
+REGRESS_TARGETS = case badsec badarch nodate baddate
+REGRESS_TARGETS += noos order dupe nobody lateos befSh
+LINT_TARGETS = case badsec badarch nodate baddate
+LINT_TARGETS += noos order dupe nobody lateos befSh
+
+SKIP_GROFF = badsec badarch nodate baddate noos nobody befSh
+SKIP_ASCII = badsec badarch nodate baddate noos befSh
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/mdoc/Dt/befSh.in b/regress/usr.bin/mandoc/mdoc/Dt/befSh.in
new file mode 100644
index 00000000000..ef9f585bd2f
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Dt/befSh.in
@@ -0,0 +1,9 @@
+.Dd June 20, 2014
+.Dt DT-BEFSH 1
+.Os OpenBSD
+.Ox
+.Sh NAME
+.Nm Dt-befSh
+.Nd content before the first section header
+.Sh DESCRIPTION
+some text
diff --git a/regress/usr.bin/mandoc/mdoc/Dt/befSh.out_lint b/regress/usr.bin/mandoc/mdoc/Dt/befSh.out_lint
new file mode 100644
index 00000000000..baed9c38f10
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Dt/befSh.out_lint
@@ -0,0 +1 @@
+mandoc: befSh.in:4:4: WARNING: content before the first section header
diff --git a/regress/usr.bin/mandoc/mdoc/Dt/nobody.in b/regress/usr.bin/mandoc/mdoc/Dt/nobody.in
new file mode 100644
index 00000000000..cc184f9c15a
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Dt/nobody.in
@@ -0,0 +1,3 @@
+.Dd June 20, 2014
+.Dt DT-NOBODY 1
+.Os OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Dt/nobody.out_ascii b/regress/usr.bin/mandoc/mdoc/Dt/nobody.out_ascii
new file mode 100644
index 00000000000..61425787677
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Dt/nobody.out_ascii
@@ -0,0 +1,3 @@
+DT-NOBODY(1) OpenBSD Reference Manual DT-NOBODY(1)
+
+OpenBSD June 20, 2014 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Dt/nobody.out_lint b/regress/usr.bin/mandoc/mdoc/Dt/nobody.out_lint
new file mode 100644
index 00000000000..f5439fcdc56
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Dt/nobody.out_lint
@@ -0,0 +1 @@
+mandoc: nobody.in: WARNING: no document body
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index b0b35319bed..e754060cb60 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.91 2014/06/20 16:11:03 schwarze Exp $ */
+/* $Id: main.c,v 1.92 2014/06/20 22:58:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -409,9 +409,13 @@ mmsg(enum mandocerr t, enum mandoclevel lvl,
const char *file, int line, int col, const char *msg)
{
- fprintf(stderr, "%s: %s:%d:%d: %s: %s", progname,
- file, line, col + 1,
- mparse_strlevel(lvl), mparse_strerror(t));
+ fprintf(stderr, "%s: %s:", progname, file);
+
+ if (line)
+ fprintf(stderr, "%d:%d:", line, col + 1);
+
+ fprintf(stderr, " %s: %s", mparse_strlevel(lvl),
+ mparse_strerror(t));
if (msg)
fprintf(stderr, ": %s", msg);
diff --git a/usr.bin/mandoc/man.h b/usr.bin/mandoc/man.h
index e1c12bbfbb0..e21d4cfced8 100644
--- a/usr.bin/mandoc/man.h
+++ b/usr.bin/mandoc/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.43 2014/03/30 19:47:32 schwarze Exp $ */
+/* $Id: man.h,v 1.44 2014/06/20 22:58:41 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -79,6 +79,7 @@ struct man_meta {
char *vol; /* `TH' volume */
char *title; /* `TH' title (e.g., FOO) */
char *source; /* `TH' source (e.g., GNU) */
+ int hasbody; /* document is not empty */
};
struct man_node {
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 667240679c8..31b18e98e20 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.102 2014/04/23 16:07:06 schwarze Exp $ */
+/* $Id: man_term.c,v 1.103 2014/06/20 22:58:41 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1057,7 +1057,8 @@ print_man_foot(struct termp *p, const void *arg)
term_fontrepl(p, TERMFONT_NONE);
- term_vspace(p);
+ if (meta->hasbody)
+ term_vspace(p);
/*
* Temporary, undocumented option to imitate mdoc(7) output.
@@ -1066,8 +1067,10 @@ print_man_foot(struct termp *p, const void *arg)
*/
if ( ! p->mdocstyle) {
- term_vspace(p);
- term_vspace(p);
+ if (meta->hasbody) {
+ term_vspace(p);
+ term_vspace(p);
+ }
mandoc_asprintf(&title, "%s(%s)",
meta->title, meta->msec);
} else if (meta->source) {
diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c
index bdecddf20c2..81f67e1ecdd 100644
--- a/usr.bin/mandoc/man_validate.c
+++ b/usr.bin/mandoc/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.64 2014/06/20 17:23:09 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.65 2014/06/20 22:58:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -194,10 +194,12 @@ check_root(CHKARGS)
man->flags &= ~MAN_BLINE;
man->flags &= ~MAN_ELINE;
- if (NULL == man->first->child) {
- man_nmsg(man, n, MANDOCERR_NODOCBODY);
- return(0);
- } else if (NULL == man->meta.title) {
+ if (NULL == man->first->child)
+ man_nmsg(man, n, MANDOCERR_DOC_EMPTY);
+ else
+ man->meta.hasbody = 1;
+
+ if (NULL == man->meta.title) {
man_nmsg(man, n, MANDOCERR_TH_MISSING);
/*
diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1
index bf9081d90ae..d0ac31d1831 100644
--- a/usr.bin/mandoc/mandoc.1
+++ b/usr.bin/mandoc/mandoc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mandoc.1,v 1.56 2013/07/13 19:27:46 schwarze Exp $
+.\" $OpenBSD: mandoc.1,v 1.57 2014/06/20 22:58:41 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: July 13 2013 $
+.Dd $Mdocdate: June 20 2014 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -497,9 +497,7 @@ parser:
.Sh DIAGNOSTICS
Standard error messages reporting parsing errors are prefixed by
.Pp
-.Sm off
-.D1 Ar file : line : column : \ level :
-.Sm on
+.D1 Nm Ns : Ar file : Ns Ar line : Ns Ar column : level :
.Pp
where the fields have the following meanings:
.Bl -tag -width "column"
@@ -517,6 +515,12 @@ points to the first character of the word.
The message level, printed in capital letters.
.El
.Pp
+The
+.Ar line
+and
+.Ar column
+fields are omitted when meaningless.
+.Pp
Message levels have the following meanings:
.Bl -tag -width "warning"
.It Cm fatal
@@ -556,7 +560,7 @@ The
utility may also print messages related to invalid command line arguments
or operating system errors, for example when memory is exhausted or
input files cannot be read.
-Such messages do not carry the prefix described above.
+Such messages may not carry the prefix described above.
.Sh COMPATIBILITY
This section summarises
.Nm
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index ea95bcaef11..ac1669dd460 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.65 2014/06/20 17:23:09 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.66 2014/06/20 22:58:41 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -62,6 +62,8 @@ enum mandocerr {
/* related to document structure */
MANDOCERR_SO, /* .so is fragile, better use ln(1) */
+ MANDOCERR_DOC_EMPTY, /* no document body */
+ MANDOCERR_SEC_BEFORE, /* content before the first section header */
MANDOCERR_NAMESECFIRST, /* NAME section must come first */
MANDOCERR_BADNAMESEC, /* bad NAME section contents */
MANDOCERR_SECOOO, /* sections out of conventional order */
@@ -161,7 +163,6 @@ enum mandocerr {
MANDOCERR_SYNTCHILD, /* child violates parent syntax */
MANDOCERR_SYNTARGCOUNT, /* argument count wrong, violates syntax */
MANDOCERR_SOPATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */
- MANDOCERR_NODOCBODY, /* no document body */
MANDOCERR_NODOCPROLOG, /* no document prologue */
MANDOCERR_MEM, /* static buffer exhausted */
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index c1c93857686..d704b3a57fe 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.133 2014/06/20 17:23:09 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.134 2014/06/20 22:58:41 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1641,15 +1641,15 @@ ebool(struct mdoc *mdoc)
static int
post_root(POST_ARGS)
{
- int erc;
+ int ret;
struct mdoc_node *n;
- erc = 0;
+ ret = 1;
/* Check that we have a finished prologue. */
if ( ! (MDOC_PBODY & mdoc->flags)) {
- erc++;
+ ret = 0;
mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCPROLOG);
}
@@ -1658,17 +1658,13 @@ post_root(POST_ARGS)
/* Check that we begin with a proper `Sh'. */
- if (NULL == n->child) {
- erc++;
- mdoc_nmsg(mdoc, n, MANDOCERR_NODOCBODY);
- } else if (MDOC_BLOCK != n->child->type ||
- MDOC_Sh != n->child->tok) {
- erc++;
- /* Can this be lifted? See rxdebug.1 for example. */
- mdoc_nmsg(mdoc, n, MANDOCERR_NODOCBODY);
- }
+ if (NULL == n->child)
+ mdoc_nmsg(mdoc, n, MANDOCERR_DOC_EMPTY);
+ else if (MDOC_BLOCK != n->child->type ||
+ MDOC_Sh != n->child->tok)
+ mdoc_nmsg(mdoc, n->child, MANDOCERR_SEC_BEFORE);
- return(erc ? 0 : 1);
+ return(ret);
}
static int
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index d0c83377abc..cbb94d663e2 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.27 2014/06/20 17:23:09 schwarze Exp $ */
+/* $Id: read.c,v 1.28 2014/06/20 22:58:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -98,6 +98,8 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
/* related to document structure */
".so is fragile, better use ln(1)",
+ "no document body",
+ "content before the first section header",
"NAME section must come first",
"bad NAME section contents",
"sections out of conventional order",
@@ -196,7 +198,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"child violates parent syntax",
"argument count wrong, violates syntax",
"NOT IMPLEMENTED: .so with absolute path or \"..\"",
- "no document body",
"no document prologue",
"static buffer exhausted",
@@ -674,7 +675,7 @@ mparse_end(struct mparse *curp)
}
if ( ! (curp->mdoc || curp->man || curp->sodest)) {
- mandoc_msg(MANDOCERR_NOTMANUAL, curp, 1, 0, NULL);
+ mandoc_msg(MANDOCERR_NOTMANUAL, curp, 0, 0, NULL);
curp->file_status = MANDOCLEVEL_FATAL;
return;
}