Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. // Copyright (C) 1997-2013 Free Software Foundation, Inc.
  2. //
  3. // This file is part of the GNU ISO C++ Library.  This library is free
  4. // software; you can redistribute it and/or modify it under the
  5. // terms of the GNU General Public License as published by the
  6. // Free Software Foundation; either version 3, or (at your option)
  7. // any later version.
  8.  
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. // GNU General Public License for more details.
  13.  
  14. // Under Section 7 of GPL version 3, you are granted additional
  15. // permissions described in the GCC Runtime Library Exception, version
  16. // 3.1, as published by the Free Software Foundation.
  17.  
  18. // You should have received a copy of the GNU General Public License and
  19. // a copy of the GCC Runtime Library Exception along with this program;
  20. // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
  21. // <http://www.gnu.org/licenses/>.
  22.  
  23. #include <locale>
  24.  
  25. namespace std _GLIBCXX_VISIBILITY(default)
  26. {
  27. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  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_VERSION
  116. } // namespace
  117.