Update.
[glibc.git] / locale / lc-ctype.c
blobbf7b525129cde9ec5031903bfa55d9d280450d5b
1 /* Define current locale data for LC_CTYPE category.
2 Copyright (C) 1995-1999, 2000 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>
23 #include <stdint.h>
25 _NL_CURRENT_DEFINE (LC_CTYPE);
27 /* We are called after loading LC_CTYPE data to load it into
28 the variables used by the ctype.h macros.
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. */
34 void
35 _nl_postload_ctype (void)
37 #define paste(a,b) paste1(a,b)
38 #define paste1(a,b) a##b
40 #define current(type,x,offset) \
41 ((const type *) _NL_CURRENT (LC_CTYPE, paste(_NL_CTYPE_,x)) + offset)
43 extern const uint32_t *__ctype32_b;
44 extern const uint32_t *__ctype32_toupper;
45 extern const uint32_t *__ctype32_tolower;
46 extern const char *__ctype32_wctype[12];
47 extern const char *__ctype32_wctrans[2];
48 extern const char *__ctype32_width;
50 size_t offset, cnt;
52 __ctype_b = current (uint16_t, CLASS, 128);
53 __ctype_toupper = current (uint32_t, TOUPPER, 128);
54 __ctype_tolower = current (uint32_t, TOLOWER, 128);
55 __ctype32_b = current (uint32_t, CLASS32, 0);
56 __ctype32_toupper = current (uint32_t, TOUPPER32, 0);
57 __ctype32_tolower = current (uint32_t, TOLOWER32, 0);
59 offset = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_CLASS_OFFSET);
60 for (cnt = 0; cnt < 12; cnt++)
61 __ctype32_wctype[cnt] = _nl_current_LC_CTYPE->values[offset + cnt].string;
63 offset = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET);
64 for (cnt = 0; cnt < 2; cnt++)
65 __ctype32_wctrans[cnt] = _nl_current_LC_CTYPE->values[offset + cnt].string;
67 __ctype32_width = current (char, WIDTH, 0);