| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* Test case for setlocale vs uselocale (LC_GLOBAL_LOCALE) bug.  */ | 
|  | 2 |  | 
|  | 3 | #define _GNU_SOURCE 1 | 
|  | 4 | #include <locale.h> | 
|  | 5 | #include <stdio.h> | 
|  | 6 | #include <ctype.h> | 
|  | 7 |  | 
|  | 8 | static int | 
|  | 9 | do_test (void) | 
|  | 10 | { | 
|  | 11 | __locale_t loc_new, loc_old; | 
|  | 12 |  | 
|  | 13 | int first = !!isalpha(0xE4); | 
|  | 14 |  | 
|  | 15 | setlocale (LC_ALL, "de_DE"); | 
|  | 16 |  | 
|  | 17 | int global_de = !!isalpha(0xE4); | 
|  | 18 |  | 
|  | 19 | loc_new = newlocale (1 << LC_ALL, "C", 0); | 
|  | 20 | loc_old = uselocale (loc_new); | 
|  | 21 |  | 
|  | 22 | int used_c = !!isalpha(0xE4); | 
|  | 23 |  | 
|  | 24 | uselocale (loc_old); | 
|  | 25 |  | 
|  | 26 | int used_global = !!isalpha(0xE4); | 
|  | 27 |  | 
|  | 28 | printf ("started %d, after setlocale %d\n", first, global_de); | 
|  | 29 | printf ("after uselocale %d, after LC_GLOBAL_LOCALE %d\n", | 
|  | 30 | used_c, used_global); | 
|  | 31 |  | 
|  | 32 | freelocale (loc_new); | 
|  | 33 | return !(used_c == first && used_global == global_de); | 
|  | 34 | } | 
|  | 35 |  | 
|  | 36 |  | 
|  | 37 | #define TEST_FUNCTION do_test () | 
|  | 38 | #include "test-skeleton.c" |