summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-06-06 14:43:04 -0600
committerKarl Williamson <khw@cpan.org>2014-06-07 10:24:59 -0600
commit8ee4b76954b91d3bb381880248e4b3e0fa5e65d5 (patch)
tree45ad9498343611ce04885d6f973de1e35c69b5f3
parent2376ab1f7929a7a9f33c6ed28ac0f7c3361894c2 (diff)
downloadperl-8ee4b76954b91d3bb381880248e4b3e0fa5e65d5.tar.gz
locale.c: Fix uncomplemented 'if' test
Somehow the ! in this if () got dropped, and there were no tests to catch it. Now both are remedied.
-rw-r--r--lib/locale.t16
-rw-r--r--locale.c2
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/locale.t b/lib/locale.t
index 04ad46e3d5..1463579ae2 100644
--- a/lib/locale.t
+++ b/lib/locale.t
@@ -1667,6 +1667,7 @@ foreach my $Locale (@Locale) {
my $ok18;
my $ok19;
my $ok20;
+ my $ok21;
my $c;
my $d;
@@ -1823,6 +1824,18 @@ foreach my $Locale (@Locale) {
$ok20 = $date =~ / ^ \p{ASCII}+ $ /x || utf8::is_utf8($date);
}
+ $ok21 = 1;
+ foreach my $err (keys %!) {
+ no locale;
+ use Errno;
+ $! = eval "&Errno::$err"; # Convert to strerror() output
+ my $strerror = "$!";
+ if ("$strerror" =~ /\P{ASCII}/) {
+ $ok21 = 0;
+ last;
+ }
+ }
+
report_result($Locale, ++$locales_test_number, $ok1);
$test_names{$locales_test_number} = 'Verify that an intervening printf doesn\'t change assignment results';
my $first_a_test = $locales_test_number;
@@ -1906,6 +1919,9 @@ foreach my $Locale (@Locale) {
report_result($Locale, ++$locales_test_number, $ok20);
$test_names{$locales_test_number} = 'Verify that strftime returns date with UTF-8 flag appropriately set';
+ report_result($Locale, ++$locales_test_number, $ok21);
+ $test_names{$locales_test_number} = '"$!" is ASCII only outside of locale scope';
+
debug "# $first_f_test..$locales_test_number: \$f = $f, \$g = $g, back to locale = $Locale\n";
# Does taking lc separately differ from taking
diff --git a/locale.c b/locale.c
index 0ecce3cebb..64c0d8d6f1 100644
--- a/locale.c
+++ b/locale.c
@@ -1414,7 +1414,7 @@ Perl_my_strerror(pTHX_ const int errnum) {
* LC_MESSAGES */
#ifdef USE_LOCALE_MESSAGES
- if (IN_LC(LC_MESSAGES)) {
+ if (! IN_LC(LC_MESSAGES)) {
char * save_locale = setlocale(LC_MESSAGES, NULL);
if (! ((*save_locale == 'C' && save_locale[1] == '\0')
|| strEQ(save_locale, "POSIX")))