ctype_noninline.h revision 132720
1285809Sscottl// Locale support -*- C++ -*-
2285809Sscottl
3285809Sscottl// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
4285809Sscottl// Free Software Foundation, Inc.
5285809Sscottl//
6285809Sscottl// This file is part of the GNU ISO C++ Library.  This library is free
7285809Sscottl// software; you can redistribute it and/or modify it under the
8285809Sscottl// terms of the GNU General Public License as published by the
9285809Sscottl// Free Software Foundation; either version 2, or (at your option)
10285809Sscottl// any later version.
11285809Sscottl
12285809Sscottl// This library is distributed in the hope that it will be useful,
13285809Sscottl// but WITHOUT ANY WARRANTY; without even the implied warranty of
14285809Sscottl// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15285809Sscottl// GNU General Public License for more details.
16285809Sscottl
17285809Sscottl// You should have received a copy of the GNU General Public License along
18285809Sscottl// with this library; see the file COPYING.  If not, write to the Free
19285809Sscottl// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20285809Sscottl// USA.
21285809Sscottl
22285809Sscottl// As a special exception, you may use this file as part of a free software
23285809Sscottl// library without restriction.  Specifically, if other files instantiate
24285809Sscottl// templates or use macros or inline functions from this file, or you compile
25285809Sscottl// this file and link it with other files to produce an executable, this
26285809Sscottl// file does not by itself cause the resulting executable to be covered by
27285809Sscottl// the GNU General Public License.  This exception does not however
28285809Sscottl// invalidate any other reasons why the executable file might be covered by
29285809Sscottl// the GNU General Public License.
30285809Sscottl
31285809Sscottl//
32285809Sscottl// ISO C++ 14882: 22.1  Locales
33285809Sscottl//
34285809Sscottl
35285809Sscottl// Information as gleaned from /usr/include/ctype.h
36285809Sscottl
37285809Sscottl  const ctype_base::mask*
38285809Sscottl  ctype<char>::classic_table() throw()
39285809Sscottl  { return __SB_masks; }
40285809Sscottl
41285809Sscottl  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
42285809Sscottl		     size_t __refs)
43285809Sscottl  : facet(__refs), _M_del(__table != 0 && __del),
44285809Sscottl  _M_toupper(NULL), _M_tolower(NULL),
45285809Sscottl  _M_table(__table ? __table : (const mask *) __SB_masks)
46285809Sscottl  {
47285809Sscottl    memset(_M_widen, 0, sizeof(_M_widen));
48285809Sscottl    _M_widen_ok = 0;
49285809Sscottl    memset(_M_narrow, 0, sizeof(_M_narrow));
50285809Sscottl    _M_narrow_ok = 0;
51285809Sscottl  }
52285809Sscottl
53285809Sscottl  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
54285809Sscottl  : facet(__refs), _M_del(__table != 0 && __del),
55285809Sscottl  _M_toupper(NULL), _M_tolower(NULL),
56285809Sscottl  _M_table(__table ? __table : (const mask *) __SB_masks)
57285809Sscottl  {
58285809Sscottl    memset(_M_widen, 0, sizeof(_M_widen));
59285809Sscottl    _M_widen_ok = 0;
60285809Sscottl    memset(_M_narrow, 0, sizeof(_M_narrow));
61285809Sscottl    _M_narrow_ok = 0;
62285809Sscottl  }
63285809Sscottl
64285809Sscottl  char
65285809Sscottl  ctype<char>::do_toupper(char __c) const
66285809Sscottl  { return ::toupper((int) __c); }
67285809Sscottl
68285809Sscottl  const char*
69285809Sscottl  ctype<char>::do_toupper(char* __low, const char* __high) const
70285809Sscottl  {
71285809Sscottl    while (__low < __high)
72285809Sscottl      {
73285809Sscottl	*__low = ::toupper((int) *__low);
74285809Sscottl	++__low;
75285809Sscottl      }
76285809Sscottl    return __high;
77285809Sscottl  }
78285809Sscottl
79285809Sscottl  char
80285809Sscottl  ctype<char>::do_tolower(char __c) const
81285809Sscottl  { return ::tolower((int) __c); }
82285809Sscottl
83285809Sscottl  const char*
84285809Sscottl  ctype<char>::do_tolower(char* __low, const char* __high) const
85285809Sscottl  {
86285809Sscottl    while (__low < __high)
87285809Sscottl      {
88285809Sscottl	*__low = ::tolower((int) *__low);
89285809Sscottl	++__low;
90      }
91    return __high;
92  }
93