$Log$
+ Revision 605.30 2003/03/31 04:55:58 ajc
+ * Repaired the formatting of text/plain messages with blank lines.
+
Revision 605.29 2003/03/30 06:16:52 ajc
* Optimized CtdlReadMessageBody() and also gave it an option to store
messages with CRLF newlines instead of LF. This option is used when
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
}
remove_token(bbb, 0, '\n');
} while ((bbb[0] != 0) && (bbb[0] != '\n'));
- /*ooga*/ remove_token(bbb, 0, '\n');
+ remove_token(bbb, 0, '\n');
}
while (buf[i] != '\n')
serv_read(ipc, &buf[i], 1);
- /* Strip the trailing newline.
- */
- buf[i] = 0;
+ /* Strip the trailing newline (and carriage return, if present) */
+ if (buf[i] == 10) buf[i--] = 0;
+ if (buf[i] == 13) buf[i--] = 0;
}
/*** FIXME ***
* We haven't written the search command logic yet. Instead we
- * simply return every message as valid. This will probably surprise
+ * simply return nothing. This will probably surprise
* some users. Could someone out there please be the hero of the
* century and write this function?
*/
- is_valid = 1;
+ is_valid = 0;
/*
* If the message meets the specified search criteria, output its
struct ctdlipcmessage *message = NULL;
int r; /* IPC response code */
char *converted_text = NULL;
+ char *lineptr;
+ char *nextline;
+ int linelen;
+ int final_line_is_blank = 0;
sigcaught = 0;
sttybbs(1);
fr = fmout(screenwidth, NULL, message->text, dest,
((pagin == 1) ? 1 : 0), screenheight, (-1), 1);
} else {
- /* FIXME: renderer for text/plain */
- char *msgtext;
- char *lineptr;
+ /* renderer for text/plain */
- msgtext = message->text;
+ lineptr = message->text;
- while (lineptr = strtok(msgtext, "\n"), lineptr != NULL) {
- msgtext = NULL;
+ do {
+ nextline = strchr(lineptr, '\n');
+ if (nextline != NULL) {
+ *nextline = 0;
+ ++nextline;
+ if (*nextline == 0) nextline = NULL;
+ }
if (sigcaught == 0) {
+ linelen = strlen(lineptr);
+ if (lineptr[linelen-1] == '\r') {
+ lineptr[--linelen] = 0;
+ }
if (dest) {
fprintf(dest, "%s\n", lineptr);
} else {
scr_printf("%s\n", lineptr);
lines_printed = lines_printed + 1 +
- (strlen(lineptr) / screenwidth);
+ (linelen / screenwidth);
lines_printed =
checkpagin(lines_printed, pagin,
screenheight);
}
}
- }
+ if (lineptr[0] == 0) final_line_is_blank = 1;
+ else final_line_is_blank = 0;
+ lineptr = nextline;
+ } while (nextline);
fr = sigcaught;
}
- if (dest) {
- fprintf(dest, "\n");
- } else {
- scr_printf("\n");
- /* scr_flush(); */
- ++lines_printed;
- lines_printed = checkpagin(lines_printed, pagin, screenheight);
+ if (!final_line_is_blank) {
+ if (dest) {
+ fprintf(dest, "\n");
+ }
+ else {
+ scr_printf("\n");
+ ++lines_printed;
+ lines_printed = checkpagin(lines_printed, pagin, screenheight);
+ }
}
/* Enumerate any attachments */