Loading...
--- Libc/Libc-1725.40.4/stdio/FreeBSD/fvwrite.c
+++ Libc/Libc-583/stdio/FreeBSD/fvwrite.c
@@ -13,6 +13,10 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
@@ -34,9 +38,8 @@
static char sccsid[] = "@(#)fvwrite.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdio/fvwrite.c,v 1.19 2009/11/25 04:21:42 wollman Exp $");
-
-#include <limits.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdio/fvwrite.c,v 1.17 2004/06/08 05:45:48 das Exp $");
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -50,7 +53,9 @@
* to the three different kinds of output buffering is handled here.
*/
int
-__sfvwrite(FILE *fp, struct __suio *uio)
+__sfvwrite(fp, uio)
+ FILE *fp;
+ struct __suio *uio;
{
size_t len;
char *p;
@@ -59,7 +64,7 @@
char *nl;
int nlknown, nldist;
- if (uio->uio_resid == 0)
+ if ((len = uio->uio_resid) == 0)
return (0);
/* make sure we can write */
if (prepwrite(fp) != 0)
@@ -81,12 +86,11 @@
}
if (fp->_flags & __SNBF) {
/*
- * Unbuffered: write up to INT_MAX bytes at a time, to not truncate
- * the value of len if it is greater than 2^31 bytes.
+ * Unbuffered: write up to BUFSIZ bytes at a time.
*/
do {
GETIOV(;);
- w = _swrite(fp, p, MIN(len, INT_MAX));
+ w = _swrite(fp, p, MIN(len, BUFSIZ));
if (w <= 0)
goto err;
p += w;
@@ -96,8 +100,7 @@
/*
* Fully buffered: fill partially full buffer, if any,
* and then flush. If there is no partial buffer, write
- * entire payload directly (without copying) up to a multiple of
- * the buffer size.
+ * one _bf._size byte chunk directly (without copying).
*
* String output is a special case: write as many bytes
* as fit, but pretend we wrote everything. This makes
@@ -141,12 +144,7 @@
if (__fflush(fp))
goto err;
} else if (len >= (w = fp->_bf._size)) {
- /* write directly up to INT_MAX or greatest multiple of buffer
- * size (whatever is smaller), keeping in the memory buffer the
- * remaining part of payload that is smaller than buffer size.
- */
- if (w != 0)
- w = MIN(w * (len / w), INT_MAX);
+ /* write directly */
w = _swrite(fp, p, w);
if (w <= 0)
goto err;