This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
D:P: PATCH: gh #156 sync_locale doesn't work in 5.20 maint
[perl5.git] / dist / Devel-PPPort / parts / inc / locale
CommitLineData
840a8af5
KW
1=provides
2
3__UNDEFINED__
4
5=implementation
6
7
8/* If this doesn't exist, it's not needed, so noop */
9__UNDEFINED__ switch_to_global_locale()
10
11/* Originally, this didn't return a value, but in perls like that, the value
12 * should always be TRUE. Add a return to Perl_sync_locale() when it's
13 * available. And actually do a sync when its not, if locales are available on
14 * this system. */
15#ifdef sync_locale
16# if { VERSION < 5.27.9 }
17# if { VERSION >= 5.21.3 }
18# undef sync_locale
19# define sync_locale() (Perl_sync_locale(aTHX), 1)
da54665f
KW
20# elif defined(sync_locale) /* These should be the 5.20 maints*/
21# undef sync_locale /* Just copy their defn and return 1 */
22# define sync_locale() (new_ctype(setlocale(LC_CTYPE, NULL)), \
23 new_collate(setlocale(LC_COLLATE, NULL)), \
24 set_numeric_local(), \
25 new_numeric(setlocale(LC_NUMERIC, NULL)), \
26 1)
840a8af5
KW
27# elif defined(new_ctype) && defined(LC_CTYPE)
28# define sync_locale() (new_ctype(setlocale(LC_CTYPE, NULL)), 1)
840a8af5
KW
29# endif
30# endif
31#endif
32
33__UNDEFINED__ sync_locale() 1
34
35=xsubs
36
37bool
38sync_locale()
39 CODE:
40 RETVAL = sync_locale();
41 OUTPUT:
42 RETVAL
43
44
45=tests plan => 1
46
47use Config;
48
49 # We don't know for sure that we are in the global locale for testing. But
50 # if this is unthreaded, it almost certainly is. But Configure can be called
51 # to force POSIX locales on unthreaded systems. If this becomes a problem
52 # this check could be beefed up.
53 if ($Config{usethreads}) {
54 ok(1);
55}
56else {
57 ok(&Devel::PPPort::sync_locale());
58}