mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 20:42:21 +00:00
LibC: Implement f{get,put}ws()
This commit is contained in:
parent
bd9a22e7e7
commit
db7a6d6e74
Notes:
sideshowbarker
2024-07-17 22:55:25 +09:00
Author: https://github.com/alimpfard
Commit: db7a6d6e74
Pull-request: https://github.com/SerenityOS/serenity/pull/11324
Reviewed-by: https://github.com/BertalanD
4 changed files with 48 additions and 13 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue