* commands.c: bugfix for reading from FILE pointers; affected quote, print
authorMichael Hampton <io_error@uncensored.citadel.org>
Wed, 1 Jan 2003 08:07:46 +0000 (08:07 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Wed, 1 Jan 2003 08:07:46 +0000 (08:07 +0000)
  and external editor.

citadel/ChangeLog
citadel/commands.c

index 804b20692994270e5df20e3bc5d9458f685bb452..653c06ee41555dfcc883d28018cdc2fed2e39e3c 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 601.100  2003/01/01 08:07:46  error
+ * commands.c: bugfix for reading from FILE pointers; affected quote, print
+   and external editor.
+
  Revision 601.99  2002/12/28 05:33:29  ajc
  * ical_dezonify: set is_utc=1 even if we didn't convert from some arbitrary
    timezone.  Presumably this means the time was already UTC, and we really
@@ -4342,4 +4346,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 3899fc942b8d15138dafcb0f5562c9260390d39b..795a8289f4932d05f3ff541de57677cd224c51a2 100644 (file)
@@ -1300,6 +1300,8 @@ int fmout(
 
        /* Read the entire message body into memory */
        if (fpin) {
+               size_t got = 0;
+
                fseek(fpin, 0, SEEK_END);
                i = ftell(fpin);
                rewind(fpin);
@@ -1310,13 +1312,21 @@ int fmout(
                        logoff(NULL, 3);
                }
 
-               g = fread(buffer, i, 1, fpin);
-               if (g == 1) {
+               while (got < i) {
+                       size_t g;
+
+                       g = fread(buffer + got, 1, i - got, fpin);
+                       got += g;
+                       if (g < i - got) {
+                               /* Interrupted system call, keep going */
+                               if (errno == EINTR)
+                                       continue;
+                               /* At this point we have either EOF or error */
+                               i = got;
+                               break;
+                       }
                        buffer[i] = 0;
                }
-               else {
-                       buffer[0] = 0;
-               }
        } else {
                buffer = text;
        }