internal_vprintf was wrong

This commit is contained in:
georgemoralis 2025-02-21 09:04:15 +02:00
parent 745cdd89fd
commit a4a8bf721b

View File

@ -152,35 +152,9 @@ s32 PS4_SYSV_ABI internal_vfwscanf_s() {
return ORBIS_OK; return ORBIS_OK;
} }
s32 PS4_SYSV_ABI internal_vprintf(const char* format, va_list args) { s32 PS4_SYSV_ABI internal_vprintf() {
// Copy the va_list because vsnprintf consumes it LOG_ERROR(Lib_LibcInternal, "(STUBBED) called");
va_list args_copy; return ORBIS_OK;
va_copy(args_copy, args);
// Calculate the required buffer size
int size = std::vsnprintf(nullptr, 0, format, args_copy);
va_end(args_copy);
if (size < 0) {
// Handle vsnprintf error
LOG_ERROR(Lib_LibcInternal, "vsnprintf failed to calculate size");
return size;
}
// Create a string with the required size
std::string buffer(size, '\0');
// Format the string into the buffer
int result =
std::vsnprintf(buffer.data(), buffer.size() + 1, format, args); // +1 for null terminator
if (result >= 0) {
// Log the formatted result
LOG_INFO(Lib_LibcInternal, "{}", buffer);
} else {
LOG_ERROR(Lib_LibcInternal, "vsnprintf failed during formatting");
}
return result;
} }
s32 PS4_SYSV_ABI internal_vprintf_s() { s32 PS4_SYSV_ABI internal_vprintf_s() {