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/string.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'libpsn00b/libc/string.c') diff --git a/libpsn00b/libc/string.c b/libpsn00b/libc/string.c index 445b227..a1a9a05 100644 --- a/libpsn00b/libc/string.c +++ b/libpsn00b/libc/string.c @@ -8,6 +8,10 @@ #include #include +// Uncomment to enable strtod(), strtold() and strtof(). Note that these +// functions use extremely slow software floats. +//#define ALLOW_FLOAT + int tolower(int chr) { return (chr >='A' && chr<='Z') ? (chr + 32) : (chr); @@ -252,6 +256,8 @@ long strtol(const char *nptr, char **endptr, int base) return (long)strtoll(nptr, endptr, base); } +#ifdef ALLOW_FLOAT + double strtod(const char *nptr, char **endptr) { char strbuf[64]; @@ -302,6 +308,8 @@ double strtod(const char *nptr, char **endptr) return (i + d)*s; } +#endif + /* implementation by Lameguy64, behaves like OpenWatcom's strtok() */ /* BIOS strtok seemed either bugged, or designed for wide chars */ @@ -344,6 +352,8 @@ char *strtok( char *s1, char *s2 ) } /* strtok */ +#ifdef ALLOW_FLOAT + long double strtold(const char *nptr, char **endptr) { return (long double)strtod(nptr, endptr); @@ -352,4 +362,6 @@ long double strtold(const char *nptr, char **endptr) float strtof(const char *nptr, char **endptr) { return (float)strtod(nptr, endptr); -} \ No newline at end of file +} + +#endif -- cgit v1.2.3