Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[dragonfly.git] / contrib / gcc-3.4 / libstdc++-v3 / src / locale_facets.cc
1 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
2 // Free Software Foundation, Inc.
3 //
4 // This file is part of the GNU ISO C++ Library.  This library is free
5 // software; you can redistribute it and/or modify it under the
6 // terms of the GNU General Public License as published by the
7 // Free Software Foundation; either version 2, or (at your option)
8 // any later version.
9
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14
15 // You should have received a copy of the GNU General Public License along
16 // with this library; see the file COPYING.  If not, write to the Free
17 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 // USA.
19
20 // As a special exception, you may use this file as part of a free software
21 // library without restriction.  Specifically, if other files instantiate
22 // templates or use macros or inline functions from this file, or you compile
23 // this file and link it with other files to produce an executable, this
24 // file does not by itself cause the resulting executable to be covered by
25 // the GNU General Public License.  This exception does not however
26 // invalidate any other reasons why the executable file might be covered by
27 // the GNU General Public License.
28
29 #include <locale>
30
31 namespace std 
32 {
33   // Definitions for static const data members of time_base.
34   template<> 
35     const char*
36     __timepunct_cache<char>::_S_timezones[14] =
37     { 
38       "GMT", "HST", "AKST", "PST", "MST", "CST", "EST", "AST", "NST", "CET", 
39       "IST", "EET", "CST", "JST"  
40     };
41  
42 #ifdef _GLIBCXX_USE_WCHAR_T
43   template<> 
44     const wchar_t*
45     __timepunct_cache<wchar_t>::_S_timezones[14] =
46     { 
47       L"GMT", L"HST", L"AKST", L"PST", L"MST", L"CST", L"EST", L"AST", 
48       L"NST", L"CET", L"IST", L"EET", L"CST", L"JST"  
49     };
50 #endif
51
52   // Definitions for static const data members of money_base.
53   const money_base::pattern 
54   money_base::_S_default_pattern =  { {symbol, sign, none, value} };
55
56   const char* money_base::_S_atoms = "-0123456789";
57
58   const char* __num_base::_S_atoms_in = "-+xX0123456789abcdefABCDEF";
59   const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF";
60
61   // _GLIBCXX_RESOLVE_LIB_DEFECTS
62   // According to the resolution of DR 231, about 22.2.2.2.2, p11,
63   // "str.precision() is specified in the conversion specification".
64   void
65   __num_base::_S_format_float(const ios_base& __io, char* __fptr, char __mod)
66   {
67     ios_base::fmtflags __flags = __io.flags();
68     *__fptr++ = '%';
69     // [22.2.2.2.2] Table 60
70     if (__flags & ios_base::showpos)
71       *__fptr++ = '+';
72     if (__flags & ios_base::showpoint)
73       *__fptr++ = '#';
74
75     // As per DR 231: _always_, not only when 
76     // __flags & ios_base::fixed || __prec > 0
77     *__fptr++ = '.';
78     *__fptr++ = '*';
79
80     if (__mod)
81       *__fptr++ = __mod;
82     ios_base::fmtflags __fltfield = __flags & ios_base::floatfield;
83     // [22.2.2.2.2] Table 58
84     if (__fltfield == ios_base::fixed)
85       *__fptr++ = 'f';
86     else if (__fltfield == ios_base::scientific)
87       *__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e';
88     else
89       *__fptr++ = (__flags & ios_base::uppercase) ? 'G' : 'g';
90     *__fptr = '\0';
91   }
92 } // namespace std
93