diff options
| author | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2021-11-28 18:46:06 +0100 |
|---|---|---|
| committer | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2021-11-28 18:46:06 +0100 |
| commit | 7186b911cc461dbdad9307afd8901be118e20893 (patch) | |
| tree | d4fe73b268c92345922625329e6a5f43ce914254 /libpsn00b/libc/string.c | |
| parent | a75b3fa4b1a1b882c33f533645ddae75c09dd697 (diff) | |
| download | psn00bsdk-7186b911cc461dbdad9307afd8901be118e20893.tar.gz | |
CMake fixes, psxcd and printf/scanf improvements
Diffstat (limited to 'libpsn00b/libc/string.c')
| -rw-r--r-- | libpsn00b/libc/string.c | 14 |
1 files changed, 13 insertions, 1 deletions
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 <string.h> #include <stdlib.h> +// 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 |
