more work on word wrap

This commit is contained in:
Andrew Pamment 2018-02-27 22:28:28 +10:00
parent f5b136ae21
commit 962e4cc67f

View File

@ -707,9 +707,6 @@ static char *www_wordwrap(char *content, int cutoff) {
char *ret; char *ret;
int at = 0; int at = 0;
int extra = 0; int extra = 0;
if (ret == NULL) {
return NULL;
}
for (i=0;i<len;i++) { for (i=0;i<len;i++) {
if (content[i] == '\n') { if (content[i] == '\n') {
@ -717,16 +714,20 @@ static char *www_wordwrap(char *content, int cutoff) {
} }
content[at++] = content[i]; content[at++] = content[i];
} }
content[at] = '\0'; content[at] = '\0';
at = 0; at = 0;
len = strlen(content); len = strlen(content);
for (i=0;i<len-1;i++) {
for (i=0;i<len-1;i++) {
if (content[i] == '\r' && content[i+1] != '\r') { if (content[i] == '\r' && content[i+1] != '\r') {
if (content[i+1] == ' ') {
content[at++] = '\r';
} else {
content[at++] = ' '; content[at++] = ' ';
content[at++] = content[i+1]; }
i++;
} else if (content[i] == '\r' && content[i+1] == '\r') { } else if (content[i] == '\r' && content[i+1] == '\r') {
content[at++] = '\r';
content[at++] = '\r'; content[at++] = '\r';
i++; i++;
} else { } else {
@ -735,10 +736,16 @@ static char *www_wordwrap(char *content, int cutoff) {
} }
//content[at++] = content[i]; //content[at++] = content[i];
content[at] = '\0'; content[at] = '\0';
at = 0; at = 0;
len = strlen(content); len = strlen(content);
ret = (char *)malloc(len + 1); ret = (char *)malloc(len + 1);
if (ret == NULL) {
return NULL;
}
for (i=0;i<len;i++) { for (i=0;i<len;i++) {
if (content[i] != '\r') { if (content[i] != '\r') {
ret[at] = content[i]; ret[at] = content[i];