genflags.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* Copyright (C) 2000-2002, 2005-2006, 2008-2009, 2016 Free Software Foundation, Inc.
  2. This file is part of the GNU LIBICONV Library.
  3. The GNU LIBICONV Library is free software; you can redistribute it
  4. and/or modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. The GNU LIBICONV Library is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU LIBICONV Library; see the file COPYING.LIB.
  13. If not, see <http://www.gnu.org/licenses/>. */
  14. /* Creates the flags.h include file. */
  15. #include <limits.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. /* Avoid lots of warnings from "gcc -Wall". */
  20. #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) || __GNUC__ > 4
  21. # pragma GCC diagnostic ignored "-Wunused-function"
  22. #endif
  23. /* Consider all encodings, including the system dependent ones. */
  24. #define USE_AIX
  25. #define USE_OSF1
  26. #define USE_DOS
  27. #define USE_EXTRA
  28. struct loop_funcs {};
  29. struct iconv_fallbacks {};
  30. struct iconv_hooks {};
  31. #include "converters.h"
  32. static void emit_encoding (struct wctomb_funcs * ofuncs, const char* c_name)
  33. {
  34. /* Prepare a converter struct. */
  35. struct conv_struct conv;
  36. memset(&conv,'\0',sizeof(conv));
  37. conv.ofuncs = *ofuncs;
  38. {
  39. /* See whether the encoding can encode the accents and quotation marks. */
  40. ucs4_t probe[6] = { 0x0060, 0x00b4, 0x2018, 0x2019, 0x3131, 0x3163, };
  41. int res[6];
  42. int i;
  43. for (i = 0; i < 6; i++) {
  44. unsigned char buf[10];
  45. memset(&conv.ostate,'\0',sizeof(state_t));
  46. res[i] = (conv.ofuncs.xxx_wctomb(&conv,buf,probe[i],sizeof(buf)) != RET_ILUNI);
  47. }
  48. printf("#define ei_%s_oflags (",c_name);
  49. {
  50. int first = 1;
  51. if (res[0] && res[1]) {
  52. printf("HAVE_ACCENTS");
  53. first = 0;
  54. }
  55. if (res[2] && res[3]) {
  56. if (!first) printf(" | ");
  57. printf("HAVE_QUOTATION_MARKS");
  58. first = 0;
  59. }
  60. if (res[4] && res[5]) {
  61. if (!first) printf(" | ");
  62. printf("HAVE_HANGUL_JAMO");
  63. first = 0;
  64. }
  65. if (first) printf("0");
  66. }
  67. printf(")\n");
  68. }
  69. }
  70. int main ()
  71. {
  72. int bitmask = 1;
  73. printf("/* Generated automatically by genflags. */\n");
  74. printf("\n");
  75. printf("/* Set if the encoding can encode\n");
  76. printf(" the acute and grave accents U+00B4 and U+0060. */\n");
  77. printf("#define HAVE_ACCENTS %d\n",bitmask);
  78. printf("\n");
  79. bitmask = bitmask << 1;
  80. printf("/* Set if the encoding can encode\n");
  81. printf(" the single quotation marks U+2018 and U+2019. */\n");
  82. printf("#define HAVE_QUOTATION_MARKS %d\n",bitmask);
  83. printf("\n");
  84. bitmask = bitmask << 1;
  85. printf("/* Set if the encoding can encode\n");
  86. printf(" the double-width Hangul letters (Jamo) U+3131 to U+3163. */\n");
  87. printf("#define HAVE_HANGUL_JAMO %d\n",bitmask);
  88. printf("\n");
  89. #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
  90. { \
  91. struct wctomb_funcs ofuncs = xxx_ofuncs1,xxx_ofuncs2; \
  92. emit_encoding(&ofuncs,#xxx); \
  93. }
  94. #define DEFALIAS(xxx_alias,xxx) /* nothing */
  95. /* Consider all encodings, including the system dependent ones. */
  96. #include "encodings.def"
  97. #include "encodings_aix.def"
  98. #include "encodings_osf1.def"
  99. #include "encodings_dos.def"
  100. #include "encodings_extra.def"
  101. #undef DEFALIAS
  102. #undef DEFENCODING
  103. if (ferror(stdout) || fclose(stdout))
  104. exit(1);
  105. exit(0);
  106. }