Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdlib / wctob.c
blob61365a178a151c5195e16bba5f5431f15d4aba02
1 #include <reent.h>
2 #include <wchar.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <limits.h>
6 #include "local.h"
8 int
9 wctob (wint_t wc)
11 struct _reent *reent;
12 mbstate_t mbs;
13 unsigned char pmb[MB_LEN_MAX];
15 if (wc == WEOF)
16 return EOF;
18 /* Put mbs in initial state. */
19 memset (&mbs, '\0', sizeof (mbs));
21 reent = _REENT;
22 _REENT_CHECK_MISC(reent);
24 return __WCTOMB (reent, (char *) pmb, wc, &mbs) == 1 ? (int) pmb[0] : EOF;