summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2019-05-05 22:50:57 -0400
committerRich Felker <dalias@aerifal.cx>2019-05-05 22:50:57 -0400
commit511d70738bce11a67219d0132ce725c323d00e4e (patch)
tree7b457530e14ffe5a339cf45ac6846b292026ff9c
parentd02e72ad51ea3b06cb168d872e3e5c126bb3df9d (diff)
downloadmusl-511d70738bce11a67219d0132ce725c323d00e4e.tar.gz
make fgetwc set error indicator for stream on encoding errors
this is a requirement in POSIX that's omitted, and seemed potentially non-conforming, in the C standard. as such it was omitted here. however, as part of Austin Group issue #1170, the discrepancy was raised with WG14 and determined to be unintended; future versions of the C standard will require the error indicator to be set, as POSIX does.
-rw-r--r--src/stdio/fgetwc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/stdio/fgetwc.c b/src/stdio/fgetwc.c
index 0801e28f..aa10b818 100644
--- a/src/stdio/fgetwc.c
+++ b/src/stdio/fgetwc.c
@@ -25,12 +25,18 @@ static wint_t __fgetwc_unlocked_internal(FILE *f)
do {
b = c = getc_unlocked(f);
if (c < 0) {
- if (!first) errno = EILSEQ;
+ if (!first) {
+ f->flags |= F_ERR;
+ errno = EILSEQ;
+ }
return WEOF;
}
l = mbrtowc(&wc, (void *)&b, 1, &st);
if (l == -1) {
- if (!first) ungetc(b, f);
+ if (!first) {
+ f->flags |= F_ERR;
+ ungetc(b, f);
+ }
return WEOF;
}
first = 0;