summaryrefslogtreecommitdiff
path: root/src/stdio/vfwscanf.c
diff options
context:
space:
mode:
authorBartosz Brachaczek <b.brachaczek@gmail.com>2017-07-09 23:00:18 +0200
committerRich Felker <dalias@aerifal.cx>2017-09-04 16:59:38 -0400
commit9255dad97e7bfd4165d1aa0f93f2aae321a7a4d8 (patch)
treec8bb838f61cc2a6141199893fe49c92103e3a81d /src/stdio/vfwscanf.c
parent51bdcdc424bd7169c8cccdc2de7cad17f5ea0f70 (diff)
downloadmusl-9255dad97e7bfd4165d1aa0f93f2aae321a7a4d8.tar.gz
handle whitespace before %% in scanf
this is mandated by C and POSIX standards and is in accordance with glibc behavior.
Diffstat (limited to 'src/stdio/vfwscanf.c')
-rw-r--r--src/stdio/vfwscanf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c
index 1ebc5cef..a7cd0923 100644
--- a/src/stdio/vfwscanf.c
+++ b/src/stdio/vfwscanf.c
@@ -117,8 +117,12 @@ int vfwscanf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap)
continue;
}
if (*p != '%' || p[1] == '%') {
- p += *p=='%';
- c = getwc(f);
+ if (*p == '%') {
+ p++;
+ while (iswspace((c=getwc(f)))) pos++;
+ } else {
+ c = getwc(f);
+ }
if (c!=*p) {
ungetwc(c, f);
if (c<0) goto input_fail;