repo.or.cz
/
musl.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
riscv32: add dlsym
[musl.git]
/
src
/
stdio
/
fgetws.c
blob
195cb4355a14b10b05b0b50cf293456b5b7b4f75
1
#include
"stdio_impl.h"
2
#include <wchar.h>
3
4
wint_t
__fgetwc_unlocked
(
FILE
*);
5
6
wchar_t
*
fgetws
(
wchar_t
*
restrict s
,
int
n
,
FILE
*
restrict f
)
7
{
8
wchar_t
*
p
=
s
;
9
10
if
(!
n
--)
return
s
;
11
12
FLOCK
(
f
);
13
14
for
(;
n
;
n
--) {
15
wint_t
c
=
__fgetwc_unlocked
(
f
);
16
if
(
c
==
WEOF
)
break
;
17
*
p
++ =
c
;
18
if
(
c
==
'
\n
'
)
break
;
19
}
20
*
p
=
0
;
21
if
(
ferror
(
f
))
p
=
s
;
22
23
FUNLOCK
(
f
);
24
25
return
(
p
==
s
) ?
NULL
:
s
;
26
}
27
28
weak_alias
(
fgetws
,
fgetws_unlocked
);