shithub: neatroff

Download patch

ref: 0cd7efa2a8aa12782a915c7fcc70da3f7370e9f6
parent: 173ca7a5e90175d12798dbbff8dd0ed75faf3bea
author: Ali Gholami Rudi <[email protected]>
date: Tue Sep 16 05:41:57 EDT 2014

ren: .br should flush the current partial word

This patch handles:
  abc\c
  .br
  def
Reported by Carsten Kunze <[email protected]>.

--- a/ren.c
+++ b/ren.c
@@ -376,9 +376,18 @@
 	ren_fmtpop(fmt);
 }
 
+/* pass the given word buffer to the current line buffer (cfmt) */
+static void ren_fmtword(struct wb *wb)
+{
+	while (fmt_word(cfmt, wb))
+		ren_fmtpop(cfmt);
+	wb_reset(wb);
+}
+
 /* output current line; returns 1 if triggered a trap */
 static int ren_br(void)
 {
+	ren_fmtword(cwb);
 	ren_fmtpopall(cfmt);
 	while (fmt_br(cfmt))
 		ren_fmtpop(cfmt);
@@ -963,9 +972,7 @@
 		/* add cwb (the current word) to cfmt */
 		if (c == ' ' || c == '\n') {
 			if (!wb_part(cwb)) {	/* not after a \c */
-				while (fmt_word(cfmt, cwb))
-					ren_fmtpop(cfmt);
-				wb_reset(cwb);
+				ren_fmtword(cwb);
 				if (c == '\n')
 					while (fmt_newline(cfmt))
 						ren_fmtpop(cfmt);