Andrey Zhezherun : msvcrt: Implemented _chsize_s.
Alexandre Julliard
julliard at winehq.org
Fri Jan 10 14:44:54 CST 2014
Module: wine
Branch: stable
Commit: f768b8dec18a03d363c8c885ae792c73571dc5c4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f768b8dec18a03d363c8c885ae792c73571dc5c4
Author: Andrey Zhezherun <zhezherun at yandex.ru>
Date: Tue Nov 5 09:04:19 2013 +0000
msvcrt: Implemented _chsize_s.
(cherry picked from commit 3bb2c11757156223be0f8a22f3b377b060b09562)
---
dlls/msvcr100/msvcr100.spec | 2 +-
dlls/msvcr110/msvcr110.spec | 2 +-
dlls/msvcr80/msvcr80.spec | 2 +-
dlls/msvcr90/msvcr90.spec | 2 +-
dlls/msvcrt/file.c | 27 +++++++++++++++++++--------
dlls/msvcrt/msvcrt.spec | 2 +-
include/msvcrt/io.h | 1 +
7 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index bc93840..038a787 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -721,7 +721,7 @@
@ cdecl -arch=i386 -norelay _chkesp() msvcrt._chkesp
@ cdecl _chmod(str long) msvcrt._chmod
@ cdecl _chsize(long long) msvcrt._chsize
-@ stub _chsize_s
+@ cdecl _chsize_s(long int64) msvcrt._chsize_s
@ cdecl _clearfp() msvcrt._clearfp
@ cdecl _close(long) msvcrt._close
@ cdecl _commit(long) msvcrt._commit
diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec
index 57bd107..343d26b 100644
--- a/dlls/msvcr110/msvcr110.spec
+++ b/dlls/msvcr110/msvcr110.spec
@@ -1073,7 +1073,7 @@
@ cdecl -arch=i386 -norelay _chkesp() msvcrt._chkesp
@ cdecl _chmod(str long) msvcrt._chmod
@ cdecl _chsize(long long) msvcrt._chsize
-@ stub _chsize_s
+@ cdecl _chsize_s(long int64) msvcrt._chsize_s
@ cdecl _clearfp() msvcrt._clearfp
@ cdecl _close(long) msvcrt._close
@ cdecl _commit(long) msvcrt._commit
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index c950f60..4f07638 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -384,7 +384,7 @@
@ cdecl -arch=i386 -norelay _chkesp() msvcrt._chkesp
@ cdecl _chmod(str long) msvcrt._chmod
@ cdecl _chsize(long long) msvcrt._chsize
-@ stub _chsize_s
+@ cdecl _chsize_s(long int64) msvcrt._chsize_s
@ cdecl _clearfp() msvcrt._clearfp
@ cdecl _close(long) msvcrt._close
@ cdecl _commit(long) msvcrt._commit
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index ff00184..24251e1 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -367,7 +367,7 @@
@ cdecl -arch=i386 -norelay _chkesp() msvcrt._chkesp
@ cdecl _chmod(str long) msvcrt._chmod
@ cdecl _chsize(long long) msvcrt._chsize
-@ stub _chsize_s
+@ cdecl _chsize_s(long int64) msvcrt._chsize_s
@ cdecl _clearfp() msvcrt._clearfp
@ cdecl _close(long) msvcrt._close
@ cdecl _commit(long) msvcrt._commit
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index f26d0c2..0c67744 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -1259,15 +1259,17 @@ int CDECL MSVCRT_fseek(MSVCRT_FILE* file, MSVCRT_long offset, int whence)
}
/*********************************************************************
- * _chsize (MSVCRT.@)
+ * _chsize_s (MSVCRT.@)
*/
-int CDECL MSVCRT__chsize(int fd, MSVCRT_long size)
+int CDECL MSVCRT__chsize_s(int fd, __int64 size)
{
- LONG cur, pos;
+ __int64 cur, pos;
HANDLE handle;
BOOL ret = FALSE;
- TRACE("(fd=%d, size=%d)\n", fd, size);
+ TRACE("(fd=%d, size=%s)\n", fd, wine_dbgstr_longlong(size));
+
+ if (!MSVCRT_CHECK_PMT(size >= 0)) return MSVCRT_EINVAL;
LOCK_FILES();
@@ -1275,10 +1277,10 @@ int CDECL MSVCRT__chsize(int fd, MSVCRT_long size)
if (handle != INVALID_HANDLE_VALUE)
{
/* save the current file pointer */
- cur = MSVCRT__lseek(fd, 0, SEEK_CUR);
+ cur = MSVCRT__lseeki64(fd, 0, SEEK_CUR);
if (cur >= 0)
{
- pos = MSVCRT__lseek(fd, size, SEEK_SET);
+ pos = MSVCRT__lseeki64(fd, size, SEEK_SET);
if (pos >= 0)
{
ret = SetEndOfFile(handle);
@@ -1286,12 +1288,21 @@ int CDECL MSVCRT__chsize(int fd, MSVCRT_long size)
}
/* restore the file pointer */
- MSVCRT__lseek(fd, cur, SEEK_SET);
+ MSVCRT__lseeki64(fd, cur, SEEK_SET);
}
}
UNLOCK_FILES();
- return ret ? 0 : -1;
+ return ret ? 0 : *MSVCRT__errno();
+}
+
+/*********************************************************************
+ * _chsize (MSVCRT.@)
+ */
+int CDECL MSVCRT__chsize(int fd, MSVCRT_long size)
+{
+ /* _chsize_s returns errno on failure but _chsize should return -1 */
+ return MSVCRT__chsize_s( fd, size ) == 0 ? 0 : -1;
}
/*********************************************************************
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index 58ceaf9..090cddd 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -356,7 +356,7 @@
@ cdecl -arch=i386 -norelay _chkesp()
@ cdecl _chmod(str long) MSVCRT__chmod
@ cdecl _chsize(long long) MSVCRT__chsize
-# stub _chsize_s(long int64)
+@ cdecl _chsize_s(long int64) MSVCRT__chsize_s
# stub _chvalidator(long long)
# stub _chvalidator_l(ptr long long)
@ cdecl _clearfp()
diff --git a/include/msvcrt/io.h b/include/msvcrt/io.h
index 09b615c..b227b20 100644
--- a/include/msvcrt/io.h
+++ b/include/msvcrt/io.h
@@ -87,6 +87,7 @@ extern "C" {
int __cdecl _access(const char*,int);
int __cdecl _chmod(const char*,int);
int __cdecl _chsize(int,__msvcrt_ulong);
+int __cdecl _chsize_s(int,__int64);
int __cdecl _close(int);
int __cdecl _commit(int);
int __cdecl _creat(const char*,int);
More information about the wine-cvs
mailing list