From 021a8e00fcb902c13bbef28daa913aee6467f890 Mon Sep 17 00:00:00 2001 From: Mateusz Tabaka <tab.debugteam@gmail.com> Date: Sun, 3 Jan 2021 11:50:47 +0100 Subject: [PATCH] Fix stdio/scanf test case inner_scanf prematurely exited before parsing collected string --- src/header/stdio/scanf.rs | 2 +- tests/stdio/scanf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/header/stdio/scanf.rs b/src/header/stdio/scanf.rs index 8a88a316..4a8b63c9 100644 --- a/src/header/stdio/scanf.rs +++ b/src/header/stdio/scanf.rs @@ -222,7 +222,7 @@ unsafe fn inner_scanf( r.commit(); width = width.map(|w| w - 1); if width.map(|w| w > 0).unwrap_or(true) && !read!() { - return Ok(matched); + break; } } diff --git a/tests/stdio/scanf.c b/tests/stdio/scanf.c index 0bf195b3..9102cb82 100644 --- a/tests/stdio/scanf.c +++ b/tests/stdio/scanf.c @@ -33,7 +33,7 @@ void test(char* fmt_in, char* input, struct params *p, ...) { int main(void) { struct params p = { .c = 'a' }; - test("%hhd %d", "12 345", &p, &p.sa, &p.ia); + test("%hd %d", "12 345", &p, &p.sa, &p.ia); test("%x %i %i", "12 0x345 010", &p, &p.ia, &p.ib, &p.ic); test("%f.%lf", "0.1.0.2", &p, &p.fa, &p.da); test("%p", "0xABCDEF", &p, &p.ptr); -- GitLab