From: Jonathan Wakely Date: Thu, 1 Oct 2015 11:23:39 +0000 (+0100) Subject: Save-and-restore errno more carefully in libstdc++ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f14decafae0d1771e16498e693e7bf2f7058e88e;p=gcc.git Save-and-restore errno more carefully in libstdc++ * doc/xml/manual/diagnostics.xml: Document use of errno. * doc/html/*: Regenerate. * config/locale/generic/c_locale.cc (_Save_errno): New helper. (__convert_to_v): Use _Save_errno. * include/ext/string_conversions.h (__stoa): Only restore errno when it isn't set to non-zero. From-SVN: r228328 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index cc22cfa14c0..4199ede06fd 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2015-10-01 Jonathan Wakely + + * doc/xml/manual/diagnostics.xml: Document use of errno. + * doc/html/*: Regenerate. + * config/locale/generic/c_locale.cc (_Save_errno): New helper. + (__convert_to_v): Use _Save_errno. + * include/ext/string_conversions.h (__stoa): Only restore errno when + it isn't set to non-zero. + 2015-09-30 François Dumont Jonathan Wakely diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc index 6da5f2256cf..8dfea6b0682 100644 --- a/libstdc++-v3/config/locale/generic/c_locale.cc +++ b/libstdc++-v3/config/locale/generic/c_locale.cc @@ -44,6 +44,16 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace + { + struct _Save_errno + { + _Save_errno() : _M_errno(errno) { errno = 0; } + ~_Save_errno() { if (errno == 0) errno = _M_errno; } + int _M_errno; + }; + } + template<> void __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err, @@ -59,7 +69,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION bool __overflow = false; #if !__FLT_HAS_INFINITY__ - errno = 0; + const _Save_errno __save_errno; #endif #ifdef _GLIBCXX_HAVE_STRTOF @@ -123,7 +133,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION char* __sanity; #if !__DBL_HAS_INFINITY__ - errno = 0; + const _Save_errno __save_errno; #endif __v = strtod(__s, &__sanity); @@ -167,7 +177,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION setlocale(LC_ALL, "C"); #if !__LDBL_HAS_INFINITY__ - errno = 0; + const _Save_errno __save_errno; #endif #if defined(_GLIBCXX_HAVE_STRTOLD) && !defined(_GLIBCXX_HAVE_BROKEN_STRTOLD) diff --git a/libstdc++-v3/doc/html/manual/concept_checking.html b/libstdc++-v3/doc/html/manual/concept_checking.html index df7f22f7fcd..a01957d5e27 100644 --- a/libstdc++-v3/doc/html/manual/concept_checking.html +++ b/libstdc++-v3/doc/html/manual/concept_checking.html @@ -1,5 +1,5 @@ -Concept Checking