[2/2] msvcrt: Add tmpfile_s implementation

André Hentschel nerv at dawncrow.de
Sun Feb 12 12:37:04 CST 2012


http://bugs.winehq.org/show_bug.cgi?id=29549
---
 dlls/msvcr100/msvcr100.spec |    2 +-
 dlls/msvcr80/msvcr80.spec   |    2 +-
 dlls/msvcr90/msvcr90.spec   |    2 +-
 dlls/msvcrt/file.c          |   14 ++++++++++++++
 dlls/msvcrt/msvcrt.spec     |    2 +-
 dlls/msvcrt/tests/file.c    |   19 +++++++++++++++++++
 6 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index fc40dd8..e1321a6 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -1608,7 +1608,7 @@
 @ cdecl tan(double) msvcrt.tan
 @ cdecl tanh(double) msvcrt.tanh
 @ cdecl tmpfile() msvcrt.tmpfile
-@ stub tmpfile_s
+@ cdecl tmpfile_s(ptr) msvcrt.tmpfile_s
 @ cdecl tmpnam(ptr) msvcrt.tmpnam
 @ stub tmpnam_s
 @ cdecl tolower(long) msvcrt.tolower
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index b256280..117b645 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -1462,7 +1462,7 @@
 @ cdecl tan(double) msvcrt.tan
 @ cdecl tanh(double) msvcrt.tanh
 @ cdecl tmpfile() msvcrt.tmpfile
-@ stub tmpfile_s
+@ cdecl tmpfile_s(ptr) msvcrt.tmpfile_s
 @ cdecl tmpnam(ptr) msvcrt.tmpnam
 @ stub tmpnam_s
 @ cdecl tolower(long) msvcrt.tolower
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index e2d1c5f..e6e7a1c 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -1473,7 +1473,7 @@
 @ cdecl tanh(double) msvcrt.tanh
 @ cdecl -arch=x86_64 tanhf(float) msvcrt.tanhf
 @ cdecl tmpfile() msvcrt.tmpfile
-@ stub tmpfile_s
+@ cdecl tmpfile_s(ptr) msvcrt.tmpfile_s
 @ cdecl tmpnam(ptr) msvcrt.tmpnam
 @ stub tmpnam_s
 @ cdecl tolower(long) msvcrt.tolower
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index c15e33f..f056548 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -3773,6 +3773,20 @@ MSVCRT_FILE* CDECL MSVCRT_tmpfile(void)
   return file;
 }
 
+/*********************************************************************
+ *      tmpfile_s (MSVCRT.@)
+ */
+int CDECL MSVCRT_tmpfile_s(MSVCRT_FILE** file)
+{
+    if (!file) {
+        *MSVCRT__errno() = MSVCRT_EINVAL;
+        return MSVCRT_EINVAL;
+    }
+
+    *file = MSVCRT_tmpfile();
+    return 0;
+}
+
 static int puts_clbk_file_a(void *file, int len, const char *str)
 {
     return MSVCRT_fwrite(str, sizeof(char), len, file);
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index b103f57..1a41678 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -1422,7 +1422,7 @@
 @ cdecl -arch=x86_64 tanhf(float) MSVCRT_tanhf
 @ cdecl time(ptr) MSVCRT_time
 @ cdecl tmpfile() MSVCRT_tmpfile
-# stub tmpfile_s(ptr)
+@ cdecl tmpfile_s(ptr) MSVCRT_tmpfile_s
 @ cdecl tmpnam(ptr) MSVCRT_tmpnam
 # stub tmpnam_s(ptr long)
 @ cdecl tolower(long) MSVCRT_tolower
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index b9b904d..d27c6aa 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -37,6 +37,7 @@
 static HANDLE proc_handles[2];
 
 static int (__cdecl *p_fopen_s)(FILE**, const char*, const char*);
+static int (__cdecl *p_tmpfile_s)(FILE**);
 static int (__cdecl *p__wfopen_s)(FILE**, const wchar_t*, const wchar_t*);
 
 static void init(void)
@@ -44,6 +45,7 @@ static void init(void)
     HMODULE hmod = GetModuleHandleA("msvcrt.dll");
 
     p_fopen_s = (void*)GetProcAddress(hmod, "fopen_s");
+    p_tmpfile_s = (void*)GetProcAddress(hmod, "tmpfile_s");
     p__wfopen_s = (void*)GetProcAddress(hmod, "_wfopen_s");
 }
 
@@ -1147,6 +1149,22 @@ static void test_tmpnam( void )
   ok(res[strlen(res)-1] != '.', "second call - last character is a dot\n");
 }
 
+static void test_tmpfile_s( void )
+{
+    int ret;
+
+    if (!p_tmpfile_s)
+    {
+        win_skip("Skipping tmpfile_s test\n");
+        return;
+    }
+
+    errno = 0;
+    ret = p_tmpfile_s(NULL);
+    ok(ret == EINVAL, "Expected tmpfile_s to return EINVAL, got %i\n", ret);
+    ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
+}
+
 static void test_chsize( void )
 {
     int fd;
@@ -1586,6 +1604,7 @@ START_TEST(file)
     test_ctrlz();
     test_file_put_get();
     test_tmpnam();
+    test_tmpfile_s();
     test_get_osfhandle();
     test_setmaxstdio();
     test_pipes(arg_v[0]);
-- 

Best Regards, André Hentschel
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Nachrichtenteil als Anhang
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20120212/0bfc3816/attachment.ksh>


More information about the wine-patches mailing list