source: trunk/libs/newlib/src/newlib/libc/stdlib/btowc.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: 512 bytes
Line 
1#include <wchar.h>
2#include <stdlib.h>
3#include <stdio.h>
4#include <reent.h>
5#include <string.h>
6#include "local.h"
7
8wint_t
9btowc (int c)
10{
11  mbstate_t mbs;
12  int retval = 0;
13  wchar_t pwc;
14  unsigned char b;
15
16  if (c == EOF)
17    return WEOF;
18
19  b = (unsigned char)c;
20
21  /* Put mbs in initial state. */
22  memset (&mbs, '\0', sizeof (mbs));
23
24  _REENT_CHECK_MISC(_REENT);
25
26  retval = __MBTOWC (_REENT, &pwc, (const char *) &b, 1, &mbs);
27
28  if (retval != 0 && retval != 1)
29    return WEOF;
30
31  return (wint_t)pwc;
32}
Note: See TracBrowser for help on using the repository browser.