Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdlib / btowc.c
blob7605ce6b608cf9fc0adcd20b90535f57c0cdf332
1 #include <wchar.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <reent.h>
5 #include <string.h>
6 #include "local.h"
8 wint_t
9 btowc (int c)
11 mbstate_t mbs;
12 int retval = 0;
13 wchar_t pwc;
14 unsigned char b;
16 if (c == EOF)
17 return WEOF;
19 b = (unsigned char)c;
21 /* Put mbs in initial state. */
22 memset (&mbs, '\0', sizeof (mbs));
24 _REENT_CHECK_MISC(_REENT);
26 retval = __MBTOWC (_REENT, &pwc, (const char *) &b, 1, &mbs);
28 if (retval != 0 && retval != 1)
29 return WEOF;
31 return (wint_t)pwc;