Thu Jun 13 00:02:25 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / locale / lc-ctype.c
blob2eeedf84663693103f493b731c099da79f062100
1 /* Define current locale data for LC_CTYPE category.
2 Copyright (C) 1995, 1996 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA. */
20 #include "localeinfo.h"
21 #include <ctype.h>
22 #include <endian.h>
24 _NL_CURRENT_DEFINE (LC_CTYPE);
26 /* We are called after loading LC_CTYPE data to load it into
27 the variables used by the ctype.h macros.
29 There are three arrays of short ints which need to be indexable
30 from -128 to 255 inclusive. Stored in the locale data file are
31 a copy of each for each byte order. */
33 void
34 _nl_postload_ctype (void)
36 #if BYTE_ORDER == BIG_ENDIAN
37 #define bo(x) x##_EB
38 #elif BYTE_ORDER == LITTLE_ENDIAN
39 #define bo(x) x##_EL
40 #else
41 #error bizarre byte order
42 #endif
43 #define paste(a,b) paste1(a,b)
44 #define paste1(a,b) a##b
46 #define current(type,x,offset) \
47 ((const type *) _NL_CURRENT (LC_CTYPE, paste(_NL_CTYPE_,x)) + offset)
49 extern const unsigned int *__ctype32_b;
50 extern const unsigned int *__ctype_names;
51 extern const unsigned char *__ctype_width;
53 __ctype_b = current (unsigned short int, CLASS, 128);
54 __ctype_toupper = current (int, bo (TOUPPER), 128);
55 __ctype_tolower = current (int, bo (TOLOWER), 128);
56 __ctype32_b = current (unsigned int, CLASS32, 0);
57 __ctype_names = current (unsigned int, bo (NAMES), 0);
58 __ctype_width = current (unsigned char, WIDTH, 0);