From 2cb42a96d4350547f9c6f8c19b5cd28e1dcf574f Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Sun, 26 Apr 2015 22:33:23 +0000
Subject: [PATCH] If we chop, make the next newline a hard CR.

---
 src/sbbs3/wordwrap.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/sbbs3/wordwrap.c b/src/sbbs3/wordwrap.c
index ab5e804f68..168d554a83 100644
--- a/src/sbbs3/wordwrap.c
+++ b/src/sbbs3/wordwrap.c
@@ -216,6 +216,7 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
 	int			outbuf_size=0;
 	int			inbuf_len=strlen(inbuf);
 	unsigned	next_len;
+	BOOL		chopped = FALSE;
 
 	outbuf_size=inbuf_len*3+1;
 	if((outbuf=(char*)malloc(outbuf_size))==NULL)
@@ -346,13 +347,16 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
 					icol=prefix_len+1;
 					continue;
 				}
-				else if(isspace((unsigned char)inbuf[i+1])) {	/* Next line starts with whitespace.  This is a "hard" CR. */
+				else if(chopped || isspace((unsigned char)inbuf[i+1])) {	/* Next line starts with whitespace.  This is a "hard" CR. */
 					linebuf[l++]='\r';
 					linebuf[l++]='\n';
 					outbuf_append(&outbuf, &outp, linebuf, l, &outbuf_size);
+					if(prefix)
+						memcpy(linebuf,prefix,prefix_bytes);
 					l=prefix_bytes;
 					ocol=prefix_len+1;
 					icol=prefix_len+1;
+					chopped = FALSE;
 					continue;
 				}
 				else {
@@ -411,6 +415,7 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
 							l--;
 						if(l>0)
 							l--;
+						chopped = TRUE;
 					}
 					t=l+1;									/* Store start position of next line */
 					/* Move to start of whitespace */
-- 
GitLab