1 // localization implementation details, DragonFly version -*- C++ -*-
3 // Copyright (C) 2014-2018 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
26 // ISO C++ 14882: 22.8 Standard locale categories.
29 // Written by Benjamin Kosnik <bkoz@redhat.com>
30 // Modified for DragonFly by John Marino <gnugcc@marino.st>
39 namespace std _GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
46 const __c_locale& __cloc) throw()
49 __v = strtof_l(__s, &__sanity, (locale_t)__cloc);
51 // _GLIBCXX_RESOLVE_LIB_DEFECTS
52 // 23. Num_get overflow result.
53 if (__sanity == __s || *__sanity != '\0')
56 __err = ios_base::failbit;
58 else if (__v == numeric_limits<float>::infinity())
60 __v = numeric_limits<float>::max();
61 __err = ios_base::failbit;
63 else if (__v == -numeric_limits<float>::infinity())
65 __v = -numeric_limits<float>::max();
66 __err = ios_base::failbit;
72 __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
73 const __c_locale& __cloc) throw()
76 __v = strtod_l(__s, &__sanity, (locale_t)__cloc);
78 // _GLIBCXX_RESOLVE_LIB_DEFECTS
79 // 23. Num_get overflow result.
80 if (__sanity == __s || *__sanity != '\0')
83 __err = ios_base::failbit;
85 else if (__v == numeric_limits<double>::infinity())
87 __v = numeric_limits<double>::max();
88 __err = ios_base::failbit;
90 else if (__v == -numeric_limits<double>::infinity())
92 __v = -numeric_limits<double>::max();
93 __err = ios_base::failbit;
99 __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
100 const __c_locale& __cloc) throw()
103 __v = strtold_l(__s, &__sanity, (locale_t)__cloc);
105 // _GLIBCXX_RESOLVE_LIB_DEFECTS
106 // 23. Num_get overflow result.
107 if (__sanity == __s || *__sanity != '\0')
110 __err = ios_base::failbit;
112 else if (__v == numeric_limits<long double>::infinity())
114 __v = numeric_limits<long double>::max();
115 __err = ios_base::failbit;
117 else if (__v == -numeric_limits<long double>::infinity())
119 __v = -numeric_limits<long double>::max();
120 __err = ios_base::failbit;
125 locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
128 __cloc = (__c_locale)newlocale(LC_ALL_MASK, __s, (locale_t)__old);
131 // This named locale is not supported by the underlying OS.
132 __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
138 locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
140 if (__cloc && _S_get_c_locale() != __cloc)
141 freelocale((locale_t)__cloc);
145 locale::facet::_S_clone_c_locale(__c_locale& __cloc) throw()
146 { return (__c_locale)duplocale((locale_t)__cloc); }
149 locale::facet::_S_lc_ctype_c_locale(__c_locale __cloc, const char* __s)
151 __c_locale __dup = (__c_locale)duplocale((locale_t)__cloc);
152 if (__dup == __c_locale(0))
153 __throw_runtime_error(__N("locale::facet::_S_lc_ctype_c_locale "
155 __c_locale __changed = (__c_locale)newlocale(LC_CTYPE_MASK, __s,
157 if (__changed == __c_locale(0))
159 freelocale((locale_t)__dup);
160 __throw_runtime_error(__N("locale::facet::_S_lc_ctype_c_locale "
166 _GLIBCXX_END_NAMESPACE_VERSION
169 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
171 _GLIBCXX_BEGIN_NAMESPACE_VERSION
173 const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
183 _GLIBCXX_END_NAMESPACE_VERSION
186 namespace std _GLIBCXX_VISIBILITY(default)
188 _GLIBCXX_BEGIN_NAMESPACE_VERSION
190 const char* const* const locale::_S_categories = __gnu_cxx::category_names;
192 _GLIBCXX_END_NAMESPACE_VERSION
195 // XXX GLIBCXX_ABI Deprecated
196 #ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
197 #define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
198 extern "C" void ldbl (void) __attribute__ ((alias (#dbl)))
199 _GLIBCXX_LDBL_COMPAT(_ZSt14__convert_to_vIdEvPKcRT_RSt12_Ios_IostateRKP15__locale_struct, _ZSt14__convert_to_vIeEvPKcRT_RSt12_Ios_IostateRKP15__locale_struct);
200 #endif // _GLIBCXX_LONG_DOUBLE_COMPAT