source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Fix formatting of empty .Bl -inset item heads.
Date: Thu, 3 Jul 2014 19:24:56 -0400 (EDT)	[thread overview]
Message-ID: <201407032324.s63NOupU029623@krisdoz.my.domain> (raw)

Log Message:
-----------
Fix formatting of empty .Bl -inset item heads.
Downgrade empty item heads from ERROR to WARNING.
Show the list type in the error message.
Choose better variable names for nodes in post_it().

Modified Files:
--------------
    mdocml:
        mandoc.h
        mdoc_term.c
        mdoc_validate.c
        read.c

Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.223
retrieving revision 1.224
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.223 -r1.224
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -1270,27 +1270,24 @@ post_it(POST_ARGS)
 {
 	int		  i, cols;
 	enum mdoc_list	  lt;
-	struct mdoc_node *n, *c;
+	struct mdoc_node *nbl, *nit, *nch;
 	enum mandocerr	  er;
 
-	if (MDOC_BLOCK != mdoc->last->type)
+	nit = mdoc->last;
+	if (MDOC_BLOCK != nit->type)
 		return(1);
 
-	n = mdoc->last->parent->parent;
-	lt = n->norm->Bl.type;
+	nbl = nit->parent->parent;
+	lt = nbl->norm->Bl.type;
 
 	if (LIST__NONE == lt) {
-		mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE);
+		mdoc_nmsg(mdoc, nit, MANDOCERR_LISTTYPE);
 		return(1);
 	}
 
 	switch (lt) {
 	case LIST_tag:
-		if (mdoc->last->head->child)
-			break;
-		/* FIXME: give this a dummy value. */
-		mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS);
-		break;
+		/* FALLTHROUGH */
 	case LIST_hang:
 		/* FALLTHROUGH */
 	case LIST_ohang:
@@ -1298,8 +1295,10 @@ post_it(POST_ARGS)
 	case LIST_inset:
 		/* FALLTHROUGH */
 	case LIST_diag:
-		if (NULL == mdoc->last->head->child)
-			mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS);
+		if (NULL == nit->head->child)
+			mandoc_msg(MANDOCERR_IT_NOHEAD,
+			    mdoc->parse, nit->line, nit->pos,
+			    mdoc_argnames[nbl->args->argv[0].arg]);
 		break;
 	case LIST_bullet:
 		/* FALLTHROUGH */
@@ -1308,23 +1307,23 @@ post_it(POST_ARGS)
 	case LIST_enum:
 		/* FALLTHROUGH */
 	case LIST_hyphen:
-		if (NULL == mdoc->last->body->child)
-			mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY);
+		if (NULL == nit->body->child)
+			mdoc_nmsg(mdoc, nit, MANDOCERR_NOBODY);
 		/* FALLTHROUGH */
 	case LIST_item:
-		if (mdoc->last->head->child)
-			mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGSLOST);
+		if (NULL != nit->head->child)
+			mdoc_nmsg(mdoc, nit, MANDOCERR_ARGSLOST);
 		break;
 	case LIST_column:
-		cols = (int)n->norm->Bl.ncols;
+		cols = (int)nbl->norm->Bl.ncols;
 
-		assert(NULL == mdoc->last->head->child);
+		assert(NULL == nit->head->child);
 
-		if (NULL == mdoc->last->body->child)
-			mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY);
+		if (NULL == nit->body->child)
+			mdoc_nmsg(mdoc, nit, MANDOCERR_NOBODY);
 
-		for (i = 0, c = mdoc->last->child; c; c = c->next)
-			if (MDOC_BODY == c->type)
+		for (i = 0, nch = nit->child; nch; nch = nch->next)
+			if (MDOC_BODY == nch->type)
 				i++;
 
 		if (i < cols)
@@ -1334,8 +1333,7 @@ post_it(POST_ARGS)
 		else
 			er = MANDOCERR_SYNTARGCOUNT;
 
-		mandoc_vmsg(er, mdoc->parse,
-		    mdoc->last->line, mdoc->last->pos,
+		mandoc_vmsg(er, mdoc->parse, nit->line, nit->pos,
 		    "columns == %d (have %d)", cols, i);
 		return(MANDOCERR_ARGCOUNT == er);
 	default:
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.269
retrieving revision 1.270
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.269 -r1.270
--- mdoc_term.c
+++ mdoc_term.c
@@ -747,7 +747,7 @@ termp_it_pre(DECL_ARGS)
 			term_word(p, "\\ \\ ");
 		break;
 	case LIST_inset:
-		if (MDOC_BODY == n->type)
+		if (MDOC_BODY == n->type && n->parent->head->nchild)
 			term_word(p, "\\ ");
 		break;
 	default:
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.131
retrieving revision 1.132
diff -Lmandoc.h -Lmandoc.h -u -p -r1.131 -r1.132
--- mandoc.h
+++ mandoc.h
@@ -91,6 +91,7 @@ enum	mandocerr {
 	MANDOCERR_DISPTYPE, /* missing display type */
 	MANDOCERR_LISTFIRST, /* list type must come first */
 	MANDOCERR_NOWIDTHARG, /* tag lists require a width argument */
+	MANDOCERR_IT_NOHEAD, /* missing head in list item: type */
 	MANDOCERR_FONTTYPE, /* missing font type */
 
 	/* related to bad macro arguments */
@@ -146,7 +147,6 @@ enum	mandocerr {
 	MANDOCERR_SCOPEEXIT, /* scope open on exit */
 	MANDOCERR_UNAME, /* uname(3) system call failed */
 	/* FIXME: merge following with MANDOCERR_ARGCOUNT */
-	MANDOCERR_NOARGS, /* macro requires line argument(s) */
 	MANDOCERR_NOBODY, /* macro requires body argument(s) */
 	MANDOCERR_NOARGV, /* macro requires argument(s) */
 	MANDOCERR_NUMERIC, /* request requires a numeric argument */
Index: read.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -Lread.c -Lread.c -u -p -r1.58 -r1.59
--- read.c
+++ read.c
@@ -135,6 +135,7 @@ static	const char * const	mandocerrs[MAN
 	"missing display type",
 	"list type must come first",
 	"tag lists require a width argument",
+	"missing head in list item",
 	"missing font type",
 
 	/* related to bad macro arguments */
@@ -189,7 +190,6 @@ static	const char * const	mandocerrs[MAN
 	"missing end of block",
 	"scope open on exit",
 	"uname(3) system call failed",
-	"macro requires line argument(s)",
 	"macro requires body argument(s)",
 	"macro requires argument(s)",
 	"request requires a numeric argument",
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-07-03 23:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201407032324.s63NOupU029623@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).