Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  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.  
  8. wint_t
  9. btowc (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,
  27.                      __locale_charset (), &mbs);
  28.  
  29.   if (retval != 0 && retval != 1)
  30.     return WEOF;
  31.  
  32.   return (wint_t)pwc;
  33. }
  34.