msvcrt: Fix scanf format "%i" base detection.
This commit is contained in:
parent
803f3bd0a9
commit
4e5c51a6ee
@ -169,7 +169,7 @@ _FUNCTION_ {
|
|||||||
base = 10;
|
base = 10;
|
||||||
goto number;
|
goto number;
|
||||||
case 'i': /* generic integer */
|
case 'i': /* generic integer */
|
||||||
base = 10;
|
base = 0;
|
||||||
number: {
|
number: {
|
||||||
/* read an integer */
|
/* read an integer */
|
||||||
ULONGLONG cur = 0;
|
ULONGLONG cur = 0;
|
||||||
@ -200,6 +200,9 @@ _FUNCTION_ {
|
|||||||
} else if (base==0)
|
} else if (base==0)
|
||||||
base = 8;
|
base = 8;
|
||||||
}
|
}
|
||||||
|
/* format %i without indication of base */
|
||||||
|
if (base==0)
|
||||||
|
base = 10;
|
||||||
/* throw away leading zeros */
|
/* throw away leading zeros */
|
||||||
while (width!=0 && nch=='0') {
|
while (width!=0 && nch=='0') {
|
||||||
nch = _GETC_(file);
|
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(ret == 1, "Wrong number of arguments read: %d (expected 1)\n", ret);
|
||||||
ok(result == -1, "Read %d, expected -1\n", result);
|
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 */
|
/* %o */
|
||||||
result = 0;
|
result = 0;
|
||||||
ret = sscanf("-1", "%o", &result);
|
ret = sscanf("-1", "%o", &result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user