Welcome to mirror list, hosted at ThFree Co, Russian Federation.

btowc.c « stdlib « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a1ea920efc1f256b378b6308a730be01b5db0355 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <reent.h>

wint_t
btowc (int c)
{
  mbstate_t mbs;
  int retval = 0;
  wchar_t pwc;
  unsigned char b;

  b = (unsigned char)c;

  /* Put mbs in initial state. */
  memset (&mbs, '\0', sizeof (mbs));

  _REENT_CHECK_MISC(_REENT);

  retval = _mbtowc_r (_REENT, &pwc, &b, 1, &mbs);

  if (c == EOF || retval != 1)
    return WEOF;
  else
    return (wint_t)pwc;
}