Skip to content
Snippets Groups Projects
Commit 2cb42a96 authored by deuce's avatar deuce
Browse files

If we chop, make the next newline a hard CR.

parent 30888015
No related branches found
No related tags found
No related merge requests found
...@@ -216,6 +216,7 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes) ...@@ -216,6 +216,7 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
int outbuf_size=0; int outbuf_size=0;
int inbuf_len=strlen(inbuf); int inbuf_len=strlen(inbuf);
unsigned next_len; unsigned next_len;
BOOL chopped = FALSE;
outbuf_size=inbuf_len*3+1; outbuf_size=inbuf_len*3+1;
if((outbuf=(char*)malloc(outbuf_size))==NULL) if((outbuf=(char*)malloc(outbuf_size))==NULL)
...@@ -346,13 +347,16 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes) ...@@ -346,13 +347,16 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
icol=prefix_len+1; icol=prefix_len+1;
continue; 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++]='\r';
linebuf[l++]='\n'; linebuf[l++]='\n';
outbuf_append(&outbuf, &outp, linebuf, l, &outbuf_size); outbuf_append(&outbuf, &outp, linebuf, l, &outbuf_size);
if(prefix)
memcpy(linebuf,prefix,prefix_bytes);
l=prefix_bytes; l=prefix_bytes;
ocol=prefix_len+1; ocol=prefix_len+1;
icol=prefix_len+1; icol=prefix_len+1;
chopped = FALSE;
continue; continue;
} }
else { else {
...@@ -411,6 +415,7 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes) ...@@ -411,6 +415,7 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
l--; l--;
if(l>0) if(l>0)
l--; l--;
chopped = TRUE;
} }
t=l+1; /* Store start position of next line */ t=l+1; /* Store start position of next line */
/* Move to start of whitespace */ /* Move to start of whitespace */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment