Skip to content
Snippets Groups Projects
Commit 1afb16a3 authored by rswindell's avatar rswindell
Browse files

A couple of bug fixes for word_wrap() method when used with pre-wrapped

text.
parent a22f8ed8
No related branches found
No related tags found
No related merge requests found
......@@ -442,8 +442,8 @@ js_lfexpand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool
js_word_wrap(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
int32 len=79;
ulong i,k,l;
int32 l,len=79;
ulong i,k;
int col=1;
uchar* inbuf;
char* outbuf;
......@@ -464,14 +464,17 @@ js_word_wrap(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
outbuf[0]=0;
for(i=l=0;inbuf[i];) {
if(inbuf[i]=='\r' || inbuf[i]==FF)
if(inbuf[i]=='\r' || inbuf[i]==FF) {
strncat(outbuf,linebuf,l);
l=0;
col=1;
}
else if(inbuf[i]=='\t')
col+=8;
else if(inbuf[i]>=' ')
col++;
linebuf[l]=inbuf[i++];
if(col<len) {
if(col<len && l<len) {
l++;
continue;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment