Nikolay Sivov : msvcrt: Fix char to int promotion that breaks pattern lookup.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Dec 23 18:22:07 CST 2015
Module: wine
Branch: master
Commit: d99727bcb3f211b39421b1d738a3d3165fb82d78
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d99727bcb3f211b39421b1d738a3d3165fb82d78
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Dec 23 01:14:28 2015 +0300
msvcrt: Fix char to int promotion that breaks pattern lookup.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/scanf.h | 8 ++++++++
dlls/msvcrt/tests/scanf.c | 7 +++++++
2 files changed, 15 insertions(+)
diff --git a/dlls/msvcrt/scanf.h b/dlls/msvcrt/scanf.h
index 9322704..5bf91a6 100644
--- a/dlls/msvcrt/scanf.h
+++ b/dlls/msvcrt/scanf.h
@@ -68,7 +68,11 @@
#undef _EOF_
#define _EOF_ 0
#ifdef STRING_LEN
+#ifdef WIDE_CHAR
#define _GETC_(file) (consumed==length ? '\0' : (consumed++, *file++))
+#else /* WIDE_CHAR */
+#define _GETC_(file) (consumed==length ? '\0' : (consumed++, (unsigned char)*file++))
+#endif /* WIDE_CHAR */
#define _UNGETC_(nch, file) do { file--; consumed--; } while(0)
#define _LOCK_FILE_(file) do {} while(0)
#define _UNLOCK_FILE_(file) do {} while(0)
@@ -86,7 +90,11 @@
#endif /* SECURE */
#endif /* WIDE_SCANF */
#else /* STRING_LEN */
+#ifdef WIDE_CHAR
#define _GETC_(file) (consumed++, *file++)
+#else /* WIDE_CHAR */
+#define _GETC_(file) (consumed++, (unsigned char)*file++)
+#endif /* WIDE_CHAR */
#define _UNGETC_(nch, file) do { file--; consumed--; } while(0)
#define _LOCK_FILE_(file) do {} while(0)
#define _UNLOCK_FILE_(file) do {} while(0)
diff --git a/dlls/msvcrt/tests/scanf.c b/dlls/msvcrt/tests/scanf.c
index 3c5a05e..6cb85fa 100644
--- a/dlls/msvcrt/tests/scanf.c
+++ b/dlls/msvcrt/tests/scanf.c
@@ -244,6 +244,13 @@ static void test_sscanf( void )
ret = sscanf(buffer, "%d:%d%n", &hour, &min, &number_so_far);
ok(ret == 2, "Wrong number of arguments read: %d\n", ret);
ok(number_so_far == 4, "%%n yielded wrong result: %d\n", number_so_far);
+
+ buffer[0] = 0;
+ buffer1[0] = 0;
+ ret = sscanf("test=value\xda", "%[^=] = %[^;]", buffer, buffer1);
+ ok(ret == 2, "got %d\n", ret);
+ ok(!strcmp(buffer, "test"), "buf %s\n", buffer);
+ ok(!strcmp(buffer1, "value\xda"), "buf %s\n", buffer1);
}
static void test_sscanf_s(void)
More information about the wine-cvs
mailing list