Switch to autoconf 2.72.
[libiconv.git] / lib / genflags.c
blob9f3d15d2ee3af6ddc363fe735eeb175aabda5083
1 /* Copyright (C) 2000-2002, 2005-2006, 2008-2009, 2016, 2022-2023 Free Software Foundation, Inc.
2 This file is part of the GNU LIBICONV Library.
4 The GNU LIBICONV Library is free software; you can redistribute it
5 and/or modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either version 2.1
7 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU LIBICONV Library; see the file COPYING.LIB.
16 If not, see <https://www.gnu.org/licenses/>. */
18 /* Creates the flags.h include file. */
20 #include <limits.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
25 /* Avoid lots of warnings from "gcc -Wall". */
26 #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) || __GNUC__ > 4
27 # pragma GCC diagnostic ignored "-Wunused-function"
28 #endif
30 /* Consider all encodings, including the system dependent ones. */
31 #define USE_AIX
32 #define USE_OSF1
33 #define USE_DOS
34 #define USE_ZOS
35 #define USE_EXTRA
37 struct loop_funcs {};
38 struct iconv_hooks {};
39 struct iconv_fallbacks {};
40 #define ICONV_SURFACE_EBCDIC_ZOS_UNIX 1
41 #include "converters.h"
43 static void emit_encoding (struct wctomb_funcs * ofuncs, const char* c_name)
45 /* Prepare a converter struct. */
46 struct conv_struct conv;
47 memset(&conv,'\0',sizeof(conv));
48 conv.ofuncs = *ofuncs;
51 /* See whether the encoding can encode the accents and quotation marks. */
52 ucs4_t probe[6] = { 0x0060, 0x00b4, 0x2018, 0x2019, 0x3131, 0x3163, };
53 int res[6];
54 int i;
55 for (i = 0; i < 6; i++) {
56 unsigned char buf[10];
57 memset(&conv.ostate,'\0',sizeof(state_t));
58 res[i] = (conv.ofuncs.xxx_wctomb(&conv,buf,probe[i],sizeof(buf)) != RET_ILUNI);
60 printf("#define ei_%s_oflags (",c_name);
62 int first = 1;
63 if (res[0] && res[1]) {
64 printf("HAVE_ACCENTS");
65 first = 0;
67 if (res[2] && res[3]) {
68 if (!first) printf(" | ");
69 printf("HAVE_QUOTATION_MARKS");
70 first = 0;
72 if (res[4] && res[5]) {
73 if (!first) printf(" | ");
74 printf("HAVE_HANGUL_JAMO");
75 first = 0;
77 if (first) printf("0");
79 printf(")\n");
83 int main ()
85 int bitmask = 1;
86 printf("/* Generated automatically by genflags. */\n");
87 printf("\n");
88 printf("/* Set if the encoding can encode\n");
89 printf(" the acute and grave accents U+00B4 and U+0060. */\n");
90 printf("#define HAVE_ACCENTS %d\n",bitmask);
91 printf("\n");
92 bitmask = bitmask << 1;
93 printf("/* Set if the encoding can encode\n");
94 printf(" the single quotation marks U+2018 and U+2019. */\n");
95 printf("#define HAVE_QUOTATION_MARKS %d\n",bitmask);
96 printf("\n");
97 bitmask = bitmask << 1;
98 printf("/* Set if the encoding can encode\n");
99 printf(" the double-width Hangul letters (Jamo) U+3131 to U+3163. */\n");
100 printf("#define HAVE_HANGUL_JAMO %d\n",bitmask);
101 printf("\n");
103 #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
105 struct wctomb_funcs ofuncs = xxx_ofuncs1,xxx_ofuncs2; \
106 emit_encoding(&ofuncs,#xxx); \
108 #define DEFALIAS(xxx_alias,xxx) /* nothing */
109 /* Consider all encodings, including the system dependent ones. */
110 #include "encodings.def"
111 #include "encodings_aix.def"
112 #include "encodings_osf1.def"
113 #include "encodings_dos.def"
114 #include "encodings_zos.def"
115 #include "encodings_extra.def"
116 #undef DEFALIAS
117 #undef DEFENCODING
119 if (ferror(stdout) || fclose(stdout))
120 exit(1);
121 exit(0);