bug-usesetlocale.c 781 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* Test case for setlocale vs uselocale (LC_GLOBAL_LOCALE) bug. */
  2. #define _GNU_SOURCE 1
  3. #include <locale.h>
  4. #include <stdio.h>
  5. #include <ctype.h>
  6. static int
  7. do_test (void)
  8. {
  9. __locale_t loc_new, loc_old;
  10. int first = !!isalpha(0xE4);
  11. setlocale (LC_ALL, "de_DE");
  12. int global_de = !!isalpha(0xE4);
  13. loc_new = newlocale (1 << LC_ALL, "C", 0);
  14. loc_old = uselocale (loc_new);
  15. int used_c = !!isalpha(0xE4);
  16. uselocale (loc_old);
  17. int used_global = !!isalpha(0xE4);
  18. printf ("started %d, after setlocale %d\n", first, global_de);
  19. printf ("after uselocale %d, after LC_GLOBAL_LOCALE %d\n",
  20. used_c, used_global);
  21. freelocale (loc_new);
  22. return !(used_c == first && used_global == global_de);
  23. }
  24. #define TEST_FUNCTION do_test ()
  25. #include "test-skeleton.c"