nlookup.9 - document nlookup_init_root
[dragonfly.git] / contrib / gcc-4.4 / libstdc++-v3 / src / locale_facets.cc
blob081565470ed315e701e7c93fcfe621d16de21771
1 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2 // 2006, 2007, 2008, 2009
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 _GLIBCXX_BEGIN_NAMESPACE(std)
29 // Definitions for static const data members of time_base.
30 template<>
31 const char*
32 __timepunct_cache<char>::_S_timezones[14] =
34 "GMT", "HST", "AKST", "PST", "MST", "CST", "EST", "AST", "NST", "CET",
35 "IST", "EET", "CST", "JST"
38 #ifdef _GLIBCXX_USE_WCHAR_T
39 template<>
40 const wchar_t*
41 __timepunct_cache<wchar_t>::_S_timezones[14] =
43 L"GMT", L"HST", L"AKST", L"PST", L"MST", L"CST", L"EST", L"AST",
44 L"NST", L"CET", L"IST", L"EET", L"CST", L"JST"
46 #endif
48 // Definitions for static const data members of money_base.
49 const money_base::pattern
50 money_base::_S_default_pattern = { {symbol, sign, none, value} };
52 const char* money_base::_S_atoms = "-0123456789";
54 const char* __num_base::_S_atoms_in = "-+xX0123456789abcdefABCDEF";
55 const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF";
57 // _GLIBCXX_RESOLVE_LIB_DEFECTS
58 // According to the resolution of DR 231, about 22.2.2.2.2, p11,
59 // "str.precision() is specified in the conversion specification".
60 void
61 __num_base::_S_format_float(const ios_base& __io, char* __fptr, char __mod)
63 ios_base::fmtflags __flags = __io.flags();
64 *__fptr++ = '%';
65 // [22.2.2.2.2] Table 60
66 if (__flags & ios_base::showpos)
67 *__fptr++ = '+';
68 if (__flags & ios_base::showpoint)
69 *__fptr++ = '#';
71 // As per DR 231: _always_, not only when
72 // __flags & ios_base::fixed || __prec > 0
73 *__fptr++ = '.';
74 *__fptr++ = '*';
76 if (__mod)
77 *__fptr++ = __mod;
78 ios_base::fmtflags __fltfield = __flags & ios_base::floatfield;
79 // [22.2.2.2.2] Table 58
80 if (__fltfield == ios_base::fixed)
81 *__fptr++ = 'f';
82 else if (__fltfield == ios_base::scientific)
83 *__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e';
84 else
85 *__fptr++ = (__flags & ios_base::uppercase) ? 'G' : 'g';
86 *__fptr = '\0';
89 bool
90 __verify_grouping(const char* __grouping, size_t __grouping_size,
91 const string& __grouping_tmp)
93 const size_t __n = __grouping_tmp.size() - 1;
94 const size_t __min = std::min(__n, size_t(__grouping_size - 1));
95 size_t __i = __n;
96 bool __test = true;
98 // Parsed number groupings have to match the
99 // numpunct::grouping string exactly, starting at the
100 // right-most point of the parsed sequence of elements ...
101 for (size_t __j = 0; __j < __min && __test; --__i, ++__j)
102 __test = __grouping_tmp[__i] == __grouping[__j];
103 for (; __i && __test; --__i)
104 __test = __grouping_tmp[__i] == __grouping[__min];
105 // ... but the first parsed grouping can be <= numpunct
106 // grouping (only do the check if the numpunct char is > 0
107 // because <= 0 means any size is ok).
108 if (static_cast<signed char>(__grouping[__min]) > 0
109 && __grouping[__min] != __gnu_cxx::__numeric_traits<char>::__max)
110 __test &= __grouping_tmp[0] <= __grouping[__min];
111 return __test;
114 _GLIBCXX_END_NAMESPACE