tst-translit-mchar.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Test multi-character transliterations.
  2. Copyright (C) 2024-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <locale.h>
  16. #include <iconv.h>
  17. #include <support/support.h>
  18. #include <support/check.h>
  19. static int
  20. do_test (void)
  21. {
  22. iconv_t cd;
  23. /* An input sequence that shares a common prefix with a transliteration
  24. rule. */
  25. char input[] = "ÄÅ";
  26. char *inptr = input;
  27. char outbuf[10];
  28. char *outptr = outbuf;
  29. size_t inlen = sizeof (input), outlen = sizeof (outbuf);
  30. size_t n;
  31. xsetlocale (LC_CTYPE, "tst-translit");
  32. cd = iconv_open ("ASCII//TRANSLIT", "UTF-8");
  33. TEST_VERIFY (cd != (iconv_t) -1);
  34. /* This call used to loop infinitely. */
  35. n = iconv (cd, &inptr, &inlen, &outptr, &outlen);
  36. TEST_VERIFY (iconv_close (cd) == 0);
  37. return n == 0;
  38. }
  39. #include <support/test-driver.c>