libroot_debug: Merge guarded heap into libroot_debug.
[haiku.git] / src / system / libroot / posix / wchar / btowc.c
blob4d99e42da31a29cd6d03388b0fbc803cc9b2abde
1 /*
2 ** Copyright 2011, Oliver Tappe, zooey@hirschkaefer.de. All rights reserved.
3 ** Distributed under the terms of the Haiku License.
4 */
6 #include <wchar_private.h>
9 wint_t
10 __btowc(int c)
12 static mbstate_t internalMbState;
13 char character = (char)c;
14 wchar_t wc;
16 if (c == EOF)
17 return WEOF;
19 if (c == '\0')
20 return L'\0';
23 int byteCount = __mbrtowc(&wc, &character, 1, &internalMbState);
25 if (byteCount != 1)
26 return WEOF;
29 return wc;
33 B_DEFINE_WEAK_ALIAS(__btowc, btowc);