mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 18:24:45 -05:00
LibC: Implement mbrtowc closer to POSIX
This commit is contained in:
parent
e7f99edefa
commit
4ef3ed4ba3
Notes:
sideshowbarker
2024-07-18 03:09:59 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/4ef3ed4ba3c Pull-request: https://github.com/SerenityOS/serenity/pull/10170 Reviewed-by: https://github.com/BertalanD ✅ Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/IdanHo Reviewed-by: https://github.com/kleinesfilmroellchen
1 changed files with 5 additions and 9 deletions
|
@ -209,16 +209,11 @@ size_t mbrtowc(wchar_t* pwc, const char* s, size_t n, mbstate_t* state)
|
|||
state = &_anonymous_state;
|
||||
}
|
||||
|
||||
// If s is nullptr, check if the state contains a complete multibyte character
|
||||
// s being a null pointer is a shorthand for reading a single null byte.
|
||||
if (s == nullptr) {
|
||||
if (mbstate_expected_bytes(state) == mbstate->stored_bytes) {
|
||||
*state = {};
|
||||
return 0;
|
||||
} else {
|
||||
*state = {};
|
||||
errno = EILSEQ;
|
||||
return -1;
|
||||
}
|
||||
pwc = nullptr;
|
||||
s = "";
|
||||
n = 1;
|
||||
}
|
||||
|
||||
// Stop early if we can't read anything
|
||||
|
@ -284,6 +279,7 @@ size_t mbrtowc(wchar_t* pwc, const char* s, size_t n, mbstate_t* state)
|
|||
state->stored_bytes = 0;
|
||||
|
||||
if (codepoint == 0) {
|
||||
*state = {};
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue