diff --git a/libs/libc/src/printf.cpp b/libs/libc/src/printf.cpp index 86b418b3..278c5b7f 100644 --- a/libs/libc/src/printf.cpp +++ b/libs/libc/src/printf.cpp @@ -306,8 +306,7 @@ extern "C" { int vprintf(const char* format, va_list ap) { - return internal_printf( - format, [](const char* s) { syscall(SYS_write, s, strlen(s)); }, -1, ap); + return vfprintf(stdout, format, ap); } int vsprintf(char* str, const char* format, va_list ap) @@ -352,23 +351,23 @@ extern "C" { va_list ap; va_start(ap, format); - int written = vprintf(format, ap); + int written = vfprintf(stdout, format, ap); va_end(ap); return written; } - int fprintf(FILE*, const char* format, ...) // FIXME: Make fprintf print to the selected file instead of stdout. + int fprintf(FILE* stream, const char* format, ...) { va_list ap; va_start(ap, format); - int written = vprintf(format, ap); + int written = vfprintf(stream, format, ap); va_end(ap); return written; } - int vfprintf(FILE*, const char* format, - va_list ap) // FIXME: Make vfprintf print to the selected file instead of stdout. + int vfprintf(FILE* stream, const char* format, va_list ap) { - return vprintf(format, ap); + return internal_printf( + format, [&](const char* s) { fwrite(s, strlen(s), 1, stream); }, -1, ap); } } \ No newline at end of file