From da3ff538d69b62dbb5503fa933c36932ad3e268e Mon Sep 17 00:00:00 2001 From: nicoan Date: Wed, 15 Apr 2026 14:18:20 -0300 Subject: [PATCH] WIP: fixing regressions --- src/header/stdio/scanf.rs | 3 +++ .../expected/bins_dynamic/wchar/wscanf.stdout | Bin 3960 -> 4185 bytes .../expected/bins_static/wchar/wscanf.stdout | Bin 3960 -> 4185 bytes tests/wchar/wscanf.c | 12 ++++++++++++ 4 files changed, 15 insertions(+) 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 9fa48dd2538cb4a3f3ed9fee1e04a1a651a21dd4..57f4cd5992a9f503b2b502cef4202a4135641785 100644 GIT binary patch delta 130 zcmew%cT-_QGsk3YHbEv6qsiyk`&i5Ki*iyX7qX~N_T+>L#!mjkVSr5{X7YAUGbD-g e%upRMlP!2`;Sv@Qv%!LsCvtm1xtlF`9GC$o^eSHf delta 80 zcmcbq@I!7xGsolrPQl4%+2bZ3;53*V!=Vo4$4>6%G6VC^GlS$~C&zHx0{Iqjb|H@! LjJ-LGmzfy=s>K`t diff --git a/tests/expected/bins_static/wchar/wscanf.stdout b/tests/expected/bins_static/wchar/wscanf.stdout index 9fa48dd2538cb4a3f3ed9fee1e04a1a651a21dd4..57f4cd5992a9f503b2b502cef4202a4135641785 100644 GIT binary patch delta 130 zcmew%cT-_QGsk3YHbEv6qsiyk`&i5Ki*iyX7qX~N_T+>L#!mjkVSr5{X7YAUGbD-g e%upRMlP!2`;Sv@Qv%!LsCvtm1xtlF`9GC$o^eSHf delta 80 zcmcbq@I!7xGsolrPQl4%+2bZ3;53*V!=Vo4$4>6%G6VC^GlS$~C&zHx0{Iqjb|H@! LjJ-LGmzfy=s>K`t 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); +*/