source: trunk/libs/newlib/src/newlib/libc/stdlib/wctob.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 449 bytes
Line 
1#include <reent.h>
2#include <wchar.h>
3#include <stdio.h>
4#include <string.h>
5#include <limits.h>
6#include "local.h"
7
8int
9wctob (wint_t wc)
10{
11  struct _reent *reent;
12  mbstate_t mbs;
13  unsigned char pmb[MB_LEN_MAX];
14
15  if (wc == WEOF)
16    return EOF;
17
18  /* Put mbs in initial state. */
19  memset (&mbs, '\0', sizeof (mbs));
20
21  reent = _REENT;
22  _REENT_CHECK_MISC(reent);
23
24  return __WCTOMB (reent, (char *) pmb, wc, &mbs) == 1 ? (int) pmb[0] : EOF;
25}
Note: See TracBrowser for help on using the repository browser.