Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Bouclet <bastien.bouclet@gmail.com>2019-11-09 19:28:04 +0300
committerCorinna Vinschen <corinna@vinschen.de>2019-11-18 13:02:52 +0300
commit59362c80e3a02c011fd0ef3d7f07a20098d2a9d5 (patch)
treefe2fead8741a3cd294cd7ebf133ffe97ddb5b4a3 /newlib/libc/stdio64
parent1626569222066ee601f6c41b29efcc95202674b7 (diff)
newlib: fix fseek optimization with SEEK_CUR
The call to fflush was invalidating the read buffer, preventing relative seeks to positions that would have been inside the read buffer from being optimized. The call to srefill would then re-read mostly the same data that was initially in the read buffer.
Diffstat (limited to 'newlib/libc/stdio64')
-rw-r--r--newlib/libc/stdio64/fseeko64.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/newlib/libc/stdio64/fseeko64.c b/newlib/libc/stdio64/fseeko64.c
index 0672086a3..f38005570 100644
--- a/newlib/libc/stdio64/fseeko64.c
+++ b/newlib/libc/stdio64/fseeko64.c
@@ -142,31 +142,12 @@ _fseeko64_r (struct _reent *ptr,
switch (whence)
{
case SEEK_CUR:
- /*
- * In order to seek relative to the current stream offset,
- * we have to first find the current stream offset a la
- * ftell (see ftell for details).
- */
- _fflush_r (ptr, fp); /* may adjust seek offset on append stream */
- if (fp->_flags & __SOFF)
- curoff = fp->_offset;
- else
- {
- curoff = seekfn (ptr, fp->_cookie, (_fpos64_t) 0, SEEK_CUR);
- if (curoff == -1L)
- {
- _newlib_flockfile_exit(fp);
- return EOF;
- }
- }
- if (fp->_flags & __SRD)
- {
- curoff -= fp->_r;
- if (HASUB (fp))
- curoff -= fp->_ur;
- }
- else if (fp->_flags & __SWR && fp->_p != NULL)
- curoff += fp->_p - fp->_bf._base;
+ curoff = _ftello64_r(ptr, fp);
+ if (curoff == -1L)
+ {
+ _newlib_flockfile_exit (fp);
+ return EOF;
+ }
offset += curoff;
whence = SEEK_SET;