1 // Wrapper for underlying C-language localization -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2003 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 2, 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 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
31 // ISO C++ 14882: 22.8 Standard locale categories.
34 // Written by Benjamin Kosnik <bkoz@redhat.com>
36 #include <cerrno> // For errno
40 #include <bits/c++locale_internal.h>
46 __convert_to_v(const char* __s
, float& __v
, ios_base::iostate
& __err
,
47 const __c_locale
& __cloc
)
49 if (!(__err
& ios_base::failbit
))
53 float __f
= __strtof_l(__s
, &__sanity
, __cloc
);
54 if (__sanity
!= __s
&& errno
!= ERANGE
)
57 __err
|= ios_base::failbit
;
63 __convert_to_v(const char* __s
, double& __v
, ios_base::iostate
& __err
,
64 const __c_locale
& __cloc
)
66 if (!(__err
& ios_base::failbit
))
70 double __d
= __strtod_l(__s
, &__sanity
, __cloc
);
71 if (__sanity
!= __s
&& errno
!= ERANGE
)
74 __err
|= ios_base::failbit
;
80 __convert_to_v(const char* __s
, long double& __v
, ios_base::iostate
& __err
,
81 const __c_locale
& __cloc
)
83 if (!(__err
& ios_base::failbit
))
87 long double __ld
= __strtold_l(__s
, &__sanity
, __cloc
);
88 if (__sanity
!= __s
&& errno
!= ERANGE
)
91 __err
|= ios_base::failbit
;
96 locale::facet::_S_create_c_locale(__c_locale
& __cloc
, const char* __s
,
99 __cloc
= __newlocale(1 << LC_ALL
, __s
, __old
);
102 // This named locale is not supported by the underlying OS.
103 __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
109 locale::facet::_S_destroy_c_locale(__c_locale
& __cloc
)
111 if (_S_get_c_locale() != __cloc
)
112 __freelocale(__cloc
);
116 locale::facet::_S_clone_c_locale(__c_locale
& __cloc
)
117 { return __duplocale(__cloc
); }
122 const char* const category_names
[6 + _GLIBCXX_NUM_CATEGORIES
] =
141 const char* const* const locale::_S_categories
= __gnu_cxx::category_names
;