From 7186b911cc461dbdad9307afd8901be118e20893 Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Sun, 28 Nov 2021 18:46:06 +0100 Subject: CMake fixes, psxcd and printf/scanf improvements --- libpsn00b/libc/vsprintf.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libpsn00b/libc/vsprintf.c') diff --git a/libpsn00b/libc/vsprintf.c b/libpsn00b/libc/vsprintf.c index 0a99dcc..9ca4cc5 100644 --- a/libpsn00b/libc/vsprintf.c +++ b/libpsn00b/libc/vsprintf.c @@ -6,6 +6,10 @@ #include #include #include +#include + +// Uncomment to enable support for %f. +//#define ALLOW_FLOAT #define SPRINTF_ALT_FLAG (1<<0) #define SPRINTF_ZERO_FLAG (1<<1) @@ -208,6 +212,8 @@ int libc_ulltoa(unsigned long i, char *dst, int n) return n2; } +#ifdef ALLOW_FLOAT + void libc_float_to_string(float fl, char *dst, int n) { unsigned int *p = (unsigned int*)&fl; @@ -365,6 +371,8 @@ void libc_double_to_string(double fl, char *dst, int n) char libc_sprintf_floatbuf[64]; +#endif + int vsnprintf(char *string, unsigned int size, const char *fmt, va_list ap) { int string_pos,fmt_pos; @@ -732,6 +740,7 @@ int vsnprintf(char *string, unsigned int size, const char *fmt, va_list ap) directive_coming = 0; break; +#ifdef ALLOW_FLOAT case 'f': libc_double_to_string(va_arg(ap, double), libc_sprintf_floatbuf, 64); @@ -740,6 +749,8 @@ int vsnprintf(char *string, unsigned int size, const char *fmt, va_list ap) directive_coming = 0; break; +#endif + case 'n': // Number of characters written *(va_arg(ap,unsigned int*)) = string_pos; -- cgit v1.2.3