repo.or.cz
/
newlib-cygwin.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git]
/
newlib
/
libc
/
stdlib
/
btowc.c
blob
7605ce6b608cf9fc0adcd20b90535f57c0cdf332
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
, &
mbs
);
27
28
if
(
retval
!=
0
&&
retval
!=
1
)
29
return
WEOF
;
30
31
return
(
wint_t
)
pwc
;
32
}