Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdlib')
-rw-r--r--newlib/libc/stdlib/btowc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/newlib/libc/stdlib/btowc.c b/newlib/libc/stdlib/btowc.c
index f5ef4624a..ec6c29152 100644
--- a/newlib/libc/stdlib/btowc.c
+++ b/newlib/libc/stdlib/btowc.c
@@ -13,6 +13,9 @@ btowc (int c)
wchar_t pwc;
unsigned char b;
+ if (c == EOF)
+ return WEOF;
+
b = (unsigned char)c;
/* Put mbs in initial state. */
@@ -22,8 +25,8 @@ btowc (int c)
retval = __mbtowc (_REENT, &pwc, &b, 1, __locale_charset (), &mbs);
- if (c == EOF || retval != 1)
+ if (retval != 0 && retval != 1)
return WEOF;
- else
- return (wint_t)pwc;
+
+ return (wint_t)pwc;
}