Commit 99a4deb8 by Loren J. Rittle Committed by Loren J. Rittle

acinclude.m4: Add C++ linkage check for strtof.

	* acinclude.m4: Add C++ linkage check for strtof.
	* aclocal.m4: Rebuilt.
	* config.h.in: Rebuilt.
	* configure: Rebuilt.
	* config/locale/c_locale_generic.cc: Conditionally include
	<ieeefp.h>.  Improve handling and error checking of float
	and long double input for non-C99 configurations.

From-SVN: r49546
parent 23fb1469
2002-02-06 Loren Rittle <ljrittle@acm.org>
* acinclude.m4: Add C++ linkage check for strtof.
* aclocal.m4: Rebuilt.
* config.h.in: Rebuilt.
* configure: Rebuilt.
* config/locale/c_locale_generic.cc: Conditionally include
<ieeefp.h>. Improve handling and error checking of float
and long double input for non-C99 configurations.
2002-02-06 Paolo Carlini <pcarlini@unitus.it>
* include/bits/locale_facets.tcc (money_get::do_get(string)):
......
......@@ -661,6 +661,7 @@ AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
AC_CHECK_FUNCS(drand48)
CXXFLAGS="$ac_save_CXXFLAGS"
......
......@@ -3,6 +3,9 @@
/* Define if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define if you need to in order for stat and other things to work. */
#undef _POSIX_SOURCE
// Define if GCC supports weak symbols.
#undef _GLIBCPP_SUPPORTS_WEAK
......@@ -531,6 +534,9 @@
/* Define if you have the sqrtl function. */
#undef HAVE_SQRTL
/* Define if you have the strtof function. */
#undef HAVE_STRTOF
/* Define if you have the strtold function. */
#undef HAVE_STRTOLD
......@@ -696,9 +702,6 @@
/* Define if you have the <nan.h> header file. */
#undef HAVE_NAN_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define if you have the <sys/isa_defs.h> header file. */
#undef HAVE_SYS_ISA_DEFS_H
......@@ -708,9 +711,6 @@
/* Define if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
......
......@@ -35,6 +35,10 @@
#include <locale>
#ifdef _GLIBCPP_HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
namespace std
{
// Specializations for all types used in num_get.
......@@ -119,10 +123,24 @@ namespace std
const char* __old = setlocale(LC_ALL, "C");
char* __sanity;
errno = 0;
#ifdef _GLIBCPP_USE_C99
#if defined(_GLIBCPP_USE_C99) || defined(_GLIBCPP_HAVE_STRTOF)
float __f = strtof(__s, &__sanity);
#else
float __f = static_cast<float>(strtod(__s, &__sanity));
double __d = strtod(__s, &__sanity);
float __f = static_cast<float>(__d);
#ifdef _GLIBCPP_HAVE_FINITEF
if (!finitef (__f))
errno = ERANGE;
#elif defined (_GLIBCPP_HAVE_FINITE)
if (!finite (static_cast<double> (__f)))
errno = ERANGE;
#elif defined (_GLIBCPP_HAVE_ISINF)
if (isinf (static_cast<double> (__f)))
errno = ERANGE;
#else
if (fabs(__d) > numeric_limits<float>::max())
errno = ERANGE;
#endif
#endif
if (__sanity != __s && *__sanity == '\0' && errno != ERANGE)
__v = __f;
......@@ -161,7 +179,7 @@ namespace std
{
// Assumes __s formatted for "C" locale.
const char* __old = setlocale(LC_ALL, "C");
#if defined(_GLIBCPP_USE_C99) && !defined(__hpux)
#if defined(_GLIBCPP_USE_C99) || defined(_GLIBCPP_HAVE_STRTOLD)
char* __sanity;
errno = 0;
long double __ld = strtold(__s, &__sanity);
......@@ -170,7 +188,14 @@ namespace std
#else
typedef char_traits<char>::int_type int_type;
long double __ld;
errno = 0;
int __p = sscanf(__s, "%Lf", &__ld);
if (errno == ERANGE)
__p = 0;
#ifdef _GLIBCPP_HAVE_FINITEL
if ((__p == 1) && !finitel (__ld))
__p = 0;
#endif
if (__p && static_cast<int_type>(__p) != char_traits<char>::eof())
__v = __ld;
#endif
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment