insert ANSI-mandated bogosity
authorChris Torek <torek@ucbvax.Berkeley.EDU>
Sun, 12 Dec 1993 11:11:03 +0000 (03:11 -0800)
committerChris Torek <torek@ucbvax.Berkeley.EDU>
Sun, 12 Dec 1993 11:11:03 +0000 (03:11 -0800)
SCCS-vsn: lib/libc/stdio/fread.c 8.2

usr/src/lib/libc/stdio/fread.c

index 9eff575..255551c 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fread.c    8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)fread.c    8.2 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <stdio.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <stdio.h>
@@ -26,8 +26,13 @@ fread(buf, size, count, fp)
        register int r;
        size_t total;
 
        register int r;
        size_t total;
 
+       /*
+        * The ANSI standard requires a return value of 0 for a count
+        * or a size of 0.  Peculiarily, it imposes no such requirements
+        * on fwrite; it only requires fread to be broken.
+        */
        if ((resid = count * size) == 0)
        if ((resid = count * size) == 0)
-               return (count);
+               return (0);
        if (fp->_r < 0)
                fp->_r = 0;
        total = resid;
        if (fp->_r < 0)
                fp->_r = 0;
        total = resid;