[PATCH 1/2] msvcrt: Fix char to int promotion that breaks pattern lookup
Nikolay Sivov
nsivov at codeweavers.com
Tue Dec 22 16:14:28 CST 2015
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
Fixes https://bugs.winehq.org/show_bug.cgi?id=39678
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)
--
2.6.4
More information about the wine-patches
mailing list