]>
Commit | Line | Data |
---|---|---|
933e73fa | 1 | /* Define current locale data for LC_CTYPE category. |
169ec09e | 2 | Copyright (C) 1995-1999, 2000, 2002 Free Software Foundation, Inc. |
c84142e8 | 3 | This file is part of the GNU C Library. |
933e73fa | 4 | |
c84142e8 | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
933e73fa | 9 | |
c84142e8 UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
933e73fa | 14 | |
41bdb6e2 AJ |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
933e73fa RM |
19 | |
20 | #include "localeinfo.h" | |
21 | #include <ctype.h> | |
22 | #include <endian.h> | |
4b10dd6c | 23 | #include <stdint.h> |
933e73fa RM |
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 | { | |
d20fec5d | 37 | const struct locale_data *data = _NL_CURRENT_DATA (LC_CTYPE); |
174d73a3 | 38 | |
d8cc5f0c RM |
39 | #define paste(a,b) paste1(a,b) |
40 | #define paste1(a,b) a##b | |
933e73fa | 41 | |
75cd5204 RM |
42 | #define current(type,x,offset) \ |
43 | ((const type *) _NL_CURRENT (LC_CTYPE, paste(_NL_CTYPE_,x)) + offset) | |
933e73fa | 44 | |
d20fec5d UD |
45 | extern const uint32_t *__ctype32_b; |
46 | extern const uint32_t *__ctype32_toupper; | |
47 | extern const uint32_t *__ctype32_tolower; | |
48 | extern const char *__ctype32_wctype[12] attribute_hidden; | |
49 | extern const char *__ctype32_wctrans[2] attribute_hidden; | |
50 | extern const char *__ctype32_width attribute_hidden; | |
51 | ||
52 | size_t offset, cnt; | |
53 | ||
54 | __ctype_b = current (uint16_t, CLASS, 128); | |
55 | __ctype_toupper = current (uint32_t, TOUPPER, 128); | |
56 | __ctype_tolower = current (uint32_t, TOLOWER, 128); | |
57 | __ctype32_b = current (uint32_t, CLASS32, 0); | |
58 | __ctype32_toupper = current (uint32_t, TOUPPER32, 0); | |
59 | __ctype32_tolower = current (uint32_t, TOLOWER32, 0); | |
60 | ||
61 | offset = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_CLASS_OFFSET); | |
62 | for (cnt = 0; cnt < 12; cnt++) | |
63 | __ctype32_wctype[cnt] = data->values[offset + cnt].string; | |
64 | ||
65 | offset = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET); | |
66 | for (cnt = 0; cnt < 2; cnt++) | |
67 | __ctype32_wctrans[cnt] = data->values[offset + cnt].string; | |
68 | ||
69 | __ctype32_width = current (char, WIDTH, 0); | |
933e73fa | 70 | } |