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.
4
5   The GNU C Library is free software; you can redistribute it and/or
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.
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   Lesser General Public License for more details.
14
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.  */
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
34void
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 char *__ctype32_wctype[12];
44  extern const char *__ctype32_wctrans[2];
45
46  size_t offset, cnt;
47
48  offset = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_CLASS_OFFSET);
49  for (cnt = 0; cnt < 12; cnt++)
50    __ctype32_wctype[cnt] = _nl_global_locale.__locales[LC_CTYPE]->values[offset + cnt].string;
51
52  offset = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET);
53  for (cnt = 0; cnt < 2; cnt++)
54    __ctype32_wctrans[cnt] = _nl_global_locale.__locales[LC_CTYPE]->values[offset + cnt].string;
55}
56