Update.
[platform/upstream/glibc.git] / locale / lc-ctype.c
1 /* Define current locale data for LC_CTYPE category.
2    Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    The GNU C 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 GNU
13    Library General Public License for more details.
14
15    You should have received a copy of the GNU Library General Public
16    License along with the GNU C Library; see the file COPYING.LIB.  If not,
17    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18    Boston, MA 02111-1307, USA.  */
19
20 #include "localeinfo.h"
21 #include <ctype.h>
22 #include <endian.h>
23 #include <stdint.h>
24
25 _NL_CURRENT_DEFINE (LC_CTYPE);
26
27 /* We are called after loading LC_CTYPE data to load it into
28    the variables used by the ctype.h macros.
29
30    There are three arrays of short ints which need to be indexable
31    from -128 to 255 inclusive.  Stored in the locale data file are
32    a copy of each for each byte order.  */
33
34 void
35 _nl_postload_ctype (void)
36 {
37 #define paste(a,b) paste1(a,b)
38 #define paste1(a,b) a##b
39
40 #define current(type,x,offset) \
41   ((const type *) _NL_CURRENT (LC_CTYPE, paste(_NL_CTYPE_,x)) + offset)
42
43   extern const uint32_t *__ctype32_b;
44   extern const uint32_t *__ctype_names;
45   extern const unsigned char *__ctype_width;
46
47   __ctype_b = current (uint16_t, CLASS, 128);
48   __ctype_toupper = current (uint32_t, TOUPPER, 128);
49   __ctype_tolower = current (uint32_t, TOLOWER, 128);
50   __ctype32_b = current (uint32_t, CLASS32, 0);
51   __ctype_names = current (uint32_t, NAMES, 0);
52   __ctype_width = current (unsigned char, WIDTH, 0);
53 }