msvcrt: Don't use ungetc when reading double in scanf.

It may not work on unbuffered streams.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2020-01-03 19:42:25 +01:00 committed by Alexandre Julliard
parent 1366dd69d5
commit c4ad739195
2 changed files with 115 additions and 60 deletions

View File

@ -47,7 +47,6 @@
#ifdef CONSOLE
#define _GETC_FUNC_(file) _getch()
#define _UNGETC_FUNC_(nch, file) _ungetch(nch)
#define _STRTOD_NAME_(func) console_ ## func
#define _GETC_(file) (consumed++, _getch())
#define _UNGETC_(nch, file) do { _ungetch(nch); consumed--; } while(0)
@ -71,7 +70,6 @@
#undef _EOF_
#define _EOF_ 0
#define _GETC_FUNC_(file) (*file++)
#define _UNGETC_FUNC_(nch, file) do { file--; } while(0)
#ifdef WIDE_SCANF
#define _STRTOD_NAME_(func) wstr_ ## func
#else
@ -125,7 +123,6 @@
#else /* STRING */
#ifdef WIDE_SCANF
#define _GETC_FUNC_(file) MSVCRT_fgetwc(file)
#define _UNGETC_FUNC_(nch, file) MSVCRT_ungetwc(nch, file)
#define _STRTOD_NAME_(func) filew_ ## func
#define _GETC_(file) (consumed++, MSVCRT_fgetwc(file))
#define _UNGETC_(nch, file) do { MSVCRT_ungetwc(nch, file); consumed--; } while(0)
@ -138,7 +135,6 @@
#endif /* SECURE */
#else /* WIDE_SCANF */
#define _GETC_FUNC_(file) MSVCRT_fgetc(file)
#define _UNGETC_FUNC_(nch, file) MSVCRT_ungetc(nch, file)
#define _STRTOD_NAME_(func) file_ ## func
#define _GETC_(file) (consumed++, MSVCRT_fgetc(file))
#define _UNGETC_(nch, file) do { MSVCRT_ungetc(nch, file); consumed--; } while(0)
@ -163,22 +159,28 @@ struct _STRTOD_NAME_(strtod_scanf_ctx) {
#endif
int length;
int read;
_CHAR_ unget_buf[8];
int cur;
int unget;
BOOL err;
};
static MSVCRT_wchar_t _STRTOD_NAME_(strtod_scanf_get)(void *ctx)
{
struct _STRTOD_NAME_(strtod_scanf_ctx) *context = ctx;
int c;
context->cur = _EOF_;
if (!context->length) return MSVCRT_WEOF;
c = _GETC_FUNC_(context->file);
if (c == _EOF_) return MSVCRT_WEOF;
if (context->unget != _EOF_) {
context->cur = context->unget;
context->unget = _EOF_;
} else {
context->cur = _GETC_FUNC_(context->file);
if (context->cur == _EOF_) return MSVCRT_WEOF;
}
if (context->length > 0) context->length--;
context->unget_buf[context->read % ARRAY_SIZE(context->unget_buf)] = c;
context->read++;
return c;
return context->cur;
}
static void _STRTOD_NAME_(strtod_scanf_unget)(void *ctx)
@ -187,7 +189,11 @@ static void _STRTOD_NAME_(strtod_scanf_unget)(void *ctx)
if (context->length >= 0) context->length++;
context->read--;
_UNGETC_FUNC_(context->unget_buf[context->read % ARRAY_SIZE(context->unget_buf)], context->file);
if (context->unget != _EOF_ || context->cur == _EOF_) {
context->err = TRUE;
return;
}
context->unget = context->cur;
}
#endif
@ -387,23 +393,27 @@ _FUNCTION_ {
/* skip initial whitespace */
while ((nch!=_EOF_) && _ISSPACE_(nch))
nch = _GETC_(file);
if (nch != _EOF_) _UNGETC_(nch, file);
ctx.unget = nch;
#ifdef STRING
ctx.file = file;
#endif
#ifdef STRING_LEN
if(ctx.length > length-consumed) ctx.length = length-consumed;
if(ctx.length > length-consumed+1) ctx.length = length-consumed+1;
#endif
cur = parse_double(_STRTOD_NAME_(strtod_scanf_get),
_STRTOD_NAME_(strtod_scanf_unget), &ctx, locinfo, NULL);
if(!ctx.read) break;
if(!rd && ctx.err) {
_UNLOCK_FILE_(file);
return _EOF_RET;
}
if(ctx.err || !ctx.read)
break;
consumed += ctx.read;
#ifdef STRING
file = ctx.file;
#endif
nch = _GETC_(file);
nch = ctx.cur;
st = 1;
if (!suppress) {
@ -712,7 +722,6 @@ _FUNCTION_ {
#undef _WIDE2SUPPORTED_
#undef _CHAR2DIGIT_
#undef _GETC_FUNC_
#undef _UNGETC_FUNC_
#undef _STRTOD_NAME_
#undef _GETC_
#undef _UNGETC_

View File

@ -45,12 +45,12 @@ static BOOL init(void)
return TRUE;
}
static int WINAPIV vsscanf_wrapper(unsigned __int64 options, const char *str, const char *format, ...)
static int WINAPIV vsscanf_wrapper(unsigned __int64 options, const char *str, size_t len, const char *format, ...)
{
int ret;
__ms_va_list valist;
__ms_va_start(valist, format);
ret = p_vsscanf(options, str, -1, format, NULL, valist);
ret = p_vsscanf(options, str, len, format, NULL, valist);
__ms_va_end(valist);
return ret;
}
@ -80,166 +80,166 @@ static void test_sscanf(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
ret = vsscanf_wrapper(tests[i], "", "%d", &result);
ret = vsscanf_wrapper(tests[i], "", -1, "%d", &result);
ok(ret == EOF, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ret = vsscanf_wrapper(tests[i], "000000000046F170", "%p", &ptr);
ret = vsscanf_wrapper(tests[i], "000000000046F170", -1, "%p", &ptr);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(ptr == (void *)0x46f170, "sscanf reads %p for flags %#x\n", ptr, tests[i]);
ret = vsscanf_wrapper(tests[i], "0046F171", "%p", &ptr);
ret = vsscanf_wrapper(tests[i], "0046F171", -1, "%p", &ptr);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(ptr == (void *)0x46f171, "sscanf reads %p for flags %#x\n", ptr, tests[i]);
ret = vsscanf_wrapper(tests[i], "46F172", "%p", &ptr);
ret = vsscanf_wrapper(tests[i], "46F172", -1, "%p", &ptr);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(ptr == (void *)0x46f172, "sscanf reads %p for flags %#x\n", ptr, tests[i]);
ret = vsscanf_wrapper(tests[i], "0x46F173", "%p", &ptr);
ret = vsscanf_wrapper(tests[i], "0x46F173", -1, "%p", &ptr);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
todo_wine ok(ptr == (void *)0x46f173, "sscanf reads %p for flags %#x\n", ptr, tests[i]);
ret = vsscanf_wrapper(tests[i], "-46F174", "%p", &ptr);
ret = vsscanf_wrapper(tests[i], "-46F174", -1, "%p", &ptr);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(ptr == (void *)(ULONG_PTR)-0x46f174, "sscanf reads %p for flags %#x\n", ptr, tests[i]);
ret = vsscanf_wrapper(tests[i], "+46F175", "%p", &ptr);
ret = vsscanf_wrapper(tests[i], "+46F175", -1, "%p", &ptr);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(ptr == (void *)0x46f175, "sscanf reads %p for flags %#x\n", ptr, tests[i]);
ret = vsscanf_wrapper(tests[i], "1233", "%p", &ptr);
ret = vsscanf_wrapper(tests[i], "1233", -1, "%p", &ptr);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(ptr == (void *)0x1233, "sscanf reads %p for flags %#x\n", ptr, tests[i]);
ret = vsscanf_wrapper(tests[i], "1234", "%P", &ptr);
ret = vsscanf_wrapper(tests[i], "1234", -1, "%P", &ptr);
todo_wine ok(ret == 0, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ret = vsscanf_wrapper(tests[i], "0x519", "%x", &result);
ret = vsscanf_wrapper(tests[i], "0x519", -1, "%x", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == 0x519, "sscanf reads %#x for flags %#x\n", result, tests[i]);
ret = vsscanf_wrapper(tests[i], "0x51a", "%x", &result);
ret = vsscanf_wrapper(tests[i], "0x51a", -1, "%x", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == 0x51a, "sscanf reads %#x for flags %#x\n", result, tests[i]);
ret = vsscanf_wrapper(tests[i], "0x51g", "%x", &result);
ret = vsscanf_wrapper(tests[i], "0x51g", -1, "%x", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == 0x51, "sscanf reads %#x for flags %#x\n", result, tests[i]);
result = 0;
ret = vsscanf_wrapper(tests[i], "-1", "%x", &result);
ret = vsscanf_wrapper(tests[i], "-1", -1, "%x", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == -1, "sscanf reads %#x for flags %#x\n", result, tests[i]);
ret = vsscanf_wrapper(tests[i], "\"%12@", "%\"%%%d%@", &result);
ret = vsscanf_wrapper(tests[i], "\"%12@", -1, "%\"%%%d%@", &result);
todo_wine ok(ret == 0, "sscanf returned %d for flags %#x\n", ret, tests[i]);
sprintf(buffer, "%f %f", float1, float2);
ret = vsscanf_wrapper(tests[i], buffer, "%f%f", &ret_float1, &ret_float2);
ret = vsscanf_wrapper(tests[i], buffer, -1, "%f%f", &ret_float1, &ret_float2);
ok(ret == 2, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(ret_float1 == float1, "got wrong float %.8e for flags %#x\n", ret_float1, tests[i]);
ok(ret_float2 == float2, "got wrong float %.8e for flags %#x\n", ret_float2, tests[i]);
sprintf(buffer, "%lf", 32.715);
ret = vsscanf_wrapper(tests[i], buffer, "%lf", &double_res);
ret = vsscanf_wrapper(tests[i], buffer, -1, "%lf", &double_res);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(double_res == 32.715, "got wrong double %.16e for flags %#x\n", double_res, tests[i]);
ret = vsscanf_wrapper(tests[i], buffer, "%Lf", &double_res);
ret = vsscanf_wrapper(tests[i], buffer, -1, "%Lf", &double_res);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(double_res == 32.715, "got wrong double %.16e for flags %#x\n", double_res, tests[i]);
ret = vsscanf_wrapper(tests[i], "1.1e-30", "%lf", &double_res);
ret = vsscanf_wrapper(tests[i], "1.1e-30", -1, "%lf", &double_res);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(double_res == 1.1e-30, "got wrong double %.16e for flags %#x\n", double_res, tests[i]);
ret = vsscanf_wrapper(tests[i], " Waverly", "%*c%[^\n]", buffer);
ret = vsscanf_wrapper(tests[i], " Waverly", -1, "%*c%[^\n]", buffer);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(!strcmp(buffer, " Waverly"), "got string '%s' for flags %#x\n", buffer, tests[i]);
ret = vsscanf_wrapper(tests[i], "abcefgdh", "%*[a-cg-e]%c", &buffer[0]);
ret = vsscanf_wrapper(tests[i], "abcefgdh", -1, "%*[a-cg-e]%c", &buffer[0]);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(buffer[0] == 'd', "got char '%c' for flags %#x\n", buffer[0], tests[i]);
ret = vsscanf_wrapper(tests[i], "abcefgdh", "%*[a-cd-dg-e]%c", &buffer[0]);
ret = vsscanf_wrapper(tests[i], "abcefgdh", -1, "%*[a-cd-dg-e]%c", &buffer[0]);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(buffer[0] == 'h', "got char '%c' for flags %#x\n", buffer[0], tests[i]);
strcpy(buffer, "foo");
strcpy(buffer1, "bar");
ret = vsscanf_wrapper(tests[i], "a", "%s%s", buffer, buffer1);
ret = vsscanf_wrapper(tests[i], "a", -1, "%s%s", buffer, buffer1);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(!strcmp(buffer, "a"), "got string '%s' for flags %#x\n", buffer, tests[i]);
ok(!strcmp(buffer1, "bar"), "got string '%s' for flags %#x\n", buffer1, tests[i]);
ret = vsscanf_wrapper(tests[i], "21:59:20", "%d%n", &result, &count);
ret = vsscanf_wrapper(tests[i], "21:59:20", -1, "%d%n", &result, &count);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == 21, "got wrong number %d for flags %#x\n", result, tests[i]);
ok(count == 2, "got wrong count %d for flags %#x\n", count, tests[i]);
ret = vsscanf_wrapper(tests[i], ":59:20", "%*c%n", &count);
ret = vsscanf_wrapper(tests[i], ":59:20", -1, "%*c%n", &count);
ok(ret == 0, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(count == 1, "got wrong count %d for flags %#x\n", count, tests[i]);
result = 0xdeadbeef;
ret = vsscanf_wrapper(tests[i], "12345678", "%hd", &result);
ret = vsscanf_wrapper(tests[i], "12345678", -1, "%hd", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == 0xdead614e, "got wrong number %#x for flags %#x\n", result, tests[i]);
result = 0xdeadbeef;
ret = vsscanf_wrapper(tests[i], "12345678", "%hhd", &result);
ret = vsscanf_wrapper(tests[i], "12345678", -1, "%hhd", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == 0xdeadbe4e, "got wrong number %#x for flags %#x\n", result, tests[i]);
ret = vsscanf_wrapper(tests[i], "12345678901234", "%lld", &result64);
ret = vsscanf_wrapper(tests[i], "12345678901234", -1, "%lld", &result64);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result64 == 12345678901234, "got wrong number 0x%s for flags %#x\n",
wine_dbgstr_longlong(result64), tests[i]);
ret = vsscanf_wrapper(tests[i], "123", "%i", &result);
ret = vsscanf_wrapper(tests[i], "123", -1, "%i", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == 123, "got wrong number %d for flags %#x\n", result, tests[i]);
ret = vsscanf_wrapper(tests[i], "-1", "%i", &result);
ret = vsscanf_wrapper(tests[i], "-1", -1, "%i", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == -1, "got wrong number %d for flags %#x\n", result, tests[i]);
ret = vsscanf_wrapper(tests[i], "123", "%d", &result);
ret = vsscanf_wrapper(tests[i], "123", -1, "%d", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == 123, "got wrong number %d for flags %#x\n", result, tests[i]);
ret = vsscanf_wrapper(tests[i], "-1", "%d", &result);
ret = vsscanf_wrapper(tests[i], "-1", -1, "%d", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == -1, "got wrong number %d for flags %#x\n", result, tests[i]);
ret = vsscanf_wrapper(tests[i], "017", "%i", &result);
ret = vsscanf_wrapper(tests[i], "017", -1, "%i", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == 15, "got wrong number %d for flags %#x\n", result, tests[i]);
ret = vsscanf_wrapper(tests[i], "0x17", "%i", &result);
ret = vsscanf_wrapper(tests[i], "0x17", -1, "%i", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == 23, "got wrong number %d for flags %#x\n", result, tests[i]);
ret = vsscanf_wrapper(tests[i], "-1", "%o", &result);
ret = vsscanf_wrapper(tests[i], "-1", -1, "%o", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == -1, "got wrong number %d for flags %#x\n", result, tests[i]);
ret = 0xdeadbeef;
ret = vsscanf_wrapper(tests[i], "-1", "%u", &result);
ret = vsscanf_wrapper(tests[i], "-1", -1, "%u", &result);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(result == -1, "got wrong number %d for flags %#x\n", result, tests[i]);
c = 0x55;
ret = vsscanf_wrapper(tests[i], "a", "%c", &c);
ret = vsscanf_wrapper(tests[i], "a", -1, "%c", &c);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(c == 'a', "got wrong char '%c' for flags %#x\n", c, tests[i]);
c = 0x55;
ret = vsscanf_wrapper(tests[i], " a", "%c", &c);
ret = vsscanf_wrapper(tests[i], " a", -1, "%c", &c);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(c == ' ', "got wrong char '%c' for flags %#x\n", c, tests[i]);
c = 0x55;
ret = vsscanf_wrapper(tests[i], "18:59", "%d:%d%c", &hour, &min, &c);
ret = vsscanf_wrapper(tests[i], "18:59", -1, "%d:%d%c", &hour, &min, &c);
ok(ret == 2, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(hour == 18, "got wrong char '%c' for flags %#x\n", hour, tests[i]);
ok(min == 59, "got wrong char '%c' for flags %#x\n", min, tests[i]);
@ -247,13 +247,13 @@ static void test_sscanf(void)
strcpy(buffer, "foo");
strcpy(buffer1, "bar");
ret = vsscanf_wrapper(tests[i], "abc def", "%s %n%s", buffer, &count, buffer1);
ret = vsscanf_wrapper(tests[i], "abc def", -1, "%s %n%s", buffer, &count, buffer1);
ok(ret == 2, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(!strcmp(buffer, "abc"), "got wrong string '%s' for flags %#x\n", buffer, tests[i]);
ok(count == 6, "got wrong count %d for flags %#x\n", count, tests[i]);
ok(!strcmp(buffer1, "def"), "got wrong string '%s' for flags %#x\n", buffer1, tests[i]);
ret = vsscanf_wrapper(tests[i], "3:45", "%d:%d%n", &hour, &min, &count);
ret = vsscanf_wrapper(tests[i], "3:45", -1, "%d:%d%n", &hour, &min, &count);
ok(ret == 2, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(hour == 3, "got wrong char '%c' for flags %#x\n", hour, tests[i]);
ok(min == 45, "got wrong char '%c' for flags %#x\n", min, tests[i]);
@ -261,10 +261,56 @@ static void test_sscanf(void)
strcpy(buffer, "foo");
strcpy(buffer1, "bar");
ret = vsscanf_wrapper(tests[i], "test=value\xda", "%[^=] = %[^;]", buffer, buffer1);
ret = vsscanf_wrapper(tests[i], "test=value\xda", -1, "%[^=] = %[^;]", buffer, buffer1);
ok(ret == 2, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(!strcmp(buffer, "test"), "got wrong string '%s' for flags %#x\n", buffer, tests[i]);
ok(!strcmp(buffer1, "value\xda"), "got wrong string '%s' for flags %#x\n", buffer1, tests[i]);
ret = vsscanf_wrapper(tests[i], "0.1", 3, "%lf%n", &double_res, &count);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(double_res == 0.1, "got wrong double %.16e for flags %#x\n", double_res, tests[i]);
ok(count == 3, "got wrong count %d for flags %#x\n", count, tests[i]);
ret = vsscanf_wrapper(tests[i], "a", -1, "%lf%n", &double_res, &count);
ok(ret == 0, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ret = vsscanf_wrapper(tests[i], "aa", -1, "%c%lf%n", &c, &double_res, &count);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ret = vsscanf_wrapper(tests[i], "a0e", -1, "%c%lf%n", &c, &double_res, &count);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ret = vsscanf_wrapper(tests[i], "0.", -1, "%lf%n", &double_res, &count);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(double_res == 0, "got wrong double %.16e for flags %#x\n", double_res, tests[i]);
ok(count == 2, "got wrong count %d for flags %#x\n", count, tests[i]);
ret = vsscanf_wrapper(tests[i], "0.", 2, "%lf%n", &double_res, &count);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(double_res == 0, "got wrong double %.16e for flags %#x\n", double_res, tests[i]);
ok(count == 2, "got wrong count %d for flags %#x\n", count, tests[i]);
ret = vsscanf_wrapper(tests[i], "1e", -1, "%lf%n", &double_res, &count);
ok(ret == -1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ret = vsscanf_wrapper(tests[i], "1e ", 2, "%lf%n", &double_res, &count);
ok(ret == -1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ret = vsscanf_wrapper(tests[i], "1e+", -1, "%lf%n", &double_res, &count);
ok(ret == -1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ret = vsscanf_wrapper(tests[i], "inf", -1, "%lf%n", &double_res, &count);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(double_res == INFINITY, "got wrong double %.16e for flags %#x\n", double_res, tests[i]);
ok(count == 3, "got wrong count %d for flags %#x\n", count, tests[i]);
ret = vsscanf_wrapper(tests[i], "infa", -1, "%lf%n", &double_res, &count);
ok(ret == 1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
ok(double_res == INFINITY, "got wrong double %.16e for flags %#x\n", double_res, tests[i]);
ok(count == 3, "got wrong count %d for flags %#x\n", count, tests[i]);
ret = vsscanf_wrapper(tests[i], "infi", -1, "%lf%n", &double_res, &count);
ok(ret == -1, "sscanf returned %d for flags %#x\n", ret, tests[i]);
}
}