aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/vsprintf.c
diff options
context:
space:
mode:
authorJohn "Lameguy" Wilbert Villamor <lameguy64@gmail.com>2022-01-18 08:31:14 +0800
committerGitHub <noreply@github.com>2022-01-18 08:31:14 +0800
commit05d44488bd5587786f4bd0286fc0f555c79aa46a (patch)
tree5740f396d10a9580c3a39ca536544436898ff1b6 /libpsn00b/libc/vsprintf.c
parent08de895e8582dbc70b639ae5f511ab9ebfb4d68a (diff)
parente9475e283a82665fe6c19bebc3318b5084f15a2e (diff)
downloadpsn00bsdk-05d44488bd5587786f4bd0286fc0f555c79aa46a.tar.gz
Merge pull request #44 from spicyjpeg/actions
GitHub Actions CI, psxcd and libc fixes, new examples
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;