genaliases2.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Copyright (C) 1999-2003, 2005, 2008 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 aliases2.h table. */
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. static unsigned int counter = 0;
  19. static void emit_alias (FILE* out1, const char* tag, const char* alias, const char* c_name)
  20. {
  21. fprintf(out1," S(%s_%u, \"",tag,counter);
  22. /* Output alias in upper case. */
  23. {
  24. const char* s = alias;
  25. for (; *s; s++) {
  26. unsigned char c = * (unsigned char *) s;
  27. if (c >= 0x80)
  28. exit(1);
  29. if (c >= 'a' && c <= 'z')
  30. c -= 'a'-'A';
  31. putc(c, out1);
  32. }
  33. }
  34. fprintf(out1,"\", ei_%s )\n", c_name);
  35. counter++;
  36. }
  37. static void emit_encoding (FILE* out1, FILE* out2, const char* tag, const char* const* names, size_t n, const char* c_name)
  38. {
  39. fprintf(out2," (int)(long)&((struct stringpool2_t *)0)->stringpool_%s_%u,\n",tag,counter);
  40. for (; n > 0; names++, n--)
  41. emit_alias(out1, tag, *names, c_name);
  42. }