Back to index

glibc  2.9
bug-usesetlocale.c
Go to the documentation of this file.
00001 /* Test case for setlocale vs uselocale (LC_GLOBAL_LOCALE) bug.  */
00002 
00003 #define _GNU_SOURCE 1
00004 #include <locale.h>
00005 #include <stdio.h>
00006 #include <ctype.h>
00007 
00008 static int
00009 do_test (void)
00010 {
00011   __locale_t loc_new, loc_old;
00012 
00013   int first = !!isalpha(0xE4);
00014 
00015   setlocale (LC_ALL, "de_DE");
00016 
00017   int global_de = !!isalpha(0xE4);
00018 
00019   loc_new = newlocale (1 << LC_ALL, "C", 0);
00020   loc_old = uselocale (loc_new);
00021 
00022   int used_c = !!isalpha(0xE4);
00023 
00024   uselocale (loc_old);
00025 
00026   int used_global = !!isalpha(0xE4);
00027 
00028   printf ("started %d, after setlocale %d\n", first, global_de);
00029   printf ("after uselocale %d, after LC_GLOBAL_LOCALE %d\n",
00030          used_c, used_global);
00031 
00032   freelocale (loc_new);
00033   return !(used_c == first && used_global == global_de);
00034 }
00035 
00036 
00037 #define TEST_FUNCTION do_test ()
00038 #include "test-skeleton.c"