genflags.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* Copyright (C) 2000-2002, 2005-2006, 2008-2009 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, write to the Free Software Foundation, Inc., 51 Franklin Street,
  14. Fifth Floor, Boston, MA 02110-1301, USA. */
  15. /* Creates the flags.h include file. */
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. /* Consider all encodings, including the system dependent ones. */
  20. #define USE_AIX
  21. #define USE_OSF1
  22. #define USE_DOS
  23. #define USE_EXTRA
  24. struct loop_funcs {};
  25. struct iconv_fallbacks {};
  26. struct iconv_hooks {};
  27. #include "converters.h"
  28. static void emit_encoding (struct wctomb_funcs * ofuncs, const char* c_name)
  29. {
  30. /* Prepare a converter struct. */
  31. struct conv_struct conv;
  32. memset(&conv,'\0',sizeof(conv));
  33. conv.ofuncs = *ofuncs;
  34. {
  35. /* See whether the encoding can encode the accents and quotation marks. */
  36. ucs4_t probe[6] = { 0x0060, 0x00b4, 0x2018, 0x2019, 0x3131, 0x3163, };
  37. int res[6];
  38. int i;
  39. for (i = 0; i < 6; i++) {
  40. unsigned char buf[10];
  41. memset(&conv.ostate,'\0',sizeof(state_t));
  42. res[i] = (conv.ofuncs.xxx_wctomb(&conv,buf,probe[i],sizeof(buf)) != RET_ILUNI);
  43. }
  44. printf("#define ei_%s_oflags (",c_name);
  45. {
  46. int first = 1;
  47. if (res[0] && res[1]) {
  48. printf("HAVE_ACCENTS");
  49. first = 0;
  50. }
  51. if (res[2] && res[3]) {
  52. if (!first) printf(" | ");
  53. printf("HAVE_QUOTATION_MARKS");
  54. first = 0;
  55. }
  56. if (res[4] && res[5]) {
  57. if (!first) printf(" | ");
  58. printf("HAVE_HANGUL_JAMO");
  59. first = 0;
  60. }
  61. if (first) printf("0");
  62. }
  63. printf(")\n");
  64. }
  65. }
  66. int main ()
  67. {
  68. int bitmask = 1;
  69. printf("/* Generated automatically by genflags. */\n");
  70. printf("\n");
  71. printf("/* Set if the encoding can encode\n");
  72. printf(" the acute and grave accents U+00B4 and U+0060. */\n");
  73. printf("#define HAVE_ACCENTS %d\n",bitmask);
  74. printf("\n");
  75. bitmask = bitmask << 1;
  76. printf("/* Set if the encoding can encode\n");
  77. printf(" the single quotation marks U+2018 and U+2019. */\n");
  78. printf("#define HAVE_QUOTATION_MARKS %d\n",bitmask);
  79. printf("\n");
  80. bitmask = bitmask << 1;
  81. printf("/* Set if the encoding can encode\n");
  82. printf(" the double-width Hangul letters (Jamo) U+3131 to U+3163. */\n");
  83. printf("#define HAVE_HANGUL_JAMO %d\n",bitmask);
  84. printf("\n");
  85. #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
  86. { \
  87. struct wctomb_funcs ofuncs = xxx_ofuncs1,xxx_ofuncs2; \
  88. emit_encoding(&ofuncs,#xxx); \
  89. }
  90. #define DEFALIAS(xxx_alias,xxx) /* nothing */
  91. /* Consider all encodings, including the system dependent ones. */
  92. #include "encodings.def"
  93. #include "encodings_aix.def"
  94. #include "encodings_osf1.def"
  95. #include "encodings_dos.def"
  96. #include "encodings_extra.def"
  97. #undef DEFALIAS
  98. #undef DEFENCODING
  99. if (ferror(stdout) || fclose(stdout))
  100. exit(1);
  101. exit(0);
  102. }