Skip to content
Snippets Groups Projects
Commit 83ea571d authored by deuce's avatar deuce
Browse files

If the quote chars are more than 2/3rds the width, replace all quote chars

with %d> where %d is replaced by the number of quotes total.
parent 877cbcf8
No related branches found
No related tags found
No related merge requests found
...@@ -764,6 +764,15 @@ js_word_wrap(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) ...@@ -764,6 +764,15 @@ js_word_wrap(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
i=0; i=0;
if(handle_quotes && (quote_count=get_prefix(inbuf, &prefix_bytes, &prefix_len))) { if(handle_quotes && (quote_count=get_prefix(inbuf, &prefix_bytes, &prefix_len))) {
i+=prefix_bytes; i+=prefix_bytes;
if(prefix_len>len/3*2) {
/* This prefix is insane (more than 2/3rds of the new width) hack it down to size */
/* Since we're hacking it, we will always end up with a hardcr on this line. */
/* ToDo: Something prettier would be nice. */
sprintf(prefix," %d> ",quote_count);
prefix_len=strlen(prefix);
prefix_bytes=strlen(prefix);
}
else
memcpy(prefix,inbuf,prefix_bytes); memcpy(prefix,inbuf,prefix_bytes);
strncpy(linebuf,prefix,prefix_bytes); strncpy(linebuf,prefix,prefix_bytes);
l=prefix_bytes; l=prefix_bytes;
...@@ -790,6 +799,15 @@ js_word_wrap(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) ...@@ -790,6 +799,15 @@ js_word_wrap(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
} }
/* If there's a new prefix, it is a hardcr */ /* If there's a new prefix, it is a hardcr */
else if(prefix_bytes != old_prefix_bytes || (memcmp(prefix,inbuf+i+1-prefix_bytes,prefix_bytes))) { else if(prefix_bytes != old_prefix_bytes || (memcmp(prefix,inbuf+i+1-prefix_bytes,prefix_bytes))) {
if(prefix_len>len/3*2) {
/* This prefix is insane (more than 2/3rds of the new width) hack it down to size */
/* Since we're hacking it, we will always end up with a hardcr on this line. */
/* ToDo: Something prettier would be nice. */
sprintf(prefix," %d> ",quote_count);
prefix_len=strlen(prefix);
prefix_bytes=strlen(prefix);
}
else
memcpy(prefix,inbuf+i+1-prefix_bytes,prefix_bytes); memcpy(prefix,inbuf+i+1-prefix_bytes,prefix_bytes);
linebuf[l++]='\r'; linebuf[l++]='\r';
linebuf[l++]='\n'; linebuf[l++]='\n';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment