# Revision history for Perl extension Encode.
#
-# $Id: Changes,v 2.7 2004/10/22 19:35:52 dankogai Exp $
+# $Id: Changes,v 2.8 2004/10/24 13:00:29 dankogai Exp dankogai $
#
-$Revision: 2.7 $ $Date: 2004/10/22 19:35:52 $
+$Revision: 2.8 $ $Date: 2004/10/24 13:00:29 $
+! Encode.xs lib/Encode/Encoding.pm Unicode/Unicode.{pm,xs}
+ Resolved the issue that was raised by the Encode::utf8 fallbacks vs.
+ PerlIO::encoding issue that was introduced in 2.07. This is done by
+ making use of ->renew() method that used to be used only by
+ Encode::Unicode. ->renewed() method was also introduced to fetch
+ the value thereof.
+ Message-Id: <94B2EB12-25B7-11D9-9E6A-000A95DBB50A@dan.co.jp>
+
+2.07 2004/10/22 19:35:52
! lib/Encode/Encoding.pm
"Remove Carp from warnings.pm" that influences Encode, by Tels.
Message-Id: <200410161618.29779@bloodgate.com>
#
-# $Id: Encode.pm,v 2.7 2004/10/22 19:35:52 dankogai Exp $
+# $Id: Encode.pm,v 2.8 2004/10/24 12:32:06 dankogai Exp $
#
package Encode;
use strict;
-our $VERSION = do { my @r = (q$Revision: 2.7 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 2.8 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
sub DEBUG () { 0 }
use XSLoader ();
XSLoader::load(__PACKAGE__, $VERSION);
/*
- $Id: Encode.xs,v 2.1 2004/10/22 19:35:52 dankogai Exp $
+ $Id: Encode.xs,v 2.2 2004/10/24 13:00:29 dankogai Exp dankogai $
*/
#define PERL_NO_GET_CONTEXT
PROTOTYPES: DISABLE
void
-Method_renew(obj)
-SV * obj
-CODE:
-{
- XSRETURN(1);
-}
-
-void
Method_decode_xs(obj,src,check = 0)
SV * obj
SV * src
U8 *s = (U8 *) SvPV(src, slen);
U8 *e = (U8 *) SvEND(src);
SV *dst = newSV(slen>0?slen:1); /* newSV() abhors 0 -- inaba */
+
+ /*
+ * PerlO check -- we assume the object is of PerlIO if renewed
+ * and if so, we set RETURN_ON_ERR for partial character
+ */
+ int renewed = 0;
+ dSP; ENTER; SAVETMPS;
+ PUSHMARK(sp);
+ XPUSHs(obj);
+ PUTBACK;
+ if (call_method("renewed",G_SCALAR) == 1) {
+ SPAGAIN;
+ renewed = POPi;
+ PUTBACK;
+#if 0
+ fprintf(stderr, "renewed == %d\n", renewed);
+#endif
+ if (renewed){ check |= ENCODE_RETURN_ON_ERR; }
+ }
+ FREETMPS; LEAVE;
+ /* end PerlIO check */
+
SvPOK_only(dst);
SvCUR_set(dst,0);
if (SvUTF8(src)) {
XSRETURN(1);
}
+int
+Method_renewed(obj)
+SV * obj
+CODE:
+ RETVAL = 0;
+OUTPUT:
+ RETVAL
+
void
Method_name(obj)
SV * obj
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Encode
-version: 2.07
+version: 2.08
version_from: Encode.pm
installdirs: perl
requires:
use warnings;
no warnings 'redefine';
-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 };
use XSLoader;
XSLoader::load(__PACKAGE__,$VERSION);
my $self = shift;
$BOM_Unknown{$self->name} or return $self;
my $clone = bless { %$self } => ref($self);
- $clone->{clone} = 1; # so the caller knows it is renewed.
+ $clone->{renewed}++; # so the caller knows it is renewed.
return $clone;
}
/*
- $Id: Unicode.xs,v 2.0 2004/05/16 20:55:16 dankogai Exp $
+ $Id: Unicode.xs,v 2.1 2004/10/24 13:00:29 dankogai Exp dankogai $
*/
#define PERL_NO_GET_CONTEXT
U8 endian = *((U8 *)SvPV_nolen(attr("endian", 6)));
int size = SvIV(attr("size", 4));
int ucs2 = SvTRUE(attr("ucs2", 4));
- int clone = SvTRUE(attr("clone", 5));
+ int renewed = SvTRUE(attr("renewed", 7));
SV *result = newSVpvn("",0);
STRLEN ulen;
U8 *s = (U8 *)SvPVbyte(str,ulen);
}
#if 1
/* Update endian for next sequence */
- if (clone) {
+ if (renewed) {
hv_store((HV *)SvRV(obj),"endian",6,newSVpv((char *)&endian,1),0);
}
#endif
U8 endian = *((U8 *)SvPV_nolen(attr("endian", 6)));
int size = SvIV(attr("size", 4));
int ucs2 = SvTRUE(attr("ucs2", 4));
- int clone = SvTRUE(attr("clone", 5));
+ int renewed = SvTRUE(attr("renewed", 7));
SV *result = newSVpvn("",0);
STRLEN ulen;
U8 *s = (U8 *)SvPVutf8(utf8,ulen);
enc_pack(aTHX_ result,size,endian,BOM_BE);
#if 1
/* Update endian for next sequence */
- if (clone){
+ if (renewed){
hv_store((HV *)SvRV(obj),"endian",6,newSVpv((char *)&endian,1),0);
}
#endif
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;
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 };
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: