Strictly check whether catalog file is larger enough for the data.
[glibc.git] / locale / lc-ctype.c
blobd2139aeb3117f17a295434e3914e3f58d98f3ee2
1 /* Define current locale data for LC_CTYPE category.
2 Copyright (C) 1995, 1996, 1997 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 not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, 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);