Commit 4e5c51a6 authored by Andrzej Popowski's avatar Andrzej Popowski Committed by Alexandre Julliard

msvcrt: Fix scanf format "%i" base detection.

parent 803f3bd0
......@@ -169,7 +169,7 @@ _FUNCTION_ {
base = 10;
goto number;
case 'i': /* generic integer */
base = 10;
base = 0;
number: {
/* read an integer */
ULONGLONG cur = 0;
......@@ -200,6 +200,9 @@ _FUNCTION_ {
} else if (base==0)
base = 8;
}
/* format %i without indication of base */
if (base==0)
base = 10;
/* throw away leading zeros */
while (width!=0 && nch=='0') {
nch = _GETC_(file);
......
......@@ -110,6 +110,18 @@ static void test_sscanf( void )
ok(ret == 1, "Wrong number of arguments read: %d (expected 1)\n", ret);
ok(result == -1, "Read %d, expected -1\n", result);
/* Check %i for octal and hexadecimal input */
result = 0;
strcpy(buffer,"017");
ret = sscanf(buffer, "%i", &result);
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
ok(result == 15, "Wrong number read\n");
result = 0;
strcpy(buffer,"0x17");
ret = sscanf(buffer, "%i", &result);
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
ok(result == 23, "Wrong number read\n");
/* %o */
result = 0;
ret = sscanf("-1", "%o", &result);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment