Daniel Lehman : msvcrt: Make WEOF returned from swscanf signed.

Alexandre Julliard julliard at winehq.org
Fri Jan 6 15:31:33 CST 2012


Module: wine
Branch: master
Commit: 5a3695ccee31a1e0353a96f4e82619cf3de4cd36
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5a3695ccee31a1e0353a96f4e82619cf3de4cd36

Author: Daniel Lehman <dlehman at esri.com>
Date:   Wed Jan  4 13:58:23 2012 -0800

msvcrt: Make WEOF returned from swscanf signed.

---

 dlls/msvcrt/scanf.h       |    2 +-
 dlls/msvcrt/tests/scanf.c |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/dlls/msvcrt/scanf.h b/dlls/msvcrt/scanf.h
index d1ac548..9f6911e 100644
--- a/dlls/msvcrt/scanf.h
+++ b/dlls/msvcrt/scanf.h
@@ -26,7 +26,7 @@
 #ifdef WIDE_SCANF
 #define _CHAR_ MSVCRT_wchar_t
 #define _EOF_ MSVCRT_WEOF
-#define _EOF_RET MSVCRT_WEOF
+#define _EOF_RET (short)MSVCRT_WEOF
 #define _ISSPACE_(c) MSVCRT_iswspace(c)
 #define _ISDIGIT_(c) MSVCRT_iswdigit(c)
 #define _WIDE2SUPPORTED_(c) c /* No conversion needed (wide to wide) */
diff --git a/dlls/msvcrt/tests/scanf.c b/dlls/msvcrt/tests/scanf.c
index cbfb184..8b13bdc 100644
--- a/dlls/msvcrt/tests/scanf.c
+++ b/dlls/msvcrt/tests/scanf.c
@@ -243,8 +243,25 @@ static void test_sscanf_s(void)
     ok(i==123, "i = %d\n", i);
 }
 
+static void test_swscanf( void )
+{
+    wchar_t buffer[100];
+    int result, ret;
+    static const WCHAR formatd[] = {'%','d',0};
+
+    /* check WEOF */
+    /* WEOF is an unsigned short -1 but swscanf returns int
+       so it should be sign-extended */
+    buffer[0] = 0;
+    ret = swscanf(buffer, formatd, &result);
+    /* msvcrt returns 0 but should return -1 (later versions do) */
+    ok( ret == (short)WEOF || broken(ret == 0),
+        "swscanf returns %x instead of %x\n", ret, WEOF );
+}
+
 START_TEST(scanf)
 {
     test_sscanf();
     test_sscanf_s();
+    test_swscanf();
 }




More information about the wine-cvs mailing list