1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:17:35 +00:00

LibC: Implement f{get,put}ws()

This commit is contained in:
Ali Mohammad Pur 2021-12-19 22:22:31 +03:30 committed by Ali Mohammad Pur
parent bd9a22e7e7
commit db7a6d6e74
4 changed files with 48 additions and 13 deletions

View file

@ -98,4 +98,24 @@ wint_t putwchar(wchar_t wc)
{
return fputwc(wc, stdout);
}
wchar_t* fgetws(wchar_t* __restrict buffer, int size, FILE* __restrict stream)
{
VERIFY(stream);
ScopedFileLock lock(stream);
bool ok = stream->gets(bit_cast<u32*>(buffer), size);
return ok ? buffer : nullptr;
}
int fputws(wchar_t const* __restrict ws, FILE* __restrict stream)
{
VERIFY(stream);
ScopedFileLock lock(stream);
int size = 0;
for (auto const* p = ws; *p != 0; ++p, ++size) {
if (putwc(*p, stream) == WEOF)
return WEOF;
}
return size;
}
}