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. 10 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. 15 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. 19 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/>. 24 25#include <locale> 26 27_GLIBCXX_BEGIN_NAMESPACE(std) 28 29 // Definitions for static const data members of time_base. 30 template<> 31 const char* 32 __timepunct_cache<char>::_S_timezones[14] = 33 { 34 "GMT", "HST", "AKST", "PST", "MST", "CST", "EST", "AST", "NST", "CET", 35 "IST", "EET", "CST", "JST" 36 }; 37 38#ifdef _GLIBCXX_USE_WCHAR_T 39 template<> 40 const wchar_t* 41 __timepunct_cache<wchar_t>::_S_timezones[14] = 42 { 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" 45 }; 46#endif 47 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} }; 51 52 const char* money_base::_S_atoms = "-0123456789"; 53 54 const char* __num_base::_S_atoms_in = "-+xX0123456789abcdefABCDEF"; 55 const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF"; 56 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, 62 char __mod) throw() 63 { 64 ios_base::fmtflags __flags = __io.flags(); 65 *__fptr++ = '%'; 66 // [22.2.2.2.2] Table 60 67 if (__flags & ios_base::showpos) 68 *__fptr++ = '+'; 69 if (__flags & ios_base::showpoint) 70 *__fptr++ = '#'; 71 72 // As per DR 231: _always_, not only when 73 // __flags & ios_base::fixed || __prec > 0 74 *__fptr++ = '.'; 75 *__fptr++ = '*'; 76 77 if (__mod) 78 *__fptr++ = __mod; 79 ios_base::fmtflags __fltfield = __flags & ios_base::floatfield; 80 // [22.2.2.2.2] Table 58 81 if (__fltfield == ios_base::fixed) 82 *__fptr++ = 'f'; 83 else if (__fltfield == ios_base::scientific) 84 *__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e'; 85 else 86 *__fptr++ = (__flags & ios_base::uppercase) ? 'G' : 'g'; 87 *__fptr = '\0'; 88 } 89 90 bool 91 __verify_grouping(const char* __grouping, size_t __grouping_size, 92 const string& __grouping_tmp) throw() 93 { 94 const size_t __n = __grouping_tmp.size() - 1; 95 const size_t __min = std::min(__n, size_t(__grouping_size - 1)); 96 size_t __i = __n; 97 bool __test = true; 98 99 // Parsed number groupings have to match the 100 // numpunct::grouping string exactly, starting at the 101 // right-most point of the parsed sequence of elements ... 102 for (size_t __j = 0; __j < __min && __test; --__i, ++__j) 103 __test = __grouping_tmp[__i] == __grouping[__j]; 104 for (; __i && __test; --__i) 105 __test = __grouping_tmp[__i] == __grouping[__min]; 106 // ... but the first parsed grouping can be <= numpunct 107 // grouping (only do the check if the numpunct char is > 0 108 // because <= 0 means any size is ok). 109 if (static_cast<signed char>(__grouping[__min]) > 0 110 && __grouping[__min] != __gnu_cxx::__numeric_traits<char>::__max) 111 __test &= __grouping_tmp[0] <= __grouping[__min]; 112 return __test; 113 } 114 115_GLIBCXX_END_NAMESPACE 116