shithub: neatroff

Download patch

ref: 119c7108f947a6f1608ac429b0057335fd0e51a9
parent: 065f07f73e8dcd360a6f1e752cfdca0ac645d2e2
author: Ali Gholami Rudi <[email protected]>
date: Sat Mar 21 22:18:10 EDT 2020

roff.h: \n(.% number register for real page number

--- a/ren.c
+++ b/ren.c
@@ -35,7 +35,6 @@
 
 static int bp_first = 1;	/* prior to the first page */
 static int bp_next = NOPAGE;	/* next page number */
-static int bp_count;		/* number of pages so far */
 static int bp_ejected;		/* current ejected page */
 static int bp_final;		/* 1: executing em, 2: the final page, 3: the 2nd final page */
 static int ren_level;		/* the depth of render_rec() calls */
@@ -136,8 +135,8 @@
 	n_h = 0;
 	n_pg = bp_next != NOPAGE ? bp_next : n_pg + 1;
 	bp_next = NOPAGE;
-	bp_count++;
-	out("p%d\n", n_pg);
+	n_PG += 1;
+	out("p%d\n", n_PG);
 	out("V%d\n", 0);
 	if (trap_pos(-1) == 0)
 		trap_exec(trap_reg(-1));
@@ -498,10 +497,10 @@
 static void ren_ejectpage(int br)
 {
 	ren_first();
-	bp_ejected = bp_count;
+	bp_ejected = n_PG;
 	if (br)
 		ren_br();
-	while (bp_count == bp_ejected && !cdiv) {
+	while (n_PG == bp_ejected && !cdiv) {
 		if (detect_traps(n_d, n_p)) {
 			ren_traps(n_d, n_p, 1);
 		} else {
--- a/roff.h
+++ b/roff.h
@@ -492,6 +492,7 @@
 #define n_sb		(*nreg(map("sb")))
 #define n_st		(*nreg(map("st")))
 #define n_pg		(*nreg(map("%")))	/* % */
+#define n_PG		(*nreg(DOTMAP('%')))	/* number of ejected pages */
 #define n_lb		(*nreg(map(".b0")))	/* input line beg */
 #define n_ce		(*nreg(map(".ce")))	/* .ce remaining */
 #define n_f0		(*nreg(map(".f0")))	/* last .f */