1169691Skan// Locale support -*- C++ -*-
2169691Skan
3169691Skan// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006
4169691Skan// Free Software Foundation, Inc.
5169691Skan//
6169691Skan// This file is part of the GNU ISO C++ Library.  This library is free
7169691Skan// software; you can redistribute it and/or modify it under the
8169691Skan// terms of the GNU General Public License as published by the
9169691Skan// Free Software Foundation; either version 2, or (at your option)
10169691Skan// any later version.
11169691Skan
12169691Skan// This library is distributed in the hope that it will be useful,
13169691Skan// but WITHOUT ANY WARRANTY; without even the implied warranty of
14169691Skan// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15169691Skan// GNU General Public License for more details.
16169691Skan
17169691Skan// You should have received a copy of the GNU General Public License along
18169691Skan// with this library; see the file COPYING.  If not, write to the Free
19169691Skan// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20169691Skan// USA.
21169691Skan
22169691Skan// As a special exception, you may use this file as part of a free software
23169691Skan// library without restriction.  Specifically, if other files instantiate
24169691Skan// templates or use macros or inline functions from this file, or you compile
25169691Skan// this file and link it with other files to produce an executable, this
26169691Skan// file does not by itself cause the resulting executable to be covered by
27169691Skan// the GNU General Public License.  This exception does not however
28169691Skan// invalidate any other reasons why the executable file might be covered by
29169691Skan// the GNU General Public License.
30169691Skan
31169691Skan/** @file ctype_noninline.h
32169691Skan *  This is an internal header file, included by other library headers.
33169691Skan *  You should not attempt to use it directly.
34169691Skan */
35169691Skan
36169691Skan//
37169691Skan// ISO C++ 14882: 22.1  Locales
38169691Skan//
39169691Skan
40169691Skan// Information as gleaned from /usr/include/ctype.h
41169691Skan
42169691Skan  const ctype_base::mask*
43169691Skan  ctype<char>::classic_table() throw()
44169691Skan  { return __C_ctype_b; }
45169691Skan
46169691Skan  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
47169691Skan		     size_t __refs)
48169691Skan  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
49169691Skan  _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
50169691Skan  {
51169691Skan    _M_toupper = __C_ctype_toupper;
52169691Skan    _M_tolower = __C_ctype_tolower;
53169691Skan    _M_table = __table ? __table : __C_ctype_b;
54169691Skan    memset(_M_widen, 0, sizeof(_M_widen));
55169691Skan    memset(_M_narrow, 0, sizeof(_M_narrow));
56169691Skan  }
57169691Skan
58169691Skan  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
59169691Skan  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
60169691Skan  _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
61169691Skan  {
62169691Skan    _M_toupper = __C_ctype_toupper;
63169691Skan    _M_tolower = __C_ctype_tolower;
64169691Skan    _M_table = __table ? __table : __C_ctype_b;
65169691Skan    memset(_M_widen, 0, sizeof(_M_widen));
66169691Skan    memset(_M_narrow, 0, sizeof(_M_narrow));
67169691Skan  }
68169691Skan
69169691Skan  char
70169691Skan  ctype<char>::do_toupper(char __c) const
71169691Skan  { return _M_toupper[static_cast<unsigned char>(__c)]; }
72169691Skan
73169691Skan  const char*
74169691Skan  ctype<char>::do_toupper(char* __low, const char* __high) const
75169691Skan  {
76169691Skan    while (__low < __high)
77169691Skan      {
78169691Skan	*__low = _M_toupper[static_cast<unsigned char>(*__low)];
79169691Skan	++__low;
80169691Skan      }
81169691Skan    return __high;
82169691Skan  }
83169691Skan
84169691Skan  char
85169691Skan  ctype<char>::do_tolower(char __c) const
86169691Skan  { return _M_tolower[static_cast<unsigned char>(__c)]; }
87169691Skan
88169691Skan  const char*
89169691Skan  ctype<char>::do_tolower(char* __low, const char* __high) const
90169691Skan  {
91169691Skan    while (__low < __high)
92169691Skan      {
93169691Skan	*__low = _M_tolower[static_cast<unsigned char>(*__low)];
94169691Skan	++__low;
95169691Skan      }
96169691Skan    return __high;
97169691Skan  }
98