re PR libstdc++/31117 (c++locale.o thread-unsafe in libstdc++)
2007-04-06 Paolo Carlini <pcarlini@suse.de> PR libstdc++/31117 * config/locale/gnu/c_locale.cc (__convert_to_v): Do not use errno, just check that the value is finite. * config/locale/generic/c_locale.cc (__convert_to_v): Likewise. From-SVN: r123635
This commit is contained in:
parent
91f753f8ee
commit
1bfe2e5fca
3 changed files with 27 additions and 21 deletions
|
@ -1,3 +1,10 @@
|
|||
2007-04-06 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
PR libstdc++/31117
|
||||
* config/locale/gnu/c_locale.cc (__convert_to_v): Do not use errno,
|
||||
just check that the value is finite.
|
||||
* config/locale/generic/c_locale.cc (__convert_to_v): Likewise.
|
||||
|
||||
2007-04-06 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/ext/type_traits.h (__numeric_traits): Move...
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Wrapper for underlying C-language localization -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
|
@ -34,7 +34,6 @@
|
|||
|
||||
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
#include <cerrno> // For errno
|
||||
#include <cmath> // For isinf, finite, finitef, fabs
|
||||
#include <cstdlib> // For strof, strtold
|
||||
#include <locale>
|
||||
|
@ -52,7 +51,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
const __c_locale&)
|
||||
{
|
||||
// Assumes __s formatted for "C" locale.
|
||||
errno = 0;
|
||||
char* __old = strdup(setlocale(LC_ALL, NULL));
|
||||
setlocale(LC_ALL, "C");
|
||||
char* __sanity;
|
||||
|
@ -63,19 +61,20 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
float __f = static_cast<float>(__d);
|
||||
#ifdef _GLIBCXX_HAVE_FINITEF
|
||||
if (!finitef (__f))
|
||||
errno = ERANGE;
|
||||
__f = __builtin_huge_valf();
|
||||
#elif defined (_GLIBCXX_HAVE_FINITE)
|
||||
if (!finite (static_cast<double> (__f)))
|
||||
errno = ERANGE;
|
||||
__f = __builtin_huge_valf();
|
||||
#elif defined (_GLIBCXX_HAVE_ISINF)
|
||||
if (isinf (static_cast<double> (__f)))
|
||||
errno = ERANGE;
|
||||
__f = __builtin_huge_valf();
|
||||
#else
|
||||
if (fabs(__d) > numeric_limits<float>::max())
|
||||
errno = ERANGE;
|
||||
__f = __builtin_huge_valf();
|
||||
#endif
|
||||
#endif
|
||||
if (__sanity != __s && errno != ERANGE)
|
||||
if (__sanity != __s && __f != __builtin_huge_valf()
|
||||
&& __f != -__builtin_huge_valf())
|
||||
__v = __f;
|
||||
else
|
||||
__err |= ios_base::failbit;
|
||||
|
@ -89,12 +88,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
const __c_locale&)
|
||||
{
|
||||
// Assumes __s formatted for "C" locale.
|
||||
errno = 0;
|
||||
char* __old = strdup(setlocale(LC_ALL, NULL));
|
||||
setlocale(LC_ALL, "C");
|
||||
char* __sanity;
|
||||
double __d = strtod(__s, &__sanity);
|
||||
if (__sanity != __s && errno != ERANGE)
|
||||
if (__sanity != __s && __d != __builtin_huge_val()
|
||||
&& __d != -__builtin_huge_val())
|
||||
__v = __d;
|
||||
else
|
||||
__err |= ios_base::failbit;
|
||||
|
@ -108,20 +107,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
ios_base::iostate& __err, const __c_locale&)
|
||||
{
|
||||
// Assumes __s formatted for "C" locale.
|
||||
errno = 0;
|
||||
char* __old = strdup(setlocale(LC_ALL, NULL));
|
||||
setlocale(LC_ALL, "C");
|
||||
#if defined(_GLIBCXX_HAVE_STRTOLD)
|
||||
char* __sanity;
|
||||
long double __ld = strtold(__s, &__sanity);
|
||||
if (__sanity != __s && errno != ERANGE)
|
||||
if (__sanity != __s && __ld != __builtin_huge_vall()
|
||||
&& __ld != -__builtin_huge_vall())
|
||||
__v = __ld;
|
||||
#else
|
||||
typedef char_traits<char>::int_type int_type;
|
||||
long double __ld;
|
||||
int __p = sscanf(__s, "%Lf", &__ld);
|
||||
if (__p && static_cast<int_type>(__p) != char_traits<char>::eof()
|
||||
&& errno != ERANGE)
|
||||
&& __ld != __builtin_huge_vall()
|
||||
&& __ld != -__builtin_huge_vall())
|
||||
__v = __ld;
|
||||
#endif
|
||||
else
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Wrapper for underlying C-language localization -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
|
@ -34,7 +34,6 @@
|
|||
|
||||
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
#include <cerrno> // For errno
|
||||
#include <locale>
|
||||
#include <stdexcept>
|
||||
#include <langinfo.h>
|
||||
|
@ -48,9 +47,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
const __c_locale& __cloc)
|
||||
{
|
||||
char* __sanity;
|
||||
errno = 0;
|
||||
float __f = __strtof_l(__s, &__sanity, __cloc);
|
||||
if (__sanity != __s && errno != ERANGE)
|
||||
if (__sanity != __s && __f != __builtin_huge_valf()
|
||||
&& __f != -__builtin_huge_valf())
|
||||
__v = __f;
|
||||
else
|
||||
__err |= ios_base::failbit;
|
||||
|
@ -62,9 +61,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
const __c_locale& __cloc)
|
||||
{
|
||||
char* __sanity;
|
||||
errno = 0;
|
||||
double __d = __strtod_l(__s, &__sanity, __cloc);
|
||||
if (__sanity != __s && errno != ERANGE)
|
||||
if (__sanity != __s && __d != __builtin_huge_val()
|
||||
&& __d != -__builtin_huge_val())
|
||||
__v = __d;
|
||||
else
|
||||
__err |= ios_base::failbit;
|
||||
|
@ -76,7 +75,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
const __c_locale& __cloc)
|
||||
{
|
||||
char* __sanity;
|
||||
errno = 0;
|
||||
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
|
||||
// Prefer strtold_l, as __strtold_l isn't prototyped in more recent
|
||||
// glibc versions.
|
||||
|
@ -84,7 +82,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
#else
|
||||
long double __ld = __strtold_l(__s, &__sanity, __cloc);
|
||||
#endif
|
||||
if (__sanity != __s && errno != ERANGE)
|
||||
if (__sanity != __s && __ld != __builtin_huge_vall()
|
||||
&& __ld != -__builtin_huge_vall())
|
||||
__v = __ld;
|
||||
else
|
||||
__err |= ios_base::failbit;
|
||||
|
|
Loading…
Add table
Reference in a new issue