libc: make fprintf actually write to the chosen file
Also, printf now is kind of an alias for fprintf(stdout,...), as it should be.
This commit is contained in:
parent
2f46e46aa4
commit
0f47f59364
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user