msvcrt: Add tmpfile_s implementation (try2)

André Hentschel nerv at dawncrow.de
Tue Jul 17 13:39:01 CDT 2012


---
 dlls/msvcr100/msvcr100.spec  |    2 +-
 dlls/msvcr80/msvcr80.spec    |    2 +-
 dlls/msvcr90/msvcr90.spec    |    2 +-
 dlls/msvcr90/tests/msvcr90.c |   19 +++++++++++++++++++
 dlls/msvcrt/file.c           |   14 ++++++++++++++
 dlls/msvcrt/msvcrt.spec      |    2 +-
 6 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 70bcbd0..090e82c 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -1609,7 +1609,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 d758176..3644345 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -1463,7 +1463,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 5c27fca..d10c78e 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -1474,7 +1474,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/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c
index 92945ae..b183918 100644
--- a/dlls/msvcr90/tests/msvcr90.c
+++ b/dlls/msvcr90/tests/msvcr90.c
@@ -75,6 +75,7 @@ static void (__cdecl *p_qsort_s)(void *, size_t, size_t, int (__cdecl *)(void *,
 static void* (__cdecl *p_bsearch_s)(const void *, const void *, size_t, size_t,
                                     int (__cdecl *compare)(void *, const void *, const void *), void *);
 static int (__cdecl *p_controlfp_s)(unsigned int *, unsigned int, unsigned int);
+static int (__cdecl *p_tmpfile_s)(FILE**);
 static int (__cdecl *p_atoflt)(_CRT_FLOAT *, char *);
 static unsigned int (__cdecl *p_set_abort_behavior)(unsigned int, unsigned int);
 static int (__cdecl *p_sopen_s)(int*, const char*, int, int, int);
@@ -255,6 +256,7 @@ static BOOL init(void)
     SET(p_qsort_s, "qsort_s");
     SET(p_bsearch_s, "bsearch_s");
     SET(p_controlfp_s, "_controlfp_s");
+    SET(p_tmpfile_s, "tmpfile_s");
     SET(p_atoflt, "_atoflt");
     SET(p_set_abort_behavior, "_set_abort_behavior");
     SET(p_sopen_s, "_sopen_s");
@@ -833,6 +835,22 @@ static void test_controlfp_s(void)
     ok( cur != 0xdeadbeef, "value not set\n" );
 }
 
+static void test_tmpfile_s( void )
+{
+    FILE *tmp;
+    int ret;
+
+    errno = 0xdeadbeef;
+    SET_EXPECT(invalid_parameter_handler);
+    ret = p_tmpfile_s(NULL);
+    ok(ret == EINVAL, "Expected tmpfile_s to return EINVAL, got %i\n", ret);
+    CHECK_CALLED(invalid_parameter_handler);
+    ok(errno == 0xdeadbeef, "errno = %x\n", errno);
+
+    ret = p_tmpfile_s(&tmp);
+    ok(!ret, "wrong result %d\n", ret);
+}
+
 typedef struct
 {
     const char *str;
@@ -1211,6 +1229,7 @@ START_TEST(msvcr90)
     test_qsort_s();
     test_bsearch_s();
     test_controlfp_s();
+    test_tmpfile_s();
     test__atoflt();
     test__set_abort_behavior();
     test__sopen_s();
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index df2c7cd..d80a759 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -3792,6 +3792,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 934c247..c84ecba 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
-- 
1.7.4.1

-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list