diff options
Diffstat (limited to 'newlib/libc/stdio/fvwrite.c')
-rw-r--r-- | newlib/libc/stdio/fvwrite.c | 62 |
1 files changed, 20 insertions, 42 deletions
diff --git a/newlib/libc/stdio/fvwrite.c b/newlib/libc/stdio/fvwrite.c index f036d7483..8e7d316fb 100644 --- a/newlib/libc/stdio/fvwrite.c +++ b/newlib/libc/stdio/fvwrite.c @@ -1,3 +1,5 @@ +/* No user fns here. Pesch 15apr92. */ + /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -14,17 +16,14 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -/* No user fns here. Pesch 15apr92. */ -#include <_ansi.h> #include <stdio.h> #include <string.h> -#include <stdlib.h> #include "local.h" #include "fvwrite.h" #define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define COPY(n) _CAST_VOID memmove ((_PTR) fp->_p, (_PTR) p, (size_t) (n)) +#define COPY(n) (void) memmove((void *) fp->_p, (void *) p, (size_t) (n)) #define GETIOV(extra_work) \ while (len == 0) \ @@ -43,12 +42,12 @@ */ int -_DEFUN(__sfvwrite, (fp, uio), - register FILE *fp _AND - register struct __suio *uio) +__sfvwrite (fp, uio) + register FILE *fp; + register struct __suio *uio; { register size_t len; - register _CONST char *p = NULL; + register _CONST char *p; register struct __siov *iov; register int w, s; char *nl; @@ -68,17 +67,17 @@ _DEFUN(__sfvwrite, (fp, uio), if (fp->_flags & __SCLE) /* text mode */ { do - { - GETIOV (;); - while (len > 0) - { - if (putc (*p, fp) == EOF) - return EOF; - p++; - len--; - uio->uio_resid--; - } - } + { + GETIOV (;); + while (len > 0) + { + if (putc(*p, fp) == EOF) + return EOF; + p++; + len--; + uio->uio_resid--; + } + } while (uio->uio_resid > 0); return 0; } @@ -111,9 +110,7 @@ _DEFUN(__sfvwrite, (fp, uio), * as fit, but pretend we wrote everything. This makes * snprintf() return the number of bytes needed, rather * than the number used, and avoids its write function - * (so that the write function can be invalid). If - * we are dealing with the asprintf routines, we will - * dynamically increase the buffer size as needed. + * (so that the write function can be invalid). */ do { @@ -121,24 +118,6 @@ _DEFUN(__sfvwrite, (fp, uio), w = fp->_w; if (fp->_flags & __SSTR) { - if (len > w && fp->_flags & __SMBF) - { /* must be asprintf family */ - unsigned char *ptr; - int curpos = (fp->_p - fp->_bf._base); - ptr = (unsigned char *)_realloc_r (_REENT, - fp->_bf._base, - curpos + len); - if (!ptr) - { - /* Free buffer which is no longer used. */ - _free_r (_REENT, fp->_bf._base); - goto err; - } - fp->_bf._base = ptr; - fp->_p = ptr + curpos; - fp->_bf._size = curpos + len; - w = fp->_w = len; - } if (len < w) w = len; COPY (w); /* copy MIN(fp->_w,len), */ @@ -185,13 +164,12 @@ _DEFUN(__sfvwrite, (fp, uio), * that the amount to write is MIN(len,nldist). */ nlknown = 0; - nldist = 0; do { GETIOV (nlknown = 0); if (!nlknown) { - nl = memchr ((_PTR) p, '\n', len); + nl = memchr ((void *) p, '\n', len); nldist = nl ? nl + 1 - p : len + 1; nlknown = 1; } |