* hooks.c (hook_int_rtx_mode_as_bool_0): New function.
[official-gcc.git] / libstdc++-v3 / src / c++98 / locale_facets.cc
blob92552227f80614a92815edf9ffd9022fd4c97c4a
1 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2 // 2006, 2007, 2008, 2009, 2010
3 // Free Software Foundation, Inc.
4 //
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)
9 // any later version.
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/>.
25 #include <locale>
27 namespace std _GLIBCXX_VISIBILITY(default)
29 _GLIBCXX_BEGIN_NAMESPACE_VERSION
31 // Definitions for static const data members of time_base.
32 template<>
33 const char*
34 __timepunct_cache<char>::_S_timezones[14] =
36 "GMT", "HST", "AKST", "PST", "MST", "CST", "EST", "AST", "NST", "CET",
37 "IST", "EET", "CST", "JST"
40 #ifdef _GLIBCXX_USE_WCHAR_T
41 template<>
42 const wchar_t*
43 __timepunct_cache<wchar_t>::_S_timezones[14] =
45 L"GMT", L"HST", L"AKST", L"PST", L"MST", L"CST", L"EST", L"AST",
46 L"NST", L"CET", L"IST", L"EET", L"CST", L"JST"
48 #endif
50 // Definitions for static const data members of money_base.
51 const money_base::pattern
52 money_base::_S_default_pattern = { {symbol, sign, none, value} };
54 const char* money_base::_S_atoms = "-0123456789";
56 const char* __num_base::_S_atoms_in = "-+xX0123456789abcdefABCDEF";
57 const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF";
59 // _GLIBCXX_RESOLVE_LIB_DEFECTS
60 // According to the resolution of DR 231, about 22.2.2.2.2, p11,
61 // "str.precision() is specified in the conversion specification".
62 void
63 __num_base::_S_format_float(const ios_base& __io, char* __fptr,
64 char __mod) throw()
66 ios_base::fmtflags __flags = __io.flags();
67 *__fptr++ = '%';
68 // [22.2.2.2.2] Table 60
69 if (__flags & ios_base::showpos)
70 *__fptr++ = '+';
71 if (__flags & ios_base::showpoint)
72 *__fptr++ = '#';
74 // As per DR 231: _always_, not only when
75 // __flags & ios_base::fixed || __prec > 0
76 *__fptr++ = '.';
77 *__fptr++ = '*';
79 if (__mod)
80 *__fptr++ = __mod;
81 ios_base::fmtflags __fltfield = __flags & ios_base::floatfield;
82 // [22.2.2.2.2] Table 58
83 if (__fltfield == ios_base::fixed)
84 *__fptr++ = 'f';
85 else if (__fltfield == ios_base::scientific)
86 *__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e';
87 else
88 *__fptr++ = (__flags & ios_base::uppercase) ? 'G' : 'g';
89 *__fptr = '\0';
92 bool
93 __verify_grouping(const char* __grouping, size_t __grouping_size,
94 const string& __grouping_tmp) throw()
96 const size_t __n = __grouping_tmp.size() - 1;
97 const size_t __min = std::min(__n, size_t(__grouping_size - 1));
98 size_t __i = __n;
99 bool __test = true;
101 // Parsed number groupings have to match the
102 // numpunct::grouping string exactly, starting at the
103 // right-most point of the parsed sequence of elements ...
104 for (size_t __j = 0; __j < __min && __test; --__i, ++__j)
105 __test = __grouping_tmp[__i] == __grouping[__j];
106 for (; __i && __test; --__i)
107 __test = __grouping_tmp[__i] == __grouping[__min];
108 // ... but the first parsed grouping can be <= numpunct
109 // grouping (only do the check if the numpunct char is > 0
110 // because <= 0 means any size is ok).
111 if (static_cast<signed char>(__grouping[__min]) > 0
112 && __grouping[__min] != __gnu_cxx::__numeric_traits<char>::__max)
113 __test &= __grouping_tmp[0] <= __grouping[__min];
114 return __test;
117 _GLIBCXX_END_NAMESPACE_VERSION
118 } // namespace