source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Simplify blk_part_exp(), no functional change.
@ 2015-02-01 17:31 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-02-01 17:31 UTC (permalink / raw)
  To: source

Log Message:
-----------
Simplify blk_part_exp(), no functional change.
* Replace calls to rew_sub() with rew_last() - two less out of 18.
* No need to keep track of the body, it's always opened right after
the head and never used for anything in this function.

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.162
retrieving revision 1.163
diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.162 -r1.163
--- mdoc_macro.c
+++ mdoc_macro.c
@@ -1340,7 +1340,6 @@ blk_part_exp(MACRO_PROT_ARGS)
 	int		  la, nl;
 	enum margserr	  ac;
 	struct mdoc_node *head; /* keep track of head */
-	struct mdoc_node *body; /* keep track of body */
 	char		 *p;
 
 	nl = MDOC_NEWLINE & mdoc->flags;
@@ -1352,7 +1351,8 @@ blk_part_exp(MACRO_PROT_ARGS)
 	 */
 
 	mdoc_block_alloc(mdoc, line, ppos, tok, NULL);
-	for (head = body = NULL; ; ) {
+	head = NULL;
+	for (;;) {
 		la = *pos;
 		ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
 		if (ac == ARGS_PUNCT || ac == ARGS_EOLN)
@@ -1362,32 +1362,19 @@ blk_part_exp(MACRO_PROT_ARGS)
 
 		if (head == NULL && ac != ARGS_QWORD &&
 		    mdoc_isdelim(p) == DELIM_OPEN) {
-			assert(NULL == body);
 			dword(mdoc, line, la, p, DELIM_OPEN, 0);
 			continue;
 		}
 
 		if (head == NULL) {
-			assert(body == NULL);
 			head = mdoc_head_alloc(mdoc, line, ppos, tok);
-		}
-
-		/*
-		 * `Eo' gobbles any data into the head, but most other
-		 * macros just immediately close out and begin the body.
-		 */
-
-		if (body == NULL) {
-			assert(head);
-			/* No check whether it's a macro! */
-			if (tok == MDOC_Eo)
+			if (tok == MDOC_Eo)  /* Not parsed. */
 				dword(mdoc, line, la, p, DELIM_MAX, 0);
-			rew_sub(MDOC_HEAD, mdoc, tok, line, ppos);
-			body = mdoc_body_alloc(mdoc, line, ppos, tok);
+			rew_last(mdoc, head);
+			mdoc_body_alloc(mdoc, line, ppos, tok);
 			if (tok == MDOC_Eo)
 				continue;
 		}
-		assert(head != NULL && body != NULL);
 
 		if (macro_or_word(mdoc, tok, line, la, pos, buf, 1))
 			break;
@@ -1395,11 +1382,8 @@ blk_part_exp(MACRO_PROT_ARGS)
 
 	/* Clean-up to leave in a consistent state. */
 
-	if (head == NULL)
-		mdoc_head_alloc(mdoc, line, ppos, tok);
-
-	if (body == NULL) {
-		rew_sub(MDOC_HEAD, mdoc, tok, line, ppos);
+	if (head == NULL) {
+		rew_last(mdoc, mdoc_head_alloc(mdoc, line, ppos, tok));
 		mdoc_body_alloc(mdoc, line, ppos, tok);
 	}
 	if (nl)
--
 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:[~2015-02-01 17:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-01 17:31 mdocml: Simplify blk_part_exp(), no functional change 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).