diff --git a/src/header/stdio/scanf.rs b/src/header/stdio/scanf.rs index f7ff17f689..f895b57c03 100644 --- a/src/header/stdio/scanf.rs +++ b/src/header/stdio/scanf.rs @@ -180,6 +180,7 @@ pub unsafe fn inner_scanf( } } + let pointer = c == 'p'; // Pointers aren't automatic, but we do want to parse "0x" let auto = c == 'i' || pointer; @@ -191,6 +192,7 @@ pub unsafe fn inner_scanf( _ => 10, }; + let mut n = String::new(); let mut dot = false; @@ -364,6 +366,7 @@ pub unsafe fn inner_scanf( if let Some(ptr) = ptr { *ptr = 0; matched += 1; + read!(); } }; } diff --git a/tests/expected/bins_dynamic/wchar/wscanf.stdout b/tests/expected/bins_dynamic/wchar/wscanf.stdout index 9fa48dd253..57f4cd5992 100644 Binary files a/tests/expected/bins_dynamic/wchar/wscanf.stdout and b/tests/expected/bins_dynamic/wchar/wscanf.stdout differ diff --git a/tests/expected/bins_static/wchar/wscanf.stdout b/tests/expected/bins_static/wchar/wscanf.stdout index 9fa48dd253..57f4cd5992 100644 Binary files a/tests/expected/bins_static/wchar/wscanf.stdout and b/tests/expected/bins_static/wchar/wscanf.stdout differ diff --git a/tests/wchar/wscanf.c b/tests/wchar/wscanf.c index c06d4eab8c..31da201dcf 100644 --- a/tests/wchar/wscanf.c +++ b/tests/wchar/wscanf.c @@ -56,6 +56,7 @@ int main () test(L"%lc %f", L"π 3.14", &p, &p.wc, &p.fa); test(L"test: %2i%n", L"test: 0xFF", &p, &p.ia, &p.ib); test(L"hello world%%", L"hello world%", &p); + test(L"hello %5ls %d", L"hello world 42", &p, &p.wstring1, &p.ia); test(L"h%1[ae]ll%1[^a] wor%1[^\n]%[d]", L"hello world", &p, &p.string1, &p.string2, &p.string3, &p.string4); test(L"h%1[ae]ll%1[^a] wor%1[^\n]%[d]", L"halle worfdddddd", &p, &p.string1, &p.string2, &p.string3, &p.string4); test(L"%[^a]%[b]", L"testbbbb", &p, &p.string1, &p.string2); @@ -98,3 +99,14 @@ int main () return 0; } + +/* + wchar_t world[6]; + int value; + int ret = swscanf(L"hello world 42", L"hello %5ls %d", world, &value); + // int ret = swscanf(L"42", L"%d", &value); + + // wprintf(L"swscanf gave '%ls' instead of '%ls'", world, L"world"); + printf("swscanf gave '%d' instead of %d", value, 42); + printf("ret %d\n", ret); +*/