source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Simplify: Do not call rew_dohalt() from make_pending(),  the
Date: Mon, 2 Feb 2015 13:27:02 -0500 (EST)	[thread overview]
Message-ID: <7194760857479752398.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Simplify: Do not call rew_dohalt() from make_pending(), 
the calling macro handler already found the breaking block.
No functional change except tiny variations in error messages.

Modified Files:
--------------
    mdocml:
        mdoc_macro.c

Revision Data
-------------
Index: mdoc_macro.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_macro.c,v
retrieving revision 1.167
retrieving revision 1.168
diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.167 -r1.168
--- mdoc_macro.c
+++ mdoc_macro.c
@@ -54,8 +54,8 @@ static	void		append_delims(struct mdoc *
 static	enum mdoct	lookup(struct mdoc *, enum mdoct,
 				int, int, const char *);
 static	int		macro_or_word(MACRO_PROT_ARGS, int);
-static	int		make_pending(struct mdoc_node *, enum mdoct,
-				struct mdoc *, int, int);
+static	void		make_pending(struct mdoc *, struct mdoc_node *,
+				struct mdoc_node *, int, int);
 static	int		parse_rest(struct mdoc *, enum mdoct,
 				int, int *, char *);
 static	enum mdoct	rew_alt(enum mdoct);
@@ -460,44 +460,40 @@ rew_elem(struct mdoc *mdoc, enum mdoct t
 }
 
 /*
- * We are trying to close a block identified by tok,
+ * We are trying to close the block *breaker,
  * but the child block *broken is still open.
- * Thus, postpone closing the tok block
+ * Thus, postpone closing the *breaker
  * until the rew_pending() call closing *broken.
  */
-static int
-make_pending(struct mdoc_node *broken, enum mdoct tok,
-		struct mdoc *mdoc, int line, int ppos)
+static void
+make_pending(struct mdoc *mdoc, struct mdoc_node *breaker,
+	struct mdoc_node *broken, int line, int ppos)
 {
-	struct mdoc_node *breaker;
+	struct mdoc_node *n;
 
-	/*
-	 * Iterate backwards, searching for the block matching tok,
-	 * that is, the block breaking the *broken block.
-	 */
-	for (breaker = broken->parent; breaker; breaker = breaker->parent) {
+	/* Iterate backwards, searching for the breaker. */
+
+	for (n = broken->parent; ; n = n->parent) {
 
 		/*
 		 * If the *broken block (Z) is already broken and we
 		 * encounter its breaker (B), make the tok block (A)
 		 * pending on that inner breaker (B).
-		 * Graphically, [A breaker=[B! broken=[Z->B B] tok=A] Z]
-		 * becomes breaker=[A broken=[B! [Z->B B] tok=A] Z]
+		 * Graphically, [A n=[B! broken=[Z->B B] tok=A] Z]
+		 * becomes [A broken=[B! [Z->B B] tok=A] Z]
 		 * and finally [A! [B!->A [Z->B B] A] Z].
 		 * In these graphics, "->" indicates the "pending"
 		 * pointer and "!" indicates the MDOC_BREAK flag.
 		 * Each of the cases gets one additional pointer (B->A)
 		 * and one additional flag (A!).
 		 */
-		if (breaker == broken->pending) {
-			broken = breaker;
+		if (n == broken->pending) {
+			broken = n;
 			continue;
 		}
 
-		if (REWIND_THIS != rew_dohalt(tok, MDOC_BLOCK, breaker))
+		if (n != breaker)
 			continue;
-		if (MDOC_BODY == broken->type)
-			broken = broken->parent;
 
 		/*
 		 * Found the breaker.
@@ -536,16 +532,10 @@ make_pending(struct mdoc_node *broken, e
 		if (breaker->body != NULL)
 			breaker->body->flags |= MDOC_BREAK;
 		mandoc_vmsg(MANDOCERR_BLK_NEST, mdoc->parse, line, ppos,
-		    "%s breaks %s", mdoc_macronames[tok],
+		    "%s breaks %s", mdoc_macronames[breaker->tok],
 		    mdoc_macronames[broken->tok]);
-		return(1);
+		return;
 	}
-
-	/*
-	 * Found no matching block for tok.
-	 * Are you trying to close a block that is not open?
-	 */
-	return(0);
 }
 
 static void
@@ -769,7 +759,7 @@ blk_exp_close(MACRO_PROT_ARGS)
 			 * rew_pending() closing out the sub-block.
 			 */
 
-			make_pending(later, tok, mdoc, line, ppos);
+			make_pending(mdoc, n, later, line, ppos);
 
 			/*
 			 * Mark the place where the formatting - but not
@@ -1295,7 +1285,7 @@ blk_part_imp(MACRO_PROT_ARGS)
 		if (n->type == MDOC_BLOCK &&
 		    mdoc_macros[n->tok].flags & MDOC_EXPLICIT &&
 		    ! (n->flags & MDOC_VALID)) {
-			make_pending(n, tok, mdoc, line, ppos);
+			make_pending(mdoc, blk, n, line, ppos);
 			mdoc_endbody_alloc(mdoc, line, ppos,
 			    tok, body, ENDBODY_NOSPACE);
 			return;
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2015-02-02 18:27 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=7194760857479752398.enqueue@fantadrom.bsd.lv \
    --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).