removed old libs
[TestXSLT.git] / libiconv / lib / genaliases.c
1 /* Copyright (C) 1999-2001 Free Software Foundation, Inc.
2    This file is part of the GNU LIBICONV Library.
3
4    The GNU LIBICONV Library is free software; you can redistribute it
5    and/or modify it under the terms of the GNU Library General Public
6    License as published by the Free Software Foundation; either version 2
7    of the License, or (at your option) any later version.
8
9    The GNU LIBICONV Library is distributed in the hope that it will be
10    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13
14    You should have received a copy of the GNU Library General Public
15    License along with the GNU LIBICONV Library; see the file COPYING.LIB.
16    If not, write to the Free Software Foundation, Inc., 59 Temple Place -
17    Suite 330, Boston, MA 02111-1307, USA.  */
18
19 /* Creates the aliases.gperf table. */
20
21 #include <stdio.h>
22 #include <stdlib.h>
23
24 static void emit_encoding (const char* const* names, size_t n, const char* c_name)
25 {
26   for (; n > 0; names++, n--) {
27     /* Output *names in upper case. */
28     const char* s = *names;
29     for (; *s; s++) {
30       unsigned char c = * (unsigned char *) s;
31       if (c >= 0x80)
32         exit(1);
33       if (c >= 'a' && c <= 'z')
34         c -= 'a'-'A';
35       putc(c, stdout);
36     }
37     printf(", ei_%s\n", c_name);
38   }
39 }
40
41 int main ()
42 {
43   printf("struct alias { const char* name; unsigned int encoding_index; };\n");
44   printf("%%%%\n");
45
46 #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
47   {                                                           \
48     static const char* const names[] = BRACIFY xxx_names;     \
49     emit_encoding(names,sizeof(names)/sizeof(names[0]),#xxx); \
50   }
51 #define BRACIFY(...) { __VA_ARGS__ }
52 #include "encodings.def"
53 #include "encodings_local.def"
54 #undef BRACIFY
55 #undef DEFENCODING
56
57   fflush(stdout);
58   if (ferror(stdout))
59     exit(1);
60   exit(0);
61 }