diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-11-29 16:28:30 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-11-29 16:28:30 +0000 |
commit | 0772f3f1c18483ff69b4a4cec918df39596eae5c (patch) | |
tree | ad788e069002f5924f39d5f624368177a6223d97 /newlib/libc/stdio/ftell.c | |
parent | 0d829d9695a57a37203b1ef1e4ca812bd1fb2fb1 (diff) | |
download | cygnal-0772f3f1c18483ff69b4a4cec918df39596eae5c.tar.gz cygnal-0772f3f1c18483ff69b4a4cec918df39596eae5c.tar.bz2 cygnal-0772f3f1c18483ff69b4a4cec918df39596eae5c.zip |
* libc/include/sys/reent.h (__sFILE): Change type of _offset
from int to _off_t.
* libc/stdio/ftell.c: Use _ftello_r().
* libc/stdio/ftello.c: Copy implementation from previous
_ftell_r().
* libc/stdio/fseek.c: Use _fseeko_r().
* libc/stdio/fseeko.c: Copy implementation from previous
_fseek_r().
Diffstat (limited to 'newlib/libc/stdio/ftell.c')
-rw-r--r-- | newlib/libc/stdio/ftell.c | 55 |
1 files changed, 2 insertions, 53 deletions
diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index 54a656c09..5af0709cb 100644 --- a/newlib/libc/stdio/ftell.c +++ b/newlib/libc/stdio/ftell.c @@ -105,64 +105,13 @@ _DEFUN(_ftell_r, (ptr, fp), { _fpos_t pos; - /* Ensure stdio is set up. */ - - CHECK_INIT (ptr, fp); - - _newlib_flockfile_start (fp); - - if (fp->_seek == NULL) - { - ptr->_errno = ESPIPE; - _newlib_flockfile_exit (fp); - return -1L; - } - - /* Find offset of underlying I/O object, then adjust for buffered - bytes. Flush a write stream, since the offset may be altered if - the stream is appending. Do not flush a read stream, since we - must not lose the ungetc buffer. */ - if (fp->_flags & __SWR) - _fflush_r (ptr, fp); - if (fp->_flags & __SOFF) - pos = fp->_offset; - else - { - pos = fp->_seek (ptr, fp->_cookie, (_fpos_t) 0, SEEK_CUR); - if (pos == -1L) - { - _newlib_flockfile_exit (fp); - return pos; - } - } - if (fp->_flags & __SRD) - { - /* - * Reading. Any unread characters (including - * those from ungetc) cause the position to be - * smaller than that in the underlying object. - */ - pos -= fp->_r; - if (HASUB (fp)) - pos -= fp->_ur; - } - else if ((fp->_flags & __SWR) && fp->_p != NULL) - { - /* - * Writing. Any buffered characters cause the - * position to be greater than that in the - * underlying object. - */ - pos += fp->_p - fp->_bf._base; - } - - _newlib_flockfile_end (fp); + pos = _ftello_r (ptr, fp); if ((long)pos != pos) { pos = -1; ptr->_errno = EOVERFLOW; } - return pos; + return (long)pos; } #ifndef _REENT_ONLY |