2017-04-11 21:13:36 +00:00
|
|
|
#include <reent.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include "local.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
wctob (wint_t wc)
|
|
|
|
{
|
2017-10-07 00:16:47 +00:00
|
|
|
struct _reent *reent;
|
2017-04-11 21:13:36 +00:00
|
|
|
mbstate_t mbs;
|
|
|
|
unsigned char pmb[MB_LEN_MAX];
|
|
|
|
|
|
|
|
if (wc == WEOF)
|
|
|
|
return EOF;
|
|
|
|
|
|
|
|
/* Put mbs in initial state. */
|
|
|
|
memset (&mbs, '\0', sizeof (mbs));
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
reent = _REENT;
|
|
|
|
_REENT_CHECK_MISC(reent);
|
2017-04-11 21:13:36 +00:00
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
return __WCTOMB (reent, (char *) pmb, wc, &mbs) == 1 ? (int) pmb[0] : EOF;
|
2017-04-11 21:13:36 +00:00
|
|
|
}
|