From b2be57c5cf3388c1959f840fdf732c9d8816ff73 Mon Sep 17 00:00:00 2001 From: NicJA Date: Wed, 4 Feb 2015 16:59:26 +0000 Subject: [PATCH] add the c99 strtold function git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@50008 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- compiler/stdc/include/aros/stdc/stdlib.h | 4 +- compiler/stdc/mmakefile.src | 1 + compiler/stdc/stdc.conf | 2 +- compiler/stdc/strtold.c | 70 ++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 compiler/stdc/strtold.c diff --git a/compiler/stdc/include/aros/stdc/stdlib.h b/compiler/stdc/include/aros/stdc/stdlib.h index ff3ec55690..9411c918a7 100644 --- a/compiler/stdc/include/aros/stdc/stdlib.h +++ b/compiler/stdc/include/aros/stdc/stdlib.h @@ -54,8 +54,8 @@ long int atol(const char *nptr); double strtod(const char * restrict nptr, char ** restrict endptr); /* NOTIMPL float strtof(const char * restrict nptr, char ** restrict endptr); */ -/* NOTIMPL long double strtold(const char * restrict nptr, char ** restrict endptr); */ - +long double strtold(const char * restrict nptr, + char ** restrict endptr); long int strtol(const char * restrict nptr, char ** restrict endptr, int base); diff --git a/compiler/stdc/mmakefile.src b/compiler/stdc/mmakefile.src index 1d7746887d..2fea3399ad 100644 --- a/compiler/stdc/mmakefile.src +++ b/compiler/stdc/mmakefile.src @@ -165,6 +165,7 @@ STDC := \ strspn \ strstr \ strtod \ + strtold \ strtoimax \ strtok \ strtok_r \ diff --git a/compiler/stdc/stdc.conf b/compiler/stdc/stdc.conf index 12e6ecd71c..c97c78f0ef 100644 --- a/compiler/stdc/stdc.conf +++ b/compiler/stdc/stdc.conf @@ -447,7 +447,7 @@ long int atol(const char *nptr) double strtod(const char * restrict nptr, char ** restrict endptr) .skip 2 #float strtof(const char * restrict nptr, char ** restrict endptr) -#long double strtold(const char * restrict nptr, char ** restrict endptr) +long double strtold(const char * restrict nptr, char ** restrict endptr) long int strtol(const char * restrict nptr, char ** restrict endptr, int base) long long int strtoll(const char * restrict nptr, char ** restrict endptr, int base) unsigned long int strtoul(const char * restrict nptr, char ** restrict endptr, int base) diff --git a/compiler/stdc/strtold.c b/compiler/stdc/strtold.c new file mode 100644 index 0000000000..e1e35afcaf --- /dev/null +++ b/compiler/stdc/strtold.c @@ -0,0 +1,70 @@ +/* + Copyright © 2015, The AROS Development Team. All rights reserved. + $Id:$ + + C99 function strtold(). +*/ + +#ifndef AROS_NOFPU + +#include +#include + +/***************************************************************************** + + NAME */ +#include +#include + + long double strtold ( + +/* SYNOPSIS */ + const char * str, + char ** endptr) + +/* FUNCTION + Convert a string of digits into a long double. + + INPUTS + str - The string which should be converted. Leading + whitespace are ignored. The number may be prefixed + by a '+' or '-'. An 'e' or 'E' introduces the exponent. + Komma is only allowed before exponent. + endptr - If this is non-NULL, then the address of the first + character after the number in the string is stored + here. + + RESULT + The value of the string. The first character after the number + is returned in *endptr, if endptr is non-NULL. If no digits can + be converted, *endptr contains str (if non-NULL) and 0 is + returned. + + NOTES + We make the compiler do an internal conversion from a double + to a long double. Because of this we lose a some precision, but for + now it works. + + EXAMPLE + + BUGS + NAN is not handled at the moment + + SEE ALSO + strtod() + + INTERNALS + +******************************************************************************/ +{ + return (long double)strtod(str, endptr); +} /* strtold */ + +#else + +void strtold (const char * str,char ** endptr) +{ + return; +} + +#endif /* AROS_NOFPU */ -- 2.11.4.GIT