shithub: neatroff

Download patch

ref: f8bbe8ac5392ff8948a3e735b1e3e35422e746e4
parent: b888f1393c1efeff1c752f3412c183dd4aa1c797
author: Ali Gholami Rudi <ali@rudi.ir>
date: Mon Dec 17 14:40:03 EST 2012

xroff: use OUT macro for producing troff output

--- a/dev.c
+++ b/dev.c
@@ -25,9 +25,9 @@
 
 static void dev_prologue(void)
 {
-	printf("x T utf\n");
-	printf("x res %d %d %d\n", dev_res, dev_hor, dev_ver);
-	printf("x init\n");
+	OUT("x T utf\n");
+	OUT("x res %d %d %d\n", dev_res, dev_hor, dev_ver);
+	OUT("x init\n");
 }
 
 int dev_mnt(int pos, char *id, char *name)
@@ -43,7 +43,7 @@
 	if (fn_name[pos] != name)	/* ignore if fn_name[pos] is passed */
 		strcpy(fn_name[pos], id);
 	fn_font[pos] = fn;
-	printf("x font %d %s\n", pos, name);
+	OUT("x font %d %s\n", pos, name);
 	return pos;
 }
 
@@ -104,8 +104,8 @@
 
 static void dev_epilogue(void)
 {
-	printf("x trailer\n");
-	printf("x stop\n");
+	OUT("x trailer\n");
+	OUT("x stop\n");
 }
 
 void dev_close(void)
--- a/out.c
+++ b/out.c
@@ -38,7 +38,7 @@
 {
 	if (o_s != n) {
 		o_s = n;
-		printf("s%d\n", o_s);
+		OUT("s%d\n", o_s);
 	}
 }
 
@@ -46,7 +46,7 @@
 {
 	if (n >= 0 && o_f != n) {
 		o_f = n;
-		printf("f%d\n", o_f);
+		OUT("f%d\n", o_f);
 	}
 }
 
@@ -103,7 +103,7 @@
 					continue;
 				}
 				if (c[0] == 'h') {
-					printf("h%d", tr_int(arg, 0, 'm'));
+					OUT("h%d", tr_int(arg, 0, 'm'));
 					continue;
 				}
 			}
@@ -111,11 +111,11 @@
 		g = dev_glyph(c, o_f);
 		if (g) {
 			if (utf8len(c[0]) == strlen(c)) {
-				printf("c%s%s", c, c[1] ? "\n" : "");
+				OUT("c%s%s", c, c[1] ? "\n" : "");
 			} else {
-				printf("C%s\n", c);
+				OUT("C%s\n", c);
 			}
 		}
-		printf("h%d", charwid(g ? g->wid : dev_spacewid(), o_s));
+		OUT("h%d", charwid(g ? g->wid : dev_spacewid(), o_s));
 	}
 }
--- a/ren.c
+++ b/ren.c
@@ -107,7 +107,7 @@
 	n_d += n;
 	n_nl = n_d;
 	if (n_nl <= n_p)
-		printf("v%d\n", n);
+		OUT("v%d\n", n);
 	ren_ne(0);
 }
 
@@ -122,7 +122,7 @@
 			adjust_nf(out, nwords);
 		ren_ne(n_v);
 		down(n_v);
-		printf("H%d\n", n_o + n_i);
+		OUT("H%d\n", n_o + n_i);
 		output(out);
 		ren_ne(n_v);
 	}
@@ -148,8 +148,8 @@
 	n_nl = -1;
 	n_d = 0;
 	n_pg = pg;
-	printf("p%d\n", pg);
-	printf("V%d\n", 0);
+	OUT("p%d\n", pg);
+	OUT("V%d\n", 0);
 }
 
 void tr_bp(char **args)
--- a/xroff.c
+++ b/xroff.c
@@ -26,11 +26,11 @@
 
 static void compile(void)
 {
-	printf("s%d\n", n_s);
-	printf("f%d\n", n_f);
+	OUT("s%d\n", n_s);
+	OUT("f%d\n", n_f);
 	ren_page(1);
 	render();
-	printf("V%d\n", n_p);
+	OUT("V%d\n", n_p);
 }
 
 void errmsg(char *fmt, ...)
--- a/xroff.h
+++ b/xroff.h
@@ -76,6 +76,9 @@
 	int n;				/* number of characters in charset */
 };
 
+/* troff output function */
+#define OUT	printf
+
 /* output device functions */
 int dev_open(char *path);
 void dev_close(void);