From: Karl Williamson Date: Wed, 22 Jan 2014 21:23:26 +0000 (-0700) Subject: Allow 'use locale' on systems without locales. X-Git-Tag: upstream/5.20.0~630 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a02ae656c54414fd3b04bf8cc53393e5c2438083;p=platform%2Fupstream%2Fperl.git Allow 'use locale' on systems without locales. Instead of throwing an error, just go ahead and do the import. This will tell Perl internally to use the current underlying locale, which should be the C locale. Attempts to change the locale will fail. This differs slightly from Brian Fraser's patch, in that his didn't touch $^H, thus 'use locale' was a no-op. He has told me to apply this one, which does affect $^H. The advantage here is that now programs that are run on platforms with and without locales will behave similarly, and should run identically if the locale is not switched from the default. --- diff --git a/lib/locale.pm b/lib/locale.pm index ed254cc..97b324f 100644 --- a/lib/locale.pm +++ b/lib/locale.pm @@ -1,6 +1,6 @@ package locale; -our $VERSION = '1.02'; +our $VERSION = '1.03'; use Config; $Carp::Internal{ (__PACKAGE__) } = 1; @@ -47,13 +47,8 @@ Unicode and locales, including UTF-8 locales. See L for more detailed information on how Perl supports locales. -=head1 NOTE - -If your system does not support locales, then loading this module will -cause the program to die with a message: - - "Your vendor does not support locales, you cannot use the locale - module." +On systems that don't have locales, this pragma will cause your operations +to behave as if in the "C" locale; attempts to change the locale will fail. =cut @@ -70,11 +65,6 @@ $locale::not_chars_hint_bits = 0x10; sub import { shift; # should be 'locale'; not checked - if(!$Config{d_setlocale}) { - ## No locale support found on this Perl, giving up: - die('Your vendor does not support locales, you cannot use the locale module.'); - } - my $found_not_chars = 0; while (defined (my $arg = shift)) { if ($arg eq ":not_characters") { diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 8ed60ca..7cc963d 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -25,7 +25,13 @@ XXX New core language features go here. Summarize user-visible core language enhancements. Particularly prominent performance optimisations could go here, but most should go in the L section. -[ List each enhancement as a =head2 entry ] +=head2 C> now compiles on systems without locale ability + +Previously doing this caused the program to not compile. Within its +scope the program behaves as if in the "C" locale. Thus programs +written for platforms that support locales can run on locale-less +platforms without change. Attempts to change the locale away from the +"C" locale will, of course, fail. =head1 Security