diff --git a/newlib/libc/stdio/fseeko.c b/newlib/libc/stdio/fseeko.c index 3e0f9e90b..bbf1af43e 100644 --- a/newlib/libc/stdio/fseeko.c +++ b/newlib/libc/stdio/fseeko.c @@ -141,31 +141,12 @@ _fseeko_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, (_fpos_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 = _ftello_r(ptr, fp); + if (curoff == -1L) + { + _newlib_flockfile_exit (fp); + return EOF; + } offset += curoff; whence = SEEK_SET; 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;