fiddling with word wrap
This commit is contained in:
parent
4aa2c4f6c1
commit
50d2bab142
@ -62,7 +62,7 @@ char *www_blog() {
|
|||||||
strcat(page, buffer);
|
strcat(page, buffer);
|
||||||
len += strlen(buffer);
|
len += strlen(buffer);
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"blog-entry\">");
|
sprintf(buffer, "<div class=\"blog-entry\"><p>");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
max_len += 4096;
|
max_len += 4096;
|
||||||
page = (char *)realloc(page, max_len);
|
page = (char *)realloc(page, max_len);
|
||||||
@ -72,13 +72,22 @@ char *www_blog() {
|
|||||||
|
|
||||||
for (j=0;j<strlen(blog_entries[i]->body);j++) {
|
for (j=0;j<strlen(blog_entries[i]->body);j++) {
|
||||||
if (blog_entries[i]->body[j] == '\r') {
|
if (blog_entries[i]->body[j] == '\r') {
|
||||||
sprintf(buffer, "<br />");
|
if (blog_entries[i]->body[j+1] == '\r') {
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
sprintf(buffer, "</p><p>");
|
||||||
max_len += 4096;
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
page = (char *)realloc(page, max_len);
|
max_len += 4096;
|
||||||
|
page = (char *)realloc(page, max_len);
|
||||||
|
}
|
||||||
|
strcat(page, buffer);
|
||||||
|
len += strlen(buffer);
|
||||||
|
} else {
|
||||||
|
if (len + 1 > max_len - 1) {
|
||||||
|
max_len += 4096;
|
||||||
|
page = (char *)realloc(page, max_len);
|
||||||
|
}
|
||||||
|
page[len++] = ' ';
|
||||||
|
page[len] = '\0';
|
||||||
}
|
}
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
} else {
|
} else {
|
||||||
if (len + 1 > max_len - 1) {
|
if (len + 1 > max_len - 1) {
|
||||||
max_len += 4096;
|
max_len += 4096;
|
||||||
@ -88,7 +97,7 @@ char *www_blog() {
|
|||||||
page[len] = '\0';
|
page[len] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sprintf(buffer, "</div>");
|
sprintf(buffer, "</p></div>");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
max_len += 4096;
|
max_len += 4096;
|
||||||
page = (char *)realloc(page, max_len);
|
page = (char *)realloc(page, max_len);
|
||||||
|
@ -710,6 +710,22 @@ static char *www_wordwrap(char *content, int cutoff) {
|
|||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
at = 0;
|
||||||
|
for (i=0;i<len;i++) {
|
||||||
|
if (content[i] == '\r' && content[i+1] != '\r') {
|
||||||
|
content[at++] = ' ';
|
||||||
|
content[at++] = content[i+1];
|
||||||
|
i++;
|
||||||
|
} else if (content[i] == '\r' && content[i+1] == '\r') {
|
||||||
|
content[at++] = '\r';
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
content[at++] = content[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
content[at] = '\0';
|
||||||
|
at = 0;
|
||||||
|
|
||||||
for (i=0;i<len;i++) {
|
for (i=0;i<len;i++) {
|
||||||
if (content[i] == '\n') {
|
if (content[i] == '\n') {
|
||||||
|
Reference in New Issue
Block a user