提交 1ab59de8 编写于 作者: R Rich Felker

simplify some logic in scanf and remove redundant invalid-format check

上级 f18846dd
...@@ -169,32 +169,22 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap) ...@@ -169,32 +169,22 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap)
t = *p; t = *p;
switch (t) { /* C or S */
case 'C': if ((t&0x2f) == 3) {
if (width < 1) width = 1;
case 'S':
t |= 32; t |= 32;
size = SIZE_l; size = SIZE_l;
break; }
switch (t) {
case 'c': case 'c':
if (width < 1) width = 1; if (width < 1) width = 1;
case 'd': case 'i': case 'o': case 'u': case 'x': case '[':
case 'a': case 'e': case 'f': case 'g':
case 'A': case 'E': case 'F': case 'G': case 'X':
case '[': case 's':
case 'p': case 'n':
break; break;
default: case 'n':
goto fmt_fail;
}
if (t == 'n') {
store_int(dest, size, pos); store_int(dest, size, pos);
/* do not increment match count, etc! */ /* do not increment match count, etc! */
continue; continue;
} default:
if (t != '[' && (t|32) != 'c') {
shlim(f, 0); shlim(f, 0);
while (isspace(shgetc(f))); while (isspace(shgetc(f)));
shunget(f); shunget(f);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册