source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Clean up ERROR messages related to document structure and
@ 2014-07-07 21:36 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-07-07 21:36 UTC (permalink / raw)
  To: source

Log Message:
-----------
Clean up ERROR messages related to document structure and macros:
Hierarchical naming and mention macro names in messages.

Modified Files:
--------------
    mdocml:
        man.c
        man_macro.c
        man_validate.c
        mandoc.h
        mdoc_macro.c
        read.c
        roff.c

Revision Data
-------------
Index: mdoc_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_macro.c,v
retrieving revision 1.136
retrieving revision 1.137
diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.136 -r1.137
--- mdoc_macro.c
+++ 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, e
 			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 *m
 			     ! (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 *m
 				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);
 	}
 
Index: man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -Lman.c -Lman.c -u -p -r1.132 -r1.133
--- man.c
+++ man.c
@@ -542,7 +542,7 @@ man_pmacro(struct man *man, int ln, char
 		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
 		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]);
 
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.140
retrieving revision 1.141
diff -Lmandoc.h -Lmandoc.h -u -p -r1.140 -r1.141
--- mandoc.h
+++ 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 */
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.220
retrieving revision 1.221
diff -Lroff.c -Lroff.c -u -p -r1.220 -r1.221
--- roff.c
+++ 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 p
 {
 
 	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 p
 	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);
 	}
 
Index: read.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -Lread.c -Lread.c -u -p -r1.67 -r1.68
--- read.c
+++ read.c
@@ -180,17 +180,20 @@ static	const char * const	mandocerrs[MAN
 	"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",
Index: man_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_validate.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -Lman_validate.c -Lman_validate.c -u -p -r1.99 -r1.100
--- man_validate.c
+++ 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;
Index: man_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_macro.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -Lman_macro.c -Lman_macro.c -u -p -r1.83 -r1.84
--- man_macro.c
+++ man_macro.c
@@ -110,7 +110,7 @@ man_unscope(struct man *man, const struc
 		    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
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-07 21:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-07 21:36 mdocml: Clean up ERROR messages related to document structure and schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).