summaryrefslogtreecommitdiff
path: root/ext/Encode/lib
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-10-25 07:29:50 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-10-25 07:29:50 +0000
commitcc836e956f1f965d89e75825961e461d4c4efb8a (patch)
tree77bc28c2449e88ff2039b5d48f532dcc16a6cdb5 /ext/Encode/lib
parentd7782e692220009924ccb07ccb747c51ffee1823 (diff)
downloadperl-cc836e956f1f965d89e75825961e461d4c4efb8a.tar.gz
Upgrade to Encode 2.08.
p4raw-id: //depot/perl@23421
Diffstat (limited to 'ext/Encode/lib')
-rw-r--r--ext/Encode/lib/Encode/Encoding.pm44
1 files changed, 30 insertions, 14 deletions
diff --git a/ext/Encode/lib/Encode/Encoding.pm b/ext/Encode/lib/Encode/Encoding.pm
index 1fad60a959..06af9fb699 100644
--- a/ext/Encode/lib/Encode/Encoding.pm
+++ b/ext/Encode/lib/Encode/Encoding.pm
@@ -1,10 +1,11 @@
package Encode::Encoding;
# Base class for classes which implement encodings
use strict;
-our $VERSION = do { my @r = (q$Revision: 2.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 2.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
require Encode;
+sub DEBUG { 0 }
sub Define
{
my $obj = shift;
@@ -16,7 +17,18 @@ sub Define
sub name { return shift->{'Name'} }
-sub renew { return $_[0] }
+# sub renew { return $_[0] }
+
+sub renew {
+ my $self = shift;
+ my $clone = bless { %$self } => ref($self);
+ $clone->{renewed}++; # so the caller can see it
+ DEBUG and warn $clone->{renewed};
+ return $clone;
+}
+
+sub renewed{ return $_[0]->{renewed} || 0 }
+
*new_sequence = \&renew;
sub needs_lines { 0 };
@@ -167,25 +179,29 @@ MUST return the string representing the canonical name of the encoding.
Predefined As:
- sub renew { return $_[0] }
+ sub renew {
+ my $self = shift;
+ my $clone = bless { %$self } => ref($self);
+ $clone->{renewed}++;
+ return $clone;
+ }
This method reconstructs the encoding object if necessary. If you need
to store the state during encoding, this is where you clone your object.
-Here is an example:
-
- sub renew {
- my $self = shift;
- my $clone = bless { %$self } => ref($self);
- $clone->{clone} = 1; # so the caller can see it
- return $clone;
- }
-
-Since most encodings are stateless the default behavior is just return
-itself as shown above.
PerlIO ALWAYS calls this method to make sure it has its own private
encoding object.
+=item -E<gt>renewed
+
+Predefined As:
+
+ sub renewed { $_[0]->{renewed} || 0 }
+
+Tells whether the object is renewed (and how many times). Some
+modules emit C<Use of uninitialized value in null operation> warning
+unless the value is numeric so return 0 for false.
+
=item -E<gt>perlio_ok()
Predefined As: