1 /* Copyright (C) 1995 Free Software Foundation, Inc.
3 The GNU C Library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public License as
5 published by the Free Software Foundation; either version 2 of the
6 License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public
14 License along with the GNU C Library; see the file COPYING.LIB. If
15 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
16 Cambridge, MA 02139, USA. */
22 #include <netinet/in.h> /* Just for htons() */
24 #include "localedef.h"
25 #include "localeinfo.h"
28 /* FIXME: these values should be part of the LC_CTYPE information. */
34 ((u32) (((((u32) (v)) & 0x000000ff) << 24) \
35 | ((((u32) (v)) & 0x0000ff00) << 8) \
36 | ((((u32) (v)) & 0x00ff0000) >> 8) \
37 | ((((u32) (v)) & 0xff000000) >> 24)))
42 print_short_in_char (unsigned short val
)
44 const unsigned char *p
= (const unsigned char *) &val
;
45 printf ("\"\\%03o\\%03o\"", p
[0], p
[1]);
50 print_int_in_char (unsigned int val
)
52 const unsigned char *p
= (const unsigned char *) &val
;
53 printf ("\"\\%03o\\%03o\\%03o\\%03o\"", p
[0], p
[1], p
[2], p
[3]);
62 const char *locname
= (getenv ("LC_ALL") ?: getenv ("LC_CTYPE") ?:
63 getenv ("LANG") ?: "POSIX");
65 puts ("#include <endian.h>\n");
69 printf ("const char _nl_%s_LC_CTYPE_class[] = \n", locname
);
70 for (ch
= -128; ch
< (1 << (8 * MB_CUR_MAX
)); ++ch
)
72 if (((ch
+ 128) % 6) == 0)
73 printf (" /* 0x%02x */ ", ch
< 0 ? 256 + ch
: ch
);
74 print_short_in_char (htons (__ctype_b
[ch
< 0 ? 256 + ch
: ch
]));
75 fputc (((ch
+ 128) % 6) == 5 ? '\n' : ' ', stdout
);
80 printf ("#if BYTE_ORDER == %s\n",
81 BYTE_ORDER
== LITTLE_ENDIAN
? "LITTLE_ENDIAN" : "BIG_ENDIAN");
85 printf ("const char _nl_%s_LC_CTYPE_toupper[] = \n", locname
);
86 for (ch
= -128; ch
< (1 << (8 * MB_CUR_MAX
)); ++ch
)
88 if (((ch
+ 128) % 3) == 0)
89 printf (" /* 0x%02x */ ", ch
< 0 ? 256 + ch
: ch
);
90 print_int_in_char (__ctype_toupper
[ch
< 0 ? 256 + ch
: ch
]);
91 fputc (((ch
+ 128) % 3) == 2 ? '\n' : ' ', stdout
);
95 printf ("const char _nl_%s_LC_CTYPE_tolower[] = \n", locname
);
96 for (ch
= -128; ch
< (1 << (8 * MB_CUR_MAX
)); ++ch
)
98 if (((ch
+ 128) % 3) == 0)
99 printf (" /* 0x%02x */ ", ch
< 0 ? 256 + ch
: ch
);
100 print_int_in_char (__ctype_tolower
[ch
< 0 ? 256 + ch
: ch
]);
101 fputc (((ch
+ 128) % 3) == 2 ? '\n' : ' ', stdout
);
106 /* not implemented */;
108 printf ("#elif BYTE_ORDER == %s\n",
109 BYTE_ORDER
== LITTLE_ENDIAN
? "BIG_ENDIAN" : "LITTLE_ENDIAN");
113 printf ("const char _nl_%s_LC_CTYPE_toupper[] = \n", locname
);
114 for (ch
= -128; ch
< (1 << (8 * MB_CUR_MAX
)); ++ch
)
116 if (((ch
+ 128) % 3) == 0)
117 printf (" /* 0x%02x */ ", ch
< 0 ? 256 + ch
: ch
);
118 print_int_in_char (SWAP32 (__ctype_toupper
[ch
< 0 ? 256 + ch
: ch
]));
119 fputc (((ch
+ 128) % 3) == 2 ? '\n' : ' ', stdout
);
123 printf ("const char _nl_%s_LC_CTYPE_tolower[] = \n", locname
);
124 for (ch
= -128; ch
< (1 << (8 * MB_CUR_MAX
)); ++ch
)
126 if (((ch
+ 128) % 3) == 0)
127 printf (" /* 0x%02x */ ", ch
< 0 ? 256 + ch
: ch
);
128 print_int_in_char (SWAP32 (__ctype_tolower
[ch
< 0 ? 256 + ch
: ch
]));
129 fputc (((ch
+ 128) % 3) == 2 ? '\n' : ' ', stdout
);
134 /* not implemented */;
136 puts ("#else\n#error \"BYTE_ORDER\" BYTE_ORDER \" not handled.\"\n#endif\n");
138 printf("const struct locale_data _nl_%s_LC_CTYPE = \n\
140 NULL, 0, /* no file mapped */\n\
143 _nl_C_LC_CTYPE_class,\n\
144 #ifdef BYTE_ORDER == LITTLE_ENDIAN\n\
147 _nl_C_LC_CTYPE_toupper,\n\
148 _nl_C_LC_CTYPE_tolower,\n\
149 #ifdef BYTE_ORDER == BIG_ENDIAN\n\