OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [src/] [c++98/] [ctype.cc] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005,
2
// 2006, 2007, 2008, 2009, 2010, 2011
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
#include <cstdlib>
27
#include <cstring>
28
 
29
namespace std _GLIBCXX_VISIBILITY(default)
30
{
31
_GLIBCXX_BEGIN_NAMESPACE_VERSION
32
 
33
  // Definitions for static const data members of ctype_base.
34
  const ctype_base::mask ctype_base::space;
35
  const ctype_base::mask ctype_base::print;
36
  const ctype_base::mask ctype_base::cntrl;
37
  const ctype_base::mask ctype_base::upper;
38
  const ctype_base::mask ctype_base::lower;
39
  const ctype_base::mask ctype_base::alpha;
40
  const ctype_base::mask ctype_base::digit;
41
  const ctype_base::mask ctype_base::punct;
42
  const ctype_base::mask ctype_base::xdigit;
43
  const ctype_base::mask ctype_base::alnum;
44
  const ctype_base::mask ctype_base::graph;
45
 
46
  // Definitions for locale::id of standard facets that are specialized.
47
  locale::id ctype<char>::id;
48
 
49
#ifdef _GLIBCXX_USE_WCHAR_T  
50
  locale::id ctype<wchar_t>::id;
51
#endif
52
 
53
  const size_t ctype<char>::table_size;
54
 
55
  ctype<char>::~ctype()
56
  {
57
    _S_destroy_c_locale(_M_c_locale_ctype);
58
    if (_M_del)
59
      delete[] this->table();
60
  }
61
 
62
  // Fill in the narrowing cache and flag whether all values are
63
  // valid or not.  _M_narrow_ok is set to 2 if memcpy can't
64
  // be used.
65
  void
66
  ctype<char>::
67
  _M_narrow_init() const
68
  {
69
    char __tmp[sizeof(_M_narrow)];
70
    for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
71
      __tmp[__i] = __i;
72
    do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
73
 
74
    _M_narrow_ok = 1;
75
    if (__builtin_memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
76
      _M_narrow_ok = 2;
77
    else
78
      {
79
        // Deal with the special case of zero: renarrow with a
80
        // different default and compare.
81
        char __c;
82
        do_narrow(__tmp, __tmp + 1, 1, &__c);
83
        if (__c == 1)
84
          _M_narrow_ok = 2;
85
      }
86
  }
87
 
88
  void
89
  ctype<char>::
90
  _M_widen_init() const
91
  {
92
    char __tmp[sizeof(_M_widen)];
93
    for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
94
      __tmp[__i] = __i;
95
    do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
96
 
97
    _M_widen_ok = 1;
98
    // Set _M_widen_ok to 2 if memcpy can't be used.
99
    if (__builtin_memcmp(__tmp, _M_widen, sizeof(_M_widen)))
100
      _M_widen_ok = 2;
101
  }
102
 
103
#ifdef _GLIBCXX_USE_WCHAR_T
104
  ctype<wchar_t>::ctype(size_t __refs)
105
  : __ctype_abstract_base<wchar_t>(__refs),
106
  _M_c_locale_ctype(_S_get_c_locale()), _M_narrow_ok(false)
107
  { _M_initialize_ctype(); }
108
 
109
  ctype<wchar_t>::ctype(__c_locale __cloc, size_t __refs)
110
  : __ctype_abstract_base<wchar_t>(__refs),
111
  _M_c_locale_ctype(_S_clone_c_locale(__cloc)), _M_narrow_ok(false)
112
  { _M_initialize_ctype(); }
113
 
114
  ctype<wchar_t>::~ctype()
115
  { _S_destroy_c_locale(_M_c_locale_ctype); }
116
 
117
  ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs)
118
  : ctype<wchar_t>(__refs)
119
  {
120
    if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
121
      {
122
        this->_S_destroy_c_locale(this->_M_c_locale_ctype);
123
        this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
124
        this->_M_initialize_ctype();
125
      }
126
  }
127
 
128
  ctype_byname<wchar_t>::~ctype_byname()
129
  { }
130
 
131
#endif
132
 
133
_GLIBCXX_END_NAMESPACE_VERSION
134
} // namespace

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.