summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-06-20 17:24:00 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-06-20 17:24:00 +0000
commitf55f857f8f078275f8f6d914367c3075c9e25022 (patch)
tree32eae989a5989bbd16b4929027c3c2df76fd428c
parent6b6c88dfdce932cd2de0f3b003a8bf31558b0fbe (diff)
downloadmandoc-f55f857f8f078275f8f6d914367c3075c9e25022.tar.gz
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.
-rw-r--r--man_validate.c11
-rw-r--r--mandoc.c4
-rw-r--r--mandoc.h20
-rw-r--r--mdoc.c6
-rw-r--r--mdoc_validate.c18
-rw-r--r--read.c2
6 files changed, 34 insertions, 27 deletions
diff --git a/man_validate.c b/man_validate.c
index 03a5f4c5..0088e6f8 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -202,7 +202,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
@@ -390,6 +390,7 @@ post_IP(CHKARGS)
static int
post_TH(CHKARGS)
{
+ struct man_node *nb;
const char *p;
free(man->meta.title);
@@ -401,6 +402,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;
@@ -409,7 +412,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;
}
}
@@ -435,8 +438,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/mandoc.c b/mandoc.c
index 7ddead57..bc001a61 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -509,14 +509,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/mandoc.h b/mandoc.h
index 4fb4492a..27e7bddc 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -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/mdoc.c b/mdoc.c
index 69b74042..6137be57 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -305,7 +305,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);
}
@@ -313,7 +314,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/mdoc_validate.c b/mdoc_validate.c
index a3029926..0078f8cc 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -935,10 +935,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);
}
@@ -948,10 +948,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);
}
@@ -961,10 +961,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);
}
@@ -2184,7 +2184,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;
}
@@ -2228,7 +2228,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);
}
@@ -2250,7 +2250,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/read.c b/read.c
index 67209f8d..482af0db 100644
--- a/read.c
+++ b/read.c
@@ -93,7 +93,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",