From 60f3ca299cfdd742129822cb1c94240fd2b245d8 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 7 Jul 2014 21:36:20 +0000 Subject: Clean up ERROR messages related to document structure and macros: Hierarchical naming and mention macro names in messages. --- man.c | 6 +++--- man_macro.c | 7 ++++--- man_validate.c | 9 ++++----- mandoc.h | 19 +++++++++++-------- mdoc_macro.c | 16 ++++++++++------ read.c | 15 +++++++++------ roff.c | 41 +++++++++++++++++++++++++---------------- 7 files changed, 66 insertions(+), 47 deletions(-) diff --git a/man.c b/man.c index a2c99fe8..ce14a356 100644 --- a/man.c +++ b/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.132 2014/07/07 19:18:15 schwarze Exp $ */ +/* $Id: man.c,v 1.133 2014/07/07 21:36:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze @@ -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 51e91608..bf45641a 100644 --- a/man_macro.c +++ b/man_macro.c @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.83 2014/07/07 19:18:15 schwarze Exp $ */ +/* $Id: man_macro.c,v 1.84 2014/07/07 21:36:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2012, 2013 Ingo Schwarze @@ -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 985a3fb6..bb268c99 100644 --- a/man_validate.c +++ b/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.99 2014/07/06 19:09:00 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.100 2014/07/07 21:36:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -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 80a42b69..daff0b27 100644 --- a/mandoc.h +++ b/mandoc.h @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.140 2014/07/07 16:12:20 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.141 2014/07/07 21:36:20 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -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 2ccb5d8a..f4384ced 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.136 2014/07/04 16:12:08 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.137 2014/07/07 21:36:20 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013 Ingo Schwarze @@ -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 be45fd69..442d6343 100644 --- a/read.c +++ b/read.c @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.67 2014/07/07 16:12:20 schwarze Exp $ */ +/* $Id: read.c,v 1.68 2014/07/07 21:36:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -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 17806545..c257ad41 100644 --- a/roff.c +++ b/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.220 2014/07/07 11:35:06 schwarze Exp $ */ +/* $Id: roff.c,v 1.221 2014/07/07 21:36:20 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -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); } -- cgit v1.2.3-56-ge451