From 9b2a78fa52249ab481493550490aa5f37872dcf6 Mon Sep 17 00:00:00 2001 From: aqua Date: Sat, 10 Dec 2022 20:56:57 +0200 Subject: Rewrite drivers/uart and drivers/vga in cpp --- lib/stdio/vfprintf.c | 54 ---------------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 lib/stdio/vfprintf.c (limited to 'lib/stdio/vfprintf.c') diff --git a/lib/stdio/vfprintf.c b/lib/stdio/vfprintf.c deleted file mode 100644 index d24e43e..0000000 --- a/lib/stdio/vfprintf.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include - -static char buffer[3 * sizeof(int) + 2]; - -int -vfprintf(FILE *restrict stream, const char *restrict format, va_list params) -{ - int written = 0; - - int s = 0; - int l = 0; - for (int i = 0; format[i] != '\0'; ++i) { - if (format[i] == '%') { - written += stream->puts(stream, &format[s], l); - s = i + 2; - ++i; - - switch (format[i]) { - case 's': { - const char *arg = va_arg(params, const char *); - written += stream->puts(stream, arg, -1); - } break; - case 'c': { - const int arg = va_arg(params, int); - stream->putc(stream, arg); - ++written; - } break; - case 'd': { - const char *arg = itoa(buffer, va_arg(params, int), 10); - written += stream->puts(stream, arg, -1); - } break; - case 'u': { - const char *arg = utoa(buffer, va_arg(params, unsigned int), 10); - written += stream->puts(stream, arg, -1); - } break; - case 'x': { - const char *arg = utoa(buffer, va_arg(params, unsigned int), 16); - written += stream->puts(stream, arg, -1); - } break; - } - - l = 0; - } - - else - ++l; - } - - if (l > 0) { written += stream->puts(stream, &format[s], l); } - - stream->flush(stream); - return written; -} -- cgit v1.2.1