aboutsummaryrefslogtreecommitdiff
path: root/lib/stdio/vfprintf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdio/vfprintf.cpp')
-rw-r--r--lib/stdio/vfprintf.cpp54
1 files changed, 0 insertions, 54 deletions
diff --git a/lib/stdio/vfprintf.cpp b/lib/stdio/vfprintf.cpp
deleted file mode 100644
index aa9256d..0000000
--- a/lib/stdio/vfprintf.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-static char buffer[3 * sizeof(int) + 2];
-
-extern "C" 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(&format[s], l);
- s = i + 2;
- ++i;
-
- switch (format[i]) {
- case 's': {
- const char *arg = va_arg(params, const char *);
- written += stream->puts(arg, -1);
- } break;
- case 'c': {
- const int arg = va_arg(params, int);
- stream->putc(arg);
- ++written;
- } break;
- case 'd': {
- const char *arg = itoa(buffer, va_arg(params, int), 10);
- written += stream->puts(arg, -1);
- } break;
- case 'u': {
- const char *arg = utoa(buffer, va_arg(params, unsigned int), 10);
- written += stream->puts(arg, -1);
- } break;
- case 'x': {
- const char *arg = utoa(buffer, va_arg(params, unsigned int), 16);
- written += stream->puts(arg, -1);
- } break;
- }
-
- l = 0;
- }
-
- else
- ++l;
- }
-
- if (l > 0) { written += stream->puts(&format[s], l); }
-
- stream->flush();
- return written;
-}