ctype_noninline.h revision 132720
1129473Spjd// Locale support -*- C++ -*-
2142727Spjd
3129473Spjd// Copyright (C) 2002
4129473Spjd//  Free Software Foundation, Inc.
5129473Spjd//
6129473Spjd// This file is part of the GNU ISO C++ Library.  This library is free
7129473Spjd// software; you can redistribute it and/or modify it under the
8129473Spjd// terms of the GNU General Public License as published by the
9129473Spjd// Free Software Foundation; either version 2, or (at your option)
10129473Spjd// any later version.
11129473Spjd
12129473Spjd// This library is distributed in the hope that it will be useful,
13155174Spjd// but WITHOUT ANY WARRANTY; without even the implied warranty of
14129473Spjd// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15129473Spjd// GNU General Public License for more details.
16129473Spjd
17129473Spjd// You should have received a copy of the GNU General Public License along
18129473Spjd// with this library; see the file COPYING.  If not, write to the Free
19129473Spjd// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20129473Spjd// USA.
21129473Spjd
22129473Spjd// As a special exception, you may use this file as part of a free software
23129473Spjd// library without restriction.  Specifically, if other files instantiate
24129473Spjd// templates or use macros or inline functions from this file, or you compile
25129473Spjd// this file and link it with other files to produce an executable, this
26129473Spjd// file does not by itself cause the resulting executable to be covered by
27129473Spjd// the GNU General Public License.  This exception does not however
28129473Spjd// invalidate any other reasons why the executable file might be covered by
29129473Spjd// the GNU General Public License.
30129473Spjd
31129473Spjd//
32129473Spjd// ISO C++ 14882: 22.1  Locales
33129473Spjd//
34129473Spjd
35129473Spjd// Information as gleaned from /usr/include/ctype.h
36129473Spjd
37129473Spjd  const ctype_base::mask*
38129473Spjd  ctype<char>::classic_table() throw()
39131878Spjd  { return 0; }
40129473Spjd
41129473Spjd  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
42129473Spjd		     size_t __refs)
43129473Spjd  : facet(__refs), _M_del(__table != 0 && __del),
44131878Spjd  _M_toupper(NULL), _M_tolower(NULL),
45151897Srwatson  _M_table(__table == 0 ? classic_table() : __table)
46129473Spjd  {
47131878Spjd    memset(_M_widen, 0, sizeof(_M_widen));
48129473Spjd    _M_widen_ok = 0;
49129473Spjd    memset(_M_narrow, 0, sizeof(_M_narrow));
50129473Spjd    _M_narrow_ok = 0;
51129473Spjd  }
52129473Spjd
53129473Spjd  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
54129473Spjd  : facet(__refs), _M_del(__table != 0 && __del),
55129473Spjd  _M_toupper(NULL), _M_tolower(NULL),
56131878Spjd  _M_table(__table == 0 ? classic_table() : __table)
57131878Spjd  {
58129473Spjd    memset(_M_widen, 0, sizeof(_M_widen));
59129473Spjd    _M_widen_ok = 0;
60129473Spjd    memset(_M_narrow, 0, sizeof(_M_narrow));
61133318Sphk    _M_narrow_ok = 0;
62129473Spjd  }
63129473Spjd
64131878Spjd  char
65131878Spjd  ctype<char>::do_toupper(char __c) const
66131878Spjd  { return ::toupper((int) __c); }
67129473Spjd
68129473Spjd  const char*
69131878Spjd  ctype<char>::do_toupper(char* __low, const char* __high) const
70131878Spjd  {
71131878Spjd    while (__low < __high)
72134528Spjd      {
73131878Spjd	*__low = ::toupper((int) *__low);
74131878Spjd	++__low;
75138623Spjd      }
76131878Spjd    return __high;
77131878Spjd  }
78131878Spjd
79131878Spjd  char
80131878Spjd  ctype<char>::do_tolower(char __c) const
81129473Spjd  { return ::tolower((int) __c); }
82131878Spjd
83131878Spjd  const char*
84131878Spjd  ctype<char>::do_tolower(char* __low, const char* __high) const
85131878Spjd  {
86131878Spjd    while (__low < __high)
87131878Spjd      {
88131878Spjd	*__low = ::tolower((int) *__low);
89132095Spjd	++__low;
90138623Spjd      }
91131878Spjd    return __high;
92131878Spjd  }
93132095Spjd