From 4ffa9364eba5d4c2a5b00d6df647ac0cfb6db3ec Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Thu, 10 Jan 2013 11:44:02 +0100 Subject: [PATCH] msvcrt: Simplify fseek implementation. --- dlls/msvcrt/file.c | 15 +++------------ dlls/msvcrt/msvcrt.h | 1 + 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 8b5ec29e362..e19e81e3424 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -1169,19 +1169,10 @@ int CDECL MSVCRT__fseeki64(MSVCRT_FILE* file, __int64 offset, int whence) msvcrt_flush_buffer(file); if(whence == SEEK_CUR && file->_flag & MSVCRT__IOREAD ) { - offset -= file->_cnt; - if (msvcrt_get_ioinfo(file->_file)->wxflag & WX_TEXT) { - /* Black magic correction for CR removal */ - int i; - for (i=0; i_cnt; i++) { - if (file->_ptr[i] == '\n') - offset--; - } - /* Black magic when reading CR at buffer boundary*/ - if(msvcrt_get_ioinfo(file->_file)->wxflag & WX_READCR) - offset--; - } + whence = SEEK_SET; + offset += MSVCRT__ftelli64(file); } + /* Discard buffered input */ file->_cnt = 0; file->_ptr = file->_base; diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 30779bca7d2..1bdf393c9c8 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -885,6 +885,7 @@ int __cdecl MSVCRT_fgetc(MSVCRT_FILE*); int __cdecl MSVCRT_ungetc(int,MSVCRT_FILE*); MSVCRT_wint_t __cdecl MSVCRT_fgetwc(MSVCRT_FILE*); MSVCRT_wint_t __cdecl MSVCRT_ungetwc(MSVCRT_wint_t,MSVCRT_FILE*); +__int64 __cdecl MSVCRT__ftelli64(MSVCRT_FILE* file); void __cdecl MSVCRT__exit(int); void __cdecl MSVCRT_abort(void); MSVCRT_ulong* __cdecl MSVCRT___doserrno(void);