From 95b98c543ee2d92ea5b546261c4f65e713e0973e Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Thu, 20 Jul 2006 17:52:07 +0000
Subject: [PATCH] Perform 80-column line wrap *after* a character is put in the
 output buffer rather than before.

This should fix wrapping issues where the 81st column of a line contained
a CTRL-A right-movement code.
---
 src/sbbs3/js_global.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/sbbs3/js_global.c b/src/sbbs3/js_global.c
index 0727071879..d3ffca1e90 100644
--- a/src/sbbs3/js_global.c
+++ b/src/sbbs3/js_global.c
@@ -1909,6 +1909,13 @@ js_html_encode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
 							lastcolor=(blink?(1<<7):0) | (bg << 4) | (bold?(1<<3):0) | fg;
 							j+=sprintf(outbuf+j,"%s%s%s",HTML_COLOR_PREFIX,htmlansi[lastcolor],HTML_COLOR_SUFFIX);
 						}
+						outbuf[j++]=tmpbuf[i];
+						if(tmpbuf[i]=='&')
+							extchar=TRUE;
+						if(tmpbuf[i]==';')
+							extchar=FALSE;
+						if(!extchar)
+							hpos++;
 						/* ToDo: Fix hard-coded terminal window width (80) */
 						if(hpos>=80 && tmpbuf[i+1] != '\r' && tmpbuf[i+1] != '\n' && tmpbuf[i+1] != ESC)
 						{
@@ -1920,13 +1927,6 @@ js_html_encode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
 							outbuf[j++]='\r';
 							outbuf[j++]='\n';
 						}
-						outbuf[j++]=tmpbuf[i];
-						if(tmpbuf[i]=='&')
-							extchar=TRUE;
-						if(tmpbuf[i]==';')
-							extchar=FALSE;
-						if(!extchar)
-							hpos++;
 				}
 			}
 		}
-- 
GitLab