shithub: neatroff

Download patch

ref: 156edb7214f62f225bc009bcbd2953f0e99b7d42
parent: 976ae5b920edf2a1332139bd4079ffd20bfb2a44
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed Apr 24 14:45:59 EDT 2013

ren: ignore .sp after a new page

--- a/ren.c
+++ b/ren.c
@@ -102,6 +102,10 @@
 	ren_div--;
 }
 
+static int trap_reg(int pos);
+static int trap_pos(int pos);
+static void trap_exec(int reg);
+
 static void ren_page(int pg)
 {
 	n_nl = 0;
@@ -111,13 +115,15 @@
 	bp_next = n_pg + 1;
 	out("p%d\n", pg);
 	out("V%d\n", 0);
+	if (trap_pos(-1) == 0)
+		trap_exec(trap_reg(-1));
 }
 
 static void ren_first(void)
 {
 	if (bp_first) {
-		ren_page(bp_next);
 		bp_first = 0;
+		ren_page(bp_next);
 	}
 }
 
@@ -139,9 +145,6 @@
 	}
 }
 
-static int trap_reg(int pos);
-static int trap_pos(int pos);
-
 static void push_ne(void)
 {
 	char buf[32];
@@ -174,10 +177,8 @@
 static int ren_pagelimit(int ne)
 {
 	if (n_nl + ne >= n_p && !cdiv) {
-		ren_page(bp_next);
 		bp_force = 0;
-		if (trap_pos(-1) == 0)
-			trap_exec(trap_reg(-1));
+		ren_page(bp_next);
 		return 1;
 	}
 	return 0;
@@ -238,10 +239,12 @@
 			ren_sp(els_pos);
 		n_a = els_pos;
 		if (!ren_traps(prev_d, n_d, 0)) {
-			if (n_L > n_v && (cdiv || n_d < n_p))
+			if (n_L > n_v && (cdiv || n_d < n_p)) {
 				down(n_L - n_v);
-			else
-				ren_pagelimit(0);
+			} else {
+				if (ren_pagelimit(0))
+					return 1;
+			}
 			return 0;
 		}
 		return 1;