diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2010-04-06 14:46:31 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2010-04-06 14:46:31 +0000 |
commit | 65ee447a029b37484a22272082fbdf876915c7ec (patch) | |
tree | 1146d26c804c8f5fc30b073ea9f82760d173eb81 /newlib/libc/stdlib/btowc.c | |
parent | 44ac55bcb6e087e6e181a4d893e5ede15e977a04 (diff) | |
download | newlib-65ee447a029b37484a22272082fbdf876915c7ec.zip newlib-65ee447a029b37484a22272082fbdf876915c7ec.tar.gz newlib-65ee447a029b37484a22272082fbdf876915c7ec.tar.bz2 |
* libc/stdlib/btowc.c (btowc): Reorganize EOF check. Fix incorrect
return value if input byte is ASCII NUL.
Diffstat (limited to 'newlib/libc/stdlib/btowc.c')
-rw-r--r-- | newlib/libc/stdlib/btowc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/newlib/libc/stdlib/btowc.c b/newlib/libc/stdlib/btowc.c index f5ef462..ec6c291 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; } |