riscv32: add dlsym
[musl.git] / src / stdio / fgetws.c
blob195cb4355a14b10b05b0b50cf293456b5b7b4f75
1 #include "stdio_impl.h"
2 #include <wchar.h>
4 wint_t __fgetwc_unlocked(FILE *);
6 wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
8 wchar_t *p = s;
10 if (!n--) return s;
12 FLOCK(f);
14 for (; n; n--) {
15 wint_t c = __fgetwc_unlocked(f);
16 if (c == WEOF) break;
17 *p++ = c;
18 if (c == '\n') break;
20 *p = 0;
21 if (ferror(f)) p = s;
23 FUNLOCK(f);
25 return (p == s) ? NULL : s;
28 weak_alias(fgetws, fgetws_unlocked);