summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-07-07 21:36:20 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-07-07 21:36:20 +0000
commit13cec525e528ff1b9187ac2b1f0965363c8bf94c (patch)
treecdf5c917b4d9043fadc48e169fbd74d047dc9f3d
parent71a6145d9952e8d6805013e811b83ccbbd56b508 (diff)
downloadmandoc-13cec525e528ff1b9187ac2b1f0965363c8bf94c.tar.gz
Clean up ERROR messages related to document structure and macros:
Hierarchical naming and mention macro names in messages.
-rw-r--r--man.c4
-rw-r--r--man_macro.c5
-rw-r--r--man_validate.c7
-rw-r--r--mandoc.h17
-rw-r--r--mdoc_macro.c14
-rw-r--r--read.c13
-rw-r--r--roff.c39
7 files changed, 59 insertions, 40 deletions
diff --git a/man.c b/man.c
index 95e7d38e..7d9e3fca 100644
--- a/man.c
+++ b/man.c
@@ -542,7 +542,7 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
if (MAN_NSCOPED & man_macros[n->tok].flags)
n = n->parent;
- mandoc_vmsg(MANDOCERR_LINESCOPE, man->parse, n->line,
+ mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse, n->line,
n->pos, "%s breaks %s", man_macronames[tok],
man_macronames[n->tok]);
@@ -573,7 +573,7 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
assert(MAN_BLOCK == n->type);
assert(MAN_SCOPED & man_macros[n->tok].flags);
- mandoc_vmsg(MANDOCERR_LINESCOPE, man->parse, n->line,
+ mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse, n->line,
n->pos, "%s breaks %s", man_macronames[tok],
man_macronames[n->tok]);
diff --git a/man_macro.c b/man_macro.c
index 5a027e65..4e4af5ce 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -110,7 +110,7 @@ man_unscope(struct man *man, const struct man_node *to)
MAN_BLOCK == n->type &&
0 == (MAN_VALID & n->flags) &&
MAN_EXPLICIT & man_macros[n->tok].flags)
- mandoc_msg(MANDOCERR_SCOPEEXIT,
+ mandoc_msg(MANDOCERR_BLK_NOEND,
man->parse, n->line, n->pos,
man_macronames[n->tok]);
/*
@@ -270,7 +270,8 @@ blk_close(MACRO_PROT_ARGS)
break;
if (NULL == nn) {
- man_pmsg(man, line, ppos, MANDOCERR_NOSCOPE);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN, man->parse,
+ line, ppos, man_macronames[tok]);
if ( ! rew_scope(MAN_BLOCK, man, MAN_PP))
return(0);
} else
diff --git a/man_validate.c b/man_validate.c
index cd776387..3d143b9b 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -190,10 +190,9 @@ static int
check_root(CHKARGS)
{
- if (MAN_BLINE & man->flags)
- man_nmsg(man, n, MANDOCERR_SCOPEEXIT);
- else if (MAN_ELINE & man->flags)
- man_nmsg(man, n, MANDOCERR_SCOPEEXIT);
+ if ((MAN_BLINE | MAN_ELINE) & man->flags)
+ mandoc_msg(MANDOCERR_BLK_LINE, man->parse,
+ 0, 0, "at end of file");
man->flags &= ~MAN_BLINE;
man->flags &= ~MAN_ELINE;
diff --git a/mandoc.h b/mandoc.h
index ded6389a..ff77e642 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -75,13 +75,13 @@ enum mandocerr {
MANDOCERR_PAR_SKIP, /* skipping paragraph macro: macro ... */
MANDOCERR_PAR_MOVE, /* moving paragraph macro out of list: macro */
MANDOCERR_NS_SKIP, /* skipping no-space macro */
- MANDOCERR_BLOCK_NEST, /* blocks badly nested: macro ... */
+ MANDOCERR_BLK_NEST, /* blocks badly nested: macro ... */
MANDOCERR_BD_NEST, /* nested displays are not portable: macro ... */
MANDOCERR_BL_MOVE, /* moving content out of list: macro */
MANDOCERR_VT_CHILD, /* .Vt block has child macro: macro */
MANDOCERR_FI_SKIP, /* fill mode already enabled, skipping .fi */
MANDOCERR_NF_SKIP, /* fill mode already disabled, skipping .nf */
- MANDOCERR_LINESCOPE, /* line scope broken: macro breaks macro */
+ MANDOCERR_BLK_LINE, /* line scope broken: macro breaks macro */
/* related to missing arguments */
MANDOCERR_REQ_EMPTY, /* skipping empty request: request */
@@ -136,17 +136,20 @@ enum mandocerr {
MANDOCERR_TBLBLOCK, /* data block still open */
MANDOCERR_TBLEXTRADAT, /* ignoring extra data cells */
+ /* related to document structure and macros */
MANDOCERR_ROFFLOOP, /* input stack limit exceeded, infinite loop? */
MANDOCERR_BADCHAR, /* skipping bad character */
+ MANDOCERR_MACRO, /* skipping unknown macro */
+ MANDOCERR_TA_STRAY, /* skipping column outside column list */
+ MANDOCERR_BLK_NOTOPEN, /* skipping end of block that is not open */
+ MANDOCERR_BLK_BROKEN, /* inserting missing end of block: macro ... */
+ MANDOCERR_BLK_NOEND, /* appending missing end of block: macro */
+
+ /* related to request and macro arguments */
MANDOCERR_NAMESC, /* escaped character not allowed in a name */
MANDOCERR_NONAME, /* manual name not yet set */
- MANDOCERR_MACRO, /* skipping unknown macro */
MANDOCERR_ARGCOUNT, /* argument count wrong */
MANDOCERR_ST_BAD, /* unknown standard specifier: standard */
- MANDOCERR_STRAYTA, /* skipping column outside column list */
- MANDOCERR_NOSCOPE, /* skipping end of block that is not open */
- MANDOCERR_SCOPEBROKEN, /* missing end of block */
- MANDOCERR_SCOPEEXIT, /* scope open on exit */
MANDOCERR_UNAME, /* uname(3) system call failed */
MANDOCERR_NUMERIC, /* request requires a numeric argument */
MANDOCERR_BL_NOTYPE, /* missing list type, using -item */
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 72476679..33dc1e8a 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -234,7 +234,8 @@ mdoc_macroend(struct mdoc *mdoc)
for ( ; n; n = n->parent)
if (MDOC_BLOCK == n->type &&
MDOC_EXPLICIT & mdoc_macros[n->tok].flags)
- mdoc_nmsg(mdoc, n, MANDOCERR_SCOPEEXIT);
+ mandoc_msg(MANDOCERR_BLK_NOEND, mdoc->parse,
+ n->line, n->pos, mdoc_macronames[n->tok]);
/* Rewind to the first. */
@@ -528,7 +529,7 @@ make_pending(struct mdoc_node *broken, enum mdoct tok,
taker->pending = broken->pending;
}
broken->pending = breaker;
- mandoc_vmsg(MANDOCERR_BLOCK_NEST, mdoc->parse, line, ppos,
+ mandoc_vmsg(MANDOCERR_BLK_NEST, mdoc->parse, line, ppos,
"%s breaks %s", mdoc_macronames[tok],
mdoc_macronames[broken->tok]);
return(1);
@@ -558,7 +559,7 @@ rew_sub(enum mdoc_type t, struct mdoc *mdoc,
! (MDOC_EXPLICIT & mdoc_macros[tok].flags));
break;
case REWIND_FORCE:
- mandoc_vmsg(MANDOCERR_SCOPEBROKEN, mdoc->parse,
+ mandoc_vmsg(MANDOCERR_BLK_BROKEN, mdoc->parse,
line, ppos, "%s breaks %s",
mdoc_macronames[tok],
mdoc_macronames[n->tok]);
@@ -574,7 +575,9 @@ rew_sub(enum mdoc_type t, struct mdoc *mdoc,
return(1);
/* FALLTHROUGH */
case REWIND_ERROR:
- mdoc_pmsg(mdoc, line, ppos, MANDOCERR_NOSCOPE);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN,
+ mdoc->parse, line, ppos,
+ mdoc_macronames[tok]);
return(1);
}
break;
@@ -1763,7 +1766,8 @@ phrase_ta(MACRO_PROT_ARGS)
while (NULL != n && MDOC_Bl != n->tok)
n = n->parent;
if (NULL == n || LIST_column != n->norm->Bl.type) {
- mdoc_pmsg(mdoc, line, ppos, MANDOCERR_STRAYTA);
+ mandoc_msg(MANDOCERR_TA_STRAY, mdoc->parse,
+ line, ppos, NULL);
return(1);
}
diff --git a/read.c b/read.c
index 369d3fca..dd25696c 100644
--- a/read.c
+++ b/read.c
@@ -180,17 +180,20 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"data block still open",
"ignoring extra data cells",
+ /* related to document structure and macros */
"input stack limit exceeded, infinite loop?",
"skipping bad character",
+ "skipping unknown macro",
+ "skipping column outside column list",
+ "skipping end of block that is not open",
+ "inserting missing end of block",
+ "appending missing end of block",
+
+ /* related to request and macro arguments */
"escaped character not allowed in a name",
"manual name not yet set",
- "skipping unknown macro",
"argument count wrong",
"unknown standard specifier",
- "skipping column outside column list",
- "skipping end of block that is not open",
- "missing end of block",
- "scope open on exit",
"uname(3) system call failed",
"request requires a numeric argument",
"missing list type, using -item",
diff --git a/roff.c b/roff.c
index 8153b69e..83b30d27 100644
--- a/roff.c
+++ b/roff.c
@@ -786,18 +786,19 @@ roff_endparse(struct roff *r)
{
if (r->last)
- mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
- r->last->line, r->last->col, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOEND, r->parse,
+ r->last->line, r->last->col,
+ roffs[r->last->tok].name);
if (r->eqn) {
- mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
- r->eqn->eqn.ln, r->eqn->eqn.pos, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOEND, r->parse,
+ r->eqn->eqn.ln, r->eqn->eqn.pos, "EQ");
eqn_end(&r->eqn);
}
if (r->tbl) {
- mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
- r->tbl->line, r->tbl->pos, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOEND, r->parse,
+ r->tbl->line, r->tbl->pos, "TS");
tbl_end(&r->tbl);
}
}
@@ -841,7 +842,8 @@ roff_cblock(ROFF_ARGS)
*/
if (NULL == r->last) {
- mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,
+ ln, ppos, "..");
return(ROFF_IGN);
}
@@ -859,7 +861,8 @@ roff_cblock(ROFF_ARGS)
case ROFF_ig:
break;
default:
- mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,
+ ln, ppos, "..");
return(ROFF_IGN);
}
@@ -889,7 +892,8 @@ roff_ccond(struct roff *r, int ln, int ppos)
{
if (NULL == r->last) {
- mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,
+ ln, ppos, "\\}");
return;
}
@@ -901,12 +905,14 @@ roff_ccond(struct roff *r, int ln, int ppos)
case ROFF_if:
break;
default:
- mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,
+ ln, ppos, "\\}");
return;
}
if (r->last->endspan > -1) {
- mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,
+ ln, ppos, "\\}");
return;
}
@@ -1793,7 +1799,8 @@ roff_TE(ROFF_ARGS)
{
if (NULL == r->tbl)
- mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,
+ ln, ppos, "TE");
else
tbl_end(&r->tbl);
@@ -1805,7 +1812,8 @@ roff_T_(ROFF_ARGS)
{
if (NULL == r->tbl)
- mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,
+ ln, ppos, "T&");
else
tbl_restart(ppos, ln, r->tbl);
@@ -1856,7 +1864,7 @@ static enum rofferr
roff_EN(ROFF_ARGS)
{
- mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse, ln, ppos, "EN");
return(ROFF_IGN);
}
@@ -1866,7 +1874,8 @@ roff_TS(ROFF_ARGS)
struct tbl_node *tbl;
if (r->tbl) {
- mandoc_msg(MANDOCERR_SCOPEBROKEN, r->parse, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_BLK_BROKEN, r->parse,
+ ln, ppos, "TS breaks TS");
tbl_end(&r->tbl);
}