Files
Alexej Szpevák 675ff30898 feat(libc): scan 16-bit wide conversions in the sscanf family on Linux
sscanf, vsscanf, sscanf_s and vsscanf_s threw on Linux for %ls, %lc, %l[, %S and %C, because glibc stores a 32-bit wchar_t per character into the guest's 16-bit buffer. ScanGuest, the per-directive scanner the _s forms already use, now scans those fields itself: the input is decoded as UTF-8, mirroring the narrow printf family's UTF-8 output, and each character is stored as one 16-bit unit, the width and the _s size counting characters; %ls skips leading white space and stops at the next, %l[ matches an ASCII scanset with ranges and negation, and a %lc field that meets the end of the input early keeps what it read, as FreeBSD's convert_wchar does. sscanf and vsscanf route a format with a wide conversion through ScanGuest and keep the host path otherwise. The UTF-8 decoding and scanset matching live in ScanWideField.cpp, which throws for input that is not UTF-8, a character outside the BMP, a scanset member outside ASCII and positional arguments next to a wide conversion; wide conversions in fscanf still throw.
2026-10-19 22:30:07 +02:00

16 lines
370 B
C++

#ifndef CORE_LIBS_PRX_LIBC_INCLUDE_SCANWIDEFIELD_HPP
#define CORE_LIBS_PRX_LIBC_INCLUDE_SCANWIDEFIELD_HPP
#include <cstddef>
#include <string>
namespace LibcDetail {
std::size_t ReadWideScanCharacter(const char* text, char32_t* point);
bool InWideScanset(const std::string& specifier, char32_t point);
void RequireNoPositionalWideScan(const char* format);
}
#endif