fixed fprintf

This commit is contained in:
georgemoralis 2024-03-13 20:18:17 +02:00
parent 751fca0616
commit 7764f13cce
2 changed files with 13 additions and 3 deletions

View file

@ -54,10 +54,12 @@ int PS4_SYSV_ABI ps4_fprintf(FILE* file, VA_ARGS) {
if (fd == 1 || fd == 2) { // output stdout and stderr to console
VA_CTX(ctx);
return printf_ctx(&ctx);
} else {
VA_CTX(ctx);
char buf[256];
fprintf_ctx(&ctx,buf);
return fprintf(file,"%s", buf);
}
UNREACHABLE_MSG("Unimplemented fprintf case");
return 0;
}
int PS4_SYSV_ABI ps4_vsnprintf(char* s, size_t n, const char* format, VaList* arg) {

View file

@ -736,6 +736,14 @@ static int printf_ctx(VaCtx* ctx) {
return result;
}
static int fprintf_ctx(VaCtx* ctx,char *buf) {
const char* format = vaArgPtr<const char>(&ctx->va_list);
char buffer[256];
int result = _vsnprintf(_out_buffer, buffer, format, &ctx->va_list);
strcpy(buf, buffer);
return result;
}
static int vsnprintf_ctx(char* s, size_t n, const char* format, VaList* arg) {
char buffer[n];
int result = _vsnprintf(_out_buffer, buffer, format, arg);