mirror of
https://github.com/fluencelabs/musl
synced 2025-07-03 16:41:59 +00:00
fix failure to distinguish input/match failure in wide %[ scanf
this also includes a related fix for vswscanf's read function, which was returning a spurious (uninitialized) character for empty strings.
This commit is contained in:
@ -264,7 +264,9 @@ int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap)
|
|||||||
}
|
}
|
||||||
if (width) ungetwc(c, f);
|
if (width) ungetwc(c, f);
|
||||||
|
|
||||||
if (!gotmatch) goto match_fail;
|
if (!gotmatch)
|
||||||
|
if (c>=0) goto match_fail;
|
||||||
|
else goto input_fail;
|
||||||
|
|
||||||
if (*p==']') p++;
|
if (*p==']') p++;
|
||||||
while (*p!=']') {
|
while (*p!=']') {
|
||||||
|
@ -17,7 +17,7 @@ static size_t wstring_read(FILE *f, unsigned char *buf, size_t len)
|
|||||||
f->rend = f->buf + k;
|
f->rend = f->buf + k;
|
||||||
f->cookie = (void *)src;
|
f->cookie = (void *)src;
|
||||||
|
|
||||||
if (!len) return 0;
|
if (!len || !k) return 0;
|
||||||
|
|
||||||
*buf = *f->rpos++;
|
*buf = *f->rpos++;
|
||||||
return 1;
|
return 1;
|
||||||
|
Reference in New Issue
Block a user