From 2a8d998930e5daeee074fb3eada5ddddef143c2c Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Fri, 4 May 2012 12:14:36 +0000 Subject: rewrite xftell64 and xfseek64 for W32 git-svn-id: svn://tug.org/texlive/trunk@26188 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/kpathsea/ChangeLog | 4 ++++ Build/source/texk/kpathsea/win32lib.c | 38 ++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 14 deletions(-) (limited to 'Build') diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index 160e322e6f4..04fa0557f77 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,3 +1,7 @@ +2012-05-04 Akira Kakuto + + * win32lib.c: rewrite xftell64 and xfseek64 for W32. + 2012-04-30 Akira Kakuto * win32lib.c: further rewrite win32_system(). diff --git a/Build/source/texk/kpathsea/win32lib.c b/Build/source/texk/kpathsea/win32lib.c index 270cce659cc..6a346ebfdde 100644 --- a/Build/source/texk/kpathsea/win32lib.c +++ b/Build/source/texk/kpathsea/win32lib.c @@ -281,26 +281,36 @@ int __cdecl kpathsea_win32_pclose (kpathsea kpse, FILE *f) /* large file support */ -void -xfseek64 (FILE *f, __int64 offset, int wherefrom, const char *filename) -{ - fflush(f); - if (_lseeki64(fileno(f), offset, wherefrom) < (__int64)0) - FATAL_PERROR(filename); -} - __int64 xftell64 (FILE *f, const char *filename) { - __int64 where; - fflush(f); - where = _telli64(fileno(f)); - if (where < (__int64)0) - FATAL_PERROR(filename); + __int64 where, filepos; + int fd; + + fd = fileno(f); + if(f->_cnt < 0) + f->_cnt = 0; + if((filepos = _lseeki64(fd, (__int64)0, SEEK_CUR)) < (__int64)0) { + FATAL_PERROR(filename); + return (__int64)(-1); + } + where = filepos - f->_cnt; + return where; +} - return where; +void +xfseek64 (FILE *f, __int64 offset, int wherefrom, const char *filename) +{ + if(wherefrom == SEEK_CUR) { + offset += xftell64(f, filename); + wherefrom = SEEK_SET; + } + fflush(f); + if (_lseeki64(fileno(f), offset, wherefrom) < (__int64)0) + FATAL_PERROR(filename); } + /* special TeXLive Ghostscript */ static int is_dir (char *buff) -- cgit v1.2.3