source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Refactor the handler function roff_block_sub() for clarity and
@ 2022-04-30 11:33 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2022-04-30 11:33 UTC (permalink / raw)
  To: source

Log Message:
-----------
Refactor the handler function roff_block_sub() for clarity and simplicity.

1. Do not needlessly access the function pointer table roffs[].
Instead, simply call the block closing function directly.

2. Sort code: handle both cases of block closing at the beginning 
of the function rather than one at the beginning and one at the end.

3. Trim excessive, partially repetitive and obvious comments, also 
making the comments considerably more precise.

No functional change.

Modified Files:
--------------
    mandoc:
        roff.c

Revision Data
-------------
Index: roff.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff.c,v
retrieving revision 1.384
retrieving revision 1.385
diff -Lroff.c -Lroff.c -u -p -r1.384 -r1.385
--- roff.c
+++ roff.c
@@ -2276,12 +2276,8 @@ roff_block_sub(ROFF_ARGS)
 	int		i, j;
 
 	/*
-	 * First check whether a custom macro exists at this level.  If
-	 * it does, then check against it.  This is some of groff's
-	 * stranger behaviours.  If we encountered a custom end-scope
-	 * tag and that tag also happens to be a "real" macro, then we
-	 * need to try interpreting it again as a real macro.  If it's
-	 * not, then return ignore.  Else continue.
+	 * If a custom end marker is a user-defined or predefined macro
+	 * or a request, interpret it.
 	 */
 
 	if (r->last->end) {
@@ -2307,20 +2303,17 @@ roff_block_sub(ROFF_ARGS)
 		}
 	}
 
-	/*
-	 * If we have no custom end-query or lookup failed, then try
-	 * pulling it out of the hashtable.
-	 */
+	/* Handle the standard end marker. */
 
 	t = roff_parse(r, buf->buf, &pos, ln, ppos);
+	if (t == ROFF_cblock)
+		return roff_cblock(r, t, buf, ln, ppos, pos, offs);
 
-	if (t != ROFF_cblock) {
-		if (tok != ROFF_ig)
-			roff_setstr(r, r->last->name, buf->buf + ppos, 2);
-		return ROFF_IGN;
-	}
+	/* Not an end marker, so append the line to the block. */
 
-	return (*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs);
+	if (tok != ROFF_ig)
+		roff_setstr(r, r->last->name, buf->buf + ppos, 2);
+	return ROFF_IGN;
 }
 
 static int
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


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

only message in thread, other threads:[~2022-04-30 11:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-30 11:33 mandoc: Refactor the handler function roff_block_sub() for clarity 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).