]> code.citadel.org Git - citadel.git/commitdiff
* Repaired the formatting of text/plain messages with blank lines.
authorArt Cancro <ajc@citadel.org>
Mon, 31 Mar 2003 04:55:58 +0000 (04:55 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 31 Mar 2003 04:55:58 +0000 (04:55 +0000)
citadel/ChangeLog
citadel/citadel_ipc.c
citadel/imap_search.c
citadel/messages.c

index fc5933a91197164b8f60a0debe1fccd2685952cc..97f1cc888c7cf62c4d990aa94fda7a7330143433 100644 (file)
@@ -1,4 +1,7 @@
  $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
@@ -4603,4 +4606,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 443fae3b40d7921265755bde6204c43eca073680..4f3b7c48326f013ecccfbc724d87b4a441c73a0e 100644 (file)
@@ -572,7 +572,7 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                                        }
                                        remove_token(bbb, 0, '\n');
                                } while ((bbb[0] != 0) && (bbb[0] != '\n'));
-               /*ooga*/                remove_token(bbb, 0, '\n');
+                               remove_token(bbb, 0, '\n');
                        }
 
 
@@ -2775,9 +2775,9 @@ void CtdlIPC_getline(CtdlIPC* ipc, char *buf)
                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;
 }
 
 
index 9fd6b34b9d0d469de99107c65c588bee9136a171..540b08f60ac2bfda81c0a360885b04d6c1394389 100644 (file)
@@ -68,11 +68,11 @@ void imap_do_search_msg(int seq, struct CtdlMessage *msg,
 
        /*** 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
index f809aabc4edbf11bb96de45669cb8fa67ee2b59d..fa754faa6938710ce1263d2574942f68ebf8b472 100644 (file)
@@ -361,6 +361,10 @@ int read_message(CtdlIPC *ipc,
        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);
@@ -593,37 +597,49 @@ int read_message(CtdlIPC *ipc,
                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 */