shithub: neatroff

Download patch

ref: c10361cc297cc032c392dba0f66482f8f53ef03b
parent: 9f993218e3755f088e2b75bde569652999e398b5
author: Ali Gholami Rudi <ali@rudi.ir>
date: Tue Nov 27 14:57:17 EST 2012

implement .in

--- a/ren.c
+++ b/ren.c
@@ -4,6 +4,8 @@
 #include <string.h>
 #include "xroff.h"
 
+#define LL	(n_l - n_i)	/* effective line length */
+
 struct word {
 	int beg;	/* word beginning offset in buf */
 	int end;	/* word ending offset in buf */
@@ -55,7 +57,7 @@
 	int adj_div = 0;
 	int adj_rem = 0;
 	int n;
-	while (last < words + nwords && w + last->wid + last->blanks <= n_l) {
+	while (last < words + nwords && w + last->wid + last->blanks <= LL) {
 		w += last->wid + last->blanks;
 		last++;
 	}
@@ -63,8 +65,8 @@
 		last--;
 	n = last - words + 1;
 	if (adj && n > 1) {
-		adj_div = (n_l - w) / (n - 1);
-		adj_rem = n_l - w - adj_div * (n - 1);
+		adj_div = (LL - w) / (n - 1);
+		adj_rem = LL - w - adj_div * (n - 1);
 	}
 	for (i = 0; i < n - 1; i++)
 		words[i + 1].blanks += adj_div + (i < adj_rem);
@@ -132,6 +134,13 @@
 		ren_ps(args[1]);
 }
 
+void tr_in(char **args)
+{
+	ren_br(0, 0);
+	if (args[1])
+		n_i = tr_int(args[1], n_i, 'm');
+}
+
 static void ren_ft(char *s)
 {
 	int fn = !*s || !strcmp("P", s) ? n_f0 : dev_font(s);
@@ -202,7 +211,7 @@
 	char out[LNLEN];
 	buf[buflen] = '\0';
 	if (nwords) {
-		adjust(out, wid > n_l ? n_ad : adj);
+		adjust(out, wid > LL ? n_ad : adj);
 		down(n_v);
 		printf("H%d\n", n_o + n_i);
 		output(out);
@@ -226,8 +235,8 @@
 	ren_br(0, 0);
 	while (nextchar(c) > 0) {
 		g = NULL;
-		if (!word && wid > n_l)
-			ren_br(0, wid > n_l ? n_ad : 0);
+		if (!word && wid > LL)
+			ren_br(0, wid > LL ? n_ad : 0);
 		if (c[0] == ' ' || c[0] == '\n') {
 			if (word) {
 				word->end = buflen;
@@ -294,6 +303,6 @@
 		word->wid += g_wid;
 		wid += g_wid;
 	}
-	ren_br(0, wid > n_l ? n_ad : 0);
+	ren_br(0, wid > LL ? n_ad : 0);
 	ren_br(0, 0);
 }
--- a/tr.c
+++ b/tr.c
@@ -128,12 +128,6 @@
 	sbuf_done(&sbuf);
 }
 
-static void tr_in(char **args)
-{
-	if (args[1])
-		n_i = tr_int(args[1], n_i, 'm');
-}
-
 static void tr_na(char **args)
 {
 	n_ad = 0;
--- a/xroff.h
+++ b/xroff.h
@@ -100,13 +100,14 @@
 void ren_page(int pg);
 
 /* troff commands */
+void tr_bp(char **args);
 void tr_br(char **args);
-void tr_sp(char **args);
+void tr_fp(char **args);
+void tr_ft(char **args);
+void tr_in(char **args);
 void tr_nr(char **args);
 void tr_ps(char **args);
-void tr_ft(char **args);
-void tr_fp(char **args);
-void tr_bp(char **args);
+void tr_sp(char **args);
 
 /* helpers */
 void errmsg(char *msg, ...);