Change 28504 by [EMAIL PROTECTED] on 2006/07/08 01:14:28
Upgrade to encoding-warnings-0.10
Affected files ...
... //depot/perl/MANIFEST#1427 edit
... //depot/perl/lib/encoding/warnings.pm#2 edit
... //depot/perl/lib/encoding/warnings/t/3-normal.t#2 edit
... //depot/perl/lib/encoding/warnings/t/4-lexical.t#1 add
Differences ...
==== //depot/perl/MANIFEST#1427 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#1426~28503~ 2006-07-07 11:38:01.000000000 -0700
+++ perl/MANIFEST 2006-07-07 18:14:28.000000000 -0700
@@ -1614,6 +1614,7 @@
lib/encoding/warnings/t/1-warning.t tests for encoding::warnings
lib/encoding/warnings/t/2-fatal.t tests for encoding::warnings
lib/encoding/warnings/t/3-normal.t tests for encoding::warnings
+lib/encoding/warnings/t/4-lexical.t tests for encoding::warnings
lib/English.pm Readable aliases for short variables
lib/English.t See if English works
lib/Env.pm Map environment into ordinary variables
==== //depot/perl/lib/encoding/warnings.pm#2 (text) ====
Index: perl/lib/encoding/warnings.pm
--- perl/lib/encoding/warnings.pm#1~23980~ 2005-02-18 06:27:38.000000000
-0800
+++ perl/lib/encoding/warnings.pm 2006-07-07 18:14:28.000000000 -0700
@@ -1,10 +1,8 @@
-# $File: //member/autrijus/.vimrc $ $Author: autrijus $
-# $Revision: #14 $ $Change: 4137 $ $DateTime: 2003/02/08 11:41:59 $
-
package encoding::warnings;
-$encoding::warnings::VERSION = '0.05';
+$encoding::warnings::VERSION = '0.10';
use strict;
+use 5.007;
=head1 NAME
@@ -12,8 +10,8 @@
=head1 VERSION
-This document describes version 0.05 of encoding::warnings, released
-July 15, 2004.
+This document describes version 0.10 of encoding::warnings, released
+July 7, 2006.
=head1 SYNOPSIS
@@ -136,9 +134,10 @@
=head1 CAVEATS
-This module currently affects the whole script, instead of inside its
-lexical block. This is expected to be addressed during Perl 5.9 development,
-where the B<encoding> module will also be made lexical.
+For Perl 5.9.4 or later, this module's effect is lexical.
+
+For Perl versions prior to 5.9.4, this module affects the whole script,
+instead of inside its lexical block.
=cut
@@ -163,13 +162,21 @@
undef ${^ENCODING};
# Install a warning handler for decode()
- ${^ENCODING} = bless(
+ my $decoder = bless(
[
$ascii,
$latin1,
(($fatal eq 'FATAL') ? 'Carp::croak' : 'Carp::carp'),
], $class,
);
+
+ ${^ENCODING} = $decoder;
+ $^H{$class} = 1;
+}
+
+sub unimport {
+ my $class = shift;
+ $^H{$class} = undef;
}
# Don't worry about source code literals.
@@ -182,15 +189,24 @@
sub decode {
my $self = shift;
- local $@;
- my $rv = eval { $self->[ASCII]->decode($_[0], Encode::FB_CROAK()) };
- return $rv unless $@;
+ DO_WARN: {
+ if ($] >= 5.009004) {
+ my $hints = (caller(0))[10];
+ $hints->{ref($self)} or last DO_WARN;
+ }
+
+ local $@;
+ my $rv = eval { $self->[ASCII]->decode($_[0], Encode::FB_CROAK()) };
+ return $rv unless $@;
+
+ require Carp;
+ no strict 'refs';
+ $self->[FATAL]->(
+ "Bytes implicitly upgraded into wide characters as iso-8859-1"
+ );
+
+ }
- require Carp;
- no strict 'refs';
- $self->[FATAL]->(
- "Bytes implicitly upgraded into wide characters as iso-8859-1"
- );
return $self->[LATIN1]->decode(@_);
}
@@ -208,11 +224,11 @@
=head1 AUTHORS
-Autrijus Tang E<lt>[EMAIL PROTECTED]<gt>
+Audrey Tang
=head1 COPYRIGHT
-Copyright 2004 by Autrijus Tang E<lt>[EMAIL PROTECTED]<gt>.
+Copyright 2004, 2005, 2006 by Audrey Tang E<lt>[EMAIL PROTECTED]<gt>.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
==== //depot/perl/lib/encoding/warnings/t/3-normal.t#2 (text) ====
Index: perl/lib/encoding/warnings/t/3-normal.t
--- perl/lib/encoding/warnings/t/3-normal.t#1~23980~ 2005-02-18
06:27:38.000000000 -0800
+++ perl/lib/encoding/warnings/t/3-normal.t 2006-07-07 18:14:28.000000000
-0700
@@ -1,7 +1,3 @@
-#!/usr/bin/perl
-# $File: /member/local/autrijus/encoding-warnings/t/3-normal.t $ $Author:
autrijus $
-# $Revision: #3 $ $Change: 1625 $ $DateTime: 2004-03-14T16:50:26.012462Z $
-
use Test;
BEGIN { plan tests => 2 }
==== //depot/perl/lib/encoding/warnings/t/4-lexical.t#1 (text) ====
Index: perl/lib/encoding/warnings/t/4-lexical.t
--- /dev/null 2006-07-07 18:02:01.443840750 -0700
+++ perl/lib/encoding/warnings/t/4-lexical.t 2006-07-07 18:14:28.000000000
-0700
@@ -0,0 +1,41 @@
+use strict;
+use Test;
+BEGIN { plan tests => 3 }
+
+{
+ use encoding::warnings;
+ ok(encoding::warnings->VERSION);
+
+ if ($] < 5.009004) {
+ ok('skipped');
+ ok('skipped');
+ exit;
+ }
+
+ my ($a, $b, $c, $warned);
+
+ local $SIG{__WARN__} = sub {
+ if ($_[0] =~ /upgraded/) { $warned = 1 }
+ };
+
+ utf8::encode($a = chr(20000));
+ $b = chr(20000);
+ $c = $a . $b;
+ ok($warned);
+}
+
+{
+ my ($a, $b, $c, $warned);
+
+ local $SIG{__WARN__} = sub {
+ if ($_[0] =~ /upgraded/) { $warned = 1 }
+ };
+
+ utf8::encode($a = chr(20000));
+ $b = chr(20000);
+ $c = $a . $b;
+ ok(!$warned);
+}
+
+
+__END__
End of Patch.