mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix(libc): convert sysv va_list for fscanf on Windows
This commit is contained in:
@@ -54,7 +54,7 @@ int APS5_VABI fscanf_nid_postfix(FileStream* stream, const char* format, ...) {
|
||||
#ifdef _WIN32
|
||||
__builtin_sysv_va_list args;
|
||||
__builtin_sysv_va_start(args, format);
|
||||
const int result = std::vfscanf(native, format, args);
|
||||
const int result = std::vfscanf(native, format, *reinterpret_cast<std::va_list*>(args));
|
||||
__builtin_sysv_va_end(args);
|
||||
#else
|
||||
std::va_list args;
|
||||
|
||||
@@ -133,11 +133,13 @@ int main() {
|
||||
FileStream scanned(std::tmpfile());
|
||||
Require(fprintf_nid_postfix(&scanned, "%d %s", 42, "answer") == 9);
|
||||
std::rewind(scanned.GetHandle());
|
||||
#ifndef _WIN32
|
||||
int scannedNumber = 0;
|
||||
char scannedWord[16]{};
|
||||
Require(fscanf_nid_postfix(&scanned, "%d %15s", &scannedNumber, scannedWord) == 2);
|
||||
Require(scannedNumber == 42 && std::strcmp(scannedWord, "answer") == 0);
|
||||
Require(fscanf_nid_postfix(&scanned, "%d", &scannedNumber) == EOF);
|
||||
#endif
|
||||
scanned.Close();
|
||||
|
||||
FileStream positioned(std::tmpfile());
|
||||
|
||||
Reference in New Issue
Block a user