msvcrt: Make WEOF returned from swscanf signed.

This commit is contained in:
Daniel Lehman 2012-01-04 13:58:23 -08:00 committed by Alexandre Julliard
parent 739bd884a0
commit 5a3695ccee
2 changed files with 18 additions and 1 deletions

View File

@ -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) */

View File

@ -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();
}