summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-06-20 17:23:10 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-06-20 17:23:10 +0000
commit8ab408b8b2772f1c44cf224241dff23de210a312 (patch)
tree1b74e289ff9a8149d900a2c43a768d910cacb06a /usr.bin
parent57ca508fe900b5cb680e47a3250ae79b7a5b29a9 (diff)
Start systematic improvements of error reporting.
So far, this covers all WARNINGs related to the prologue. 1) hierarchical naming of MANDOCERR_* constants 2) mention the macro name in messages where that adds clarity 3) add one missing MANDOCERR_DATE_MISSING msg 4) fix the wording of one message related to the man(7) prologue Started on the plane back from Ottawa.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/man_validate.c13
-rw-r--r--usr.bin/mandoc/mandoc.c6
-rw-r--r--usr.bin/mandoc/mandoc.h22
-rw-r--r--usr.bin/mandoc/mdoc.c8
-rw-r--r--usr.bin/mandoc/mdoc_validate.c20
-rw-r--r--usr.bin/mandoc/read.c4
6 files changed, 40 insertions, 33 deletions
diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c
index ecb33703783..bdecddf20c2 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.63 2014/04/20 16:44:44 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.64 2014/06/20 17:23:09 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -198,7 +198,7 @@ check_root(CHKARGS)
man_nmsg(man, n, MANDOCERR_NODOCBODY);
return(0);
} else if (NULL == man->meta.title) {
- man_nmsg(man, n, MANDOCERR_NOTITLE);
+ man_nmsg(man, n, MANDOCERR_TH_MISSING);
/*
* If a title hasn't been set, do so now (by
@@ -386,6 +386,7 @@ post_IP(CHKARGS)
static int
post_TH(CHKARGS)
{
+ struct man_node *nb;
const char *p;
free(man->meta.title);
@@ -397,6 +398,8 @@ post_TH(CHKARGS)
man->meta.title = man->meta.vol = man->meta.date =
man->meta.msec = man->meta.source = NULL;
+ nb = n;
+
/* ->TITLE<- MSEC DATE SOURCE VOL */
n = n->child;
@@ -405,7 +408,7 @@ post_TH(CHKARGS)
/* Only warn about this once... */
if (isalpha((unsigned char)*p) &&
! isupper((unsigned char)*p)) {
- man_nmsg(man, n, MANDOCERR_UPPERCASE);
+ man_nmsg(man, n, MANDOCERR_TITLE_CASE);
break;
}
}
@@ -431,8 +434,10 @@ post_TH(CHKARGS)
mandoc_strdup(n->string) :
mandoc_normdate(man->parse, n->string,
n->line, n->pos);
- } else
+ } else {
man->meta.date = mandoc_strdup("");
+ man_nmsg(man, n ? n : nb, MANDOCERR_DATE_MISSING);
+ }
/* TITLE MSEC DATE ->SOURCE<- VOL */
diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c
index d6ddc390317..7d187af9133 100644
--- a/usr.bin/mandoc/mandoc.c
+++ b/usr.bin/mandoc/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.48 2014/04/20 16:44:44 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.49 2014/06/20 17:23:09 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -502,14 +502,14 @@ mandoc_normdate(struct mparse *parse, char *in, int ln, int pos)
if (NULL == in || '\0' == *in ||
0 == strcmp(in, "$" "Mdocdate$")) {
- mandoc_msg(MANDOCERR_NODATE, parse, ln, pos, NULL);
+ mandoc_msg(MANDOCERR_DATE_MISSING, parse, ln, pos, NULL);
time(&t);
}
else if (a2time(&t, "%Y-%m-%d", in))
t = 0;
else if (!a2time(&t, "$" "Mdocdate: %b %d %Y $", in) &&
!a2time(&t, "%b %d, %Y", in)) {
- mandoc_msg(MANDOCERR_BADDATE, parse, ln, pos, NULL);
+ mandoc_msg(MANDOCERR_DATE_BAD, parse, ln, pos, NULL);
t = 0;
}
out = t ? time2a(t) : NULL;
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 32907899a7f..ea95bcaef11 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.64 2014/04/20 16:44:44 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.65 2014/06/20 17:23:09 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -49,16 +49,16 @@ enum mandocerr {
MANDOCERR_WARNING, /* ===== start of warnings ===== */
/* related to the prologue */
- MANDOCERR_NOTITLE, /* no title in document */
- MANDOCERR_UPPERCASE, /* document title should be all caps */
- MANDOCERR_BADMSEC, /* unknown manual section */
- MANDOCERR_BADVOLARCH, /* unknown manual volume or arch */
- MANDOCERR_NODATE, /* date missing, using today's date */
- MANDOCERR_BADDATE, /* cannot parse date, using it verbatim */
- MANDOCERR_PROLOGOOO, /* prologue macros out of order */
- MANDOCERR_PROLOGREP, /* duplicate prologue macro */
- MANDOCERR_BADPROLOG, /* macro not allowed in prologue */
- MANDOCERR_BADBODY, /* macro not allowed in body */
+ MANDOCERR_TH_MISSING, /* no TH macro in document */
+ MANDOCERR_TITLE_CASE, /* document title should be all caps */
+ MANDOCERR_MSEC_BAD, /* unknown manual section */
+ MANDOCERR_ARCH_BAD, /* unknown manual volume or arch */
+ MANDOCERR_DATE_MISSING, /* date missing, using today's date */
+ MANDOCERR_DATE_BAD, /* cannot parse date, using it verbatim */
+ MANDOCERR_PROLOG_ORDER, /* prologue macros out of order */
+ MANDOCERR_PROLOG_REP, /* duplicate prologue macro */
+ MANDOCERR_PROLOG_BAD, /* macro not allowed in prologue */
+ MANDOCERR_PROLOG_ONLY, /* macro not allowed in body */
/* related to document structure */
MANDOCERR_SO, /* .so is fragile, better use ln(1) */
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index f0d86ad3398..c59fb662f2f 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.104 2014/04/25 14:10:59 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.105 2014/06/20 17:23:09 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -301,7 +301,8 @@ mdoc_macro(MACRO_PROT_ARGS)
if (MDOC_PROLOGUE & mdoc_macros[tok].flags &&
MDOC_PBODY & mdoc->flags) {
- mdoc_pmsg(mdoc, line, ppos, MANDOCERR_BADBODY);
+ mandoc_vmsg(MANDOCERR_PROLOG_ONLY, mdoc->parse,
+ line, ppos, "%s", mdoc_macronames[tok]);
return(1);
}
@@ -309,7 +310,8 @@ mdoc_macro(MACRO_PROT_ARGS)
if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) &&
! (MDOC_PBODY & mdoc->flags)) {
- mdoc_pmsg(mdoc, line, ppos, MANDOCERR_BADPROLOG);
+ mandoc_vmsg(MANDOCERR_PROLOG_BAD, mdoc->parse,
+ line, ppos, "%s", mdoc_macronames[tok]);
if (NULL == mdoc->meta.msec)
mdoc->meta.msec = mandoc_strdup("1");
if (NULL == mdoc->meta.title)
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 5237a127e54..c1c93857686 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.132 2014/04/23 21:06:33 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.133 2014/06/20 17:23:09 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -931,10 +931,10 @@ pre_dt(PRE_ARGS)
{
if (NULL == mdoc->meta.date || mdoc->meta.os)
- mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGOOO);
+ mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_ORDER);
if (mdoc->meta.title)
- mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGREP);
+ mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_REP);
return(1);
}
@@ -944,10 +944,10 @@ pre_os(PRE_ARGS)
{
if (NULL == mdoc->meta.title || NULL == mdoc->meta.date)
- mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGOOO);
+ mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_ORDER);
if (mdoc->meta.os)
- mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGREP);
+ mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_REP);
return(1);
}
@@ -957,10 +957,10 @@ pre_dd(PRE_ARGS)
{
if (mdoc->meta.title || mdoc->meta.os)
- mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGOOO);
+ mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_ORDER);
if (mdoc->meta.date)
- mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGREP);
+ mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_REP);
return(1);
}
@@ -2180,7 +2180,7 @@ post_dt(POST_ARGS)
* FIXME: don't be lazy: have this make all
* characters be uppercase and just warn once.
*/
- mdoc_nmsg(mdoc, nn, MANDOCERR_UPPERCASE);
+ mdoc_nmsg(mdoc, nn, MANDOCERR_TITLE_CASE);
break;
}
@@ -2224,7 +2224,7 @@ post_dt(POST_ARGS)
mdoc->meta.vol = mandoc_strdup(cp);
mdoc->meta.msec = mandoc_strdup(nn->string);
} else {
- mdoc_nmsg(mdoc, n, MANDOCERR_BADMSEC);
+ mdoc_nmsg(mdoc, n, MANDOCERR_MSEC_BAD);
mdoc->meta.vol = mandoc_strdup(nn->string);
mdoc->meta.msec = mandoc_strdup(nn->string);
}
@@ -2246,7 +2246,7 @@ post_dt(POST_ARGS)
} else {
cp = mdoc_a2arch(nn->string);
if (NULL == cp) {
- mdoc_nmsg(mdoc, nn, MANDOCERR_BADVOLARCH);
+ mdoc_nmsg(mdoc, nn, MANDOCERR_ARCH_BAD);
free(mdoc->meta.vol);
mdoc->meta.vol = mandoc_strdup(nn->string);
} else
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 9562593e680..d0c83377abc 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.26 2014/04/20 22:03:40 schwarze Exp $ */
+/* $Id: read.c,v 1.27 2014/06/20 17:23:09 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -85,7 +85,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"generic warning",
/* related to the prologue */
- "no title in document",
+ "no TH macro in document",
"document title should be all caps",
"unknown manual section",
"unknown manual volume or arch",