aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/vsprintf.c
diff options
context:
space:
mode:
authorspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2021-11-28 18:46:06 +0100
committerspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2021-11-28 18:46:06 +0100
commit7186b911cc461dbdad9307afd8901be118e20893 (patch)
treed4fe73b268c92345922625329e6a5f43ce914254 /libpsn00b/libc/vsprintf.c
parenta75b3fa4b1a1b882c33f533645ddae75c09dd697 (diff)
downloadpsn00bsdk-7186b911cc461dbdad9307afd8901be118e20893.tar.gz
CMake fixes, psxcd and printf/scanf improvements
Diffstat (limited to 'libpsn00b/libc/vsprintf.c')
-rw-r--r--libpsn00b/libc/vsprintf.c11
1 files changed, 11 insertions, 0 deletions
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 <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
+
+// 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;