// Wrapper for underlying C-language localization -*- C++ -*-
-// Copyright (C) 2001-2014 Free Software Foundation, Inc.
+// Copyright (C) 2001-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
{
_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,
bool __overflow = false;
#if !__FLT_HAS_INFINITY__
- errno = 0;
+ const _Save_errno __save_errno;
#endif
#ifdef _GLIBCXX_HAVE_STRTOF
char* __sanity;
#if !__DBL_HAS_INFINITY__
- errno = 0;
+ const _Save_errno __save_errno;
#endif
__v = strtod(__s, &__sanity);
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)