thin printf, but buggy

This commit is contained in:
2023-03-12 18:42:30 +01:00
parent f18a7733a1
commit 7e99e2cc6c
13 changed files with 1143 additions and 37 deletions
File diff suppressed because it is too large Load Diff
+39
View File
@@ -0,0 +1,39 @@
//
// Created by MightyPork on 2017/11/09.
//
// Small sprintf/snprintf implementation, used instead of the newlib one.
//
#ifndef GEX_SNPRINTF_H
#define GEX_SNPRINTF_H
#include <stdarg.h>
#include <limits.h>
int fixup_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
int fixup_snprintf(char *str, size_t count,const char *fmt,...);
int fixup_vasprintf(char **ptr, const char *format, va_list ap);
int fixup_asprintf(char **ptr, const char *format, ...);
int fixup_sprintf(char *ptr, const char *format, ...);
int fixup_printf(const char *format, ...);
int fixup_vprintf(const char *format, va_list ap);
#define VSNPRINTF(...) fixup_vsnprintf(__VA_ARGS__)
#define SNPRINTF(...) fixup_snprintf(__VA_ARGS__)
#define VASPRINTF(...) fixup_vasprintf(__VA_ARGS__)
#define ASPRINTF(...) fixup_asprintf(__VA_ARGS__)
#define SPRINTF(...) fixup_sprintf(__VA_ARGS__)
#define PRINTF(...) fixup_printf(__VA_ARGS__)
#define VPRINTF(...) fixup_vprintf(__VA_ARGS__)
// extern
extern void stdout_puts(const char *s);
extern void stdout_putchar(char c);
extern void stdout_write(const char *s, size_t len);
#define PUTS(s) stdout_puts((s))
#define PUTCHAR(c) stdout_putchar((c))
#define WRITE(s, n) stdout_write((s), (n))
#endif //GEX_SNPRINTF_H