浏览代码

fix scanf bug reading literals after width-limited field

the field width limit was not being cleared before reading the
literal, causing spurious failures in scanf in cases like "%2d:"
scanning "00:".
Rich Felker 12 年之前
父节点
当前提交
31eaad4796
共有 1 个文件被更改,包括 1 次插入0 次删除
  1. 1 0
      src/stdio/vfscanf.c

+ 1 - 0
src/stdio/vfscanf.c

@@ -103,6 +103,7 @@ int vfscanf(FILE *f, const char *fmt, va_list ap)
 		}
 		if (*p != '%' || p[1] == '%') {
 			p += *p=='%';
+			shlim(f, 0);
 			c = shgetc(f);
 			if (c!=*p) {
 				shunget(f);