fix mismatched signatures for strtod_l family
[musl] / src / stdio / fgetwc.c
index 07fb6d7..aa10b81 100644 (file)
@@ -10,7 +10,7 @@ static wint_t __fgetwc_unlocked_internal(FILE *f)
        size_t l;
 
        /* Convert character from buffer if possible */
-       if (f->rpos < f->rend) {
+       if (f->rpos != f->rend) {
                l = mbtowc(&wc, (void *)f->rpos, f->rend - f->rpos);
                if (l+1 >= 1) {
                        f->rpos += l + !l; /* l==0 means 1 byte, null */
@@ -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;