shithub: neatroff

Download patch

ref: 3450f42cb5301f69218aa47d3447327c5c3fa123
parent: 38f8ed89d531f3a8bdb50c40de58fa6f14167334
author: Ali Gholami Rudi <ali@rudi.ir>
date: Fri May 3 17:23:14 EDT 2013

cp: nested .ifs with blocks in a .if with no block

--- a/cp.c
+++ b/cp.c
@@ -135,20 +135,17 @@
 	do {
 		c = skip ? cp_raw() : cp_next();
 	} while (c == ' ' || c == '\t');
-	if (c == c_ec && in_top() == '{') {	/* a troff \{ \} block */
-		if (skip) {
-			while (skip && cp_nblk > nblk && c >= 0)
-				c = cp_raw();
-		} else {
+	if (skip) {
+		while (c >= 0 && (c != '\n' || cp_nblk > nblk))
+			c = cp_raw();
+	} else {
+		if (c == c_ec && in_top() == '{') {	/* a troff \{ \} block */
 			cp_sblk[nblk] = 1;
 			cp_raw();
-		}
-	} else {
-		if (!skip)
+		} else {
 			cp_back(c);
+		}
 	}
-	while (skip && c != '\n')	/* skip until the end of the line */
-		c = cp_raw();
 }
 
 void cp_wid(int enable)