瀏覽代碼

Fix stdio/scanf test case

inner_scanf prematurely exited before parsing collected string
Mateusz Tabaka 4 年之前
父節點
當前提交
021a8e00fc
共有 2 個文件被更改,包括 2 次插入2 次删除
  1. 1 1
      src/header/stdio/scanf.rs
  2. 1 1
      tests/stdio/scanf.c

+ 1 - 1
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;
                         }
                     }
 

+ 1 - 1
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);