summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-04-17 23:35:49 -0400
committerRich Felker <dalias@aerifal.cx>2012-04-17 23:35:49 -0400
commitbdeb184c3d08ea5017e1570e0f0431e9d7fd02fd (patch)
treecbf4d5c9531c38a3a90ed01760119242d8916169
parenta12aa2918535fd370419bd24b50a33974091c5a7 (diff)
downloadmusl-bdeb184c3d08ea5017e1570e0f0431e9d7fd02fd.tar.gz
fix wide scanf's handling of input failure on %c, and simplify %[
-rw-r--r--src/stdio/vfwscanf.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c
index dbba8652..de74fe0c 100644
--- a/src/stdio/vfwscanf.c
+++ b/src/stdio/vfwscanf.c
@@ -181,8 +181,11 @@ int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap)
/* Transform ls,lc -> S,C */
if (size==SIZE_l && (t&15)==3) t&=~32;
- if (t != 'n' && t != '[' && (t|32) != 'c') {
- while (iswspace((c=getwc(f)))) pos++;
+ if (t != 'n') {
+ if (t != '[' && (t|32) != 'c')
+ while (iswspace((c=getwc(f)))) pos++;
+ else
+ c=getwc(f);
if (c < 0) goto input_fail;
ungetwc(c, f);
}
@@ -264,9 +267,7 @@ int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap)
}
if (width) ungetwc(c, f);
- if (!gotmatch)
- if (c>=0) goto match_fail;
- else goto input_fail;
+ if (!gotmatch) goto match_fail;
if (*p==']') p++;
while (*p!=']') {