From: Jarkko Hietaniemi Date: Mon, 3 Mar 2003 06:17:28 +0000 (+0000) Subject: Upgrade to Encode 1.89. The enc_module.t required X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6be7c10195c1f65811dd5bd2452ad83544044891;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Encode 1.89. The enc_module.t required a little tweak, sending that to Dan. p4raw-id: //depot/perl@18816 --- diff --git a/MANIFEST b/MANIFEST index 6d583a2..cecd54f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -251,6 +251,7 @@ ext/Encode/README Encode extension ext/Encode/Symbol/Makefile.PL Encode extension ext/Encode/Symbol/Symbol.pm Encode extension ext/Encode/t/Aliases.t test script +ext/Encode/t/Mod_EUCJP.pm module that t/enc_module.enc uses ext/Encode/t/at-cn.t test script ext/Encode/t/at-tw.t test script ext/Encode/t/big5-eten.enc test data @@ -261,6 +262,8 @@ ext/Encode/t/CJKT.t test script ext/Encode/t/Encode.t test script ext/Encode/t/Encoder.t test script ext/Encode/t/enc_eucjp.t test script +ext/Encode/t/enc_module.enc test data for t/enc_module.t +ext/Encode/t/enc_module.t test script ext/Encode/t/enc_utf8.t test script ext/Encode/t/encoding.t test script ext/Encode/t/fallback.t test script diff --git a/ext/Encode/AUTHORS b/ext/Encode/AUTHORS index 4e3035c..71879fe 100644 --- a/ext/Encode/AUTHORS +++ b/ext/Encode/AUTHORS @@ -36,6 +36,7 @@ Paul Marquess Philip Newton Robin Barker SADAHIRO Tomoyuki +SUGAWARA Hajime SUZUKI Norio Spider Boardman Tatsuhiko Miyagawa diff --git a/ext/Encode/Changes b/ext/Encode/Changes index 3900502..32e4e83 100644 --- a/ext/Encode/Changes +++ b/ext/Encode/Changes @@ -1,8 +1,23 @@ # Revision history for Perl extension Encode. # -# $Id: Changes,v 1.88 2003/02/20 14:42:34 dankogai Exp dankogai $ +# $Id: Changes,v 1.89 2003/02/28 01:40:27 dankogai Exp dankogai $ # -$Revision: 1.88 $ $Date: 2003/02/20 14:42:34 $ +$Revision: 1.89 $ $Date: 2003/02/28 01:40:27 $ +! Encode.xs + signed vs. unsigned issue discovered by Craig on OpenVM + Message-Id: +! encoding.pm AUTHORS ++ t/Mod_EUCJP.pm t/enc_module.enc t/enc_module.t + Because binmode() stacks layers instead of overwrite, you have to + ":raw :encoding()" in encoding.pm or your are in trouble when you + call encoding.pm multiple times. There are several workarounds + but Inaba-san's idea is in. SUGAWARA Hajime , + who was the first to address this problem was added to AUTHORS. + The test suites was added for this, which is a modified version + of SUGAWARA-san's scripts + Message-Id: <3E5CF695.6AE07852@st.rim.or.jp> + +1.88 2003/02/20 14:42:34 ! Encode.xs one signedness nit for Encode by jhi <200302161933.h1GJX876018710@kosh.hut.fi> diff --git a/ext/Encode/Encode.pm b/ext/Encode/Encode.pm index ad1a27d..dc4503a 100644 --- a/ext/Encode/Encode.pm +++ b/ext/Encode/Encode.pm @@ -1,9 +1,9 @@ # -# $Id: Encode.pm,v 1.88 2003/02/20 14:36:25 dankogai Exp $ +# $Id: Encode.pm,v 1.89 2003/02/28 01:36:02 dankogai Exp $ # package Encode; use strict; -our $VERSION = do { my @r = (q$Revision: 1.88 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +our $VERSION = do { my @r = (q$Revision: 1.89 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; our $DEBUG = 0; use XSLoader (); XSLoader::load(__PACKAGE__, $VERSION); diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index 1c0de8c..6567be4 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -1,5 +1,5 @@ /* - $Id: Encode.xs,v 1.54 2003/02/20 14:42:34 dankogai Exp dankogai $ + $Id: Encode.xs,v 1.55 2003/02/28 01:40:27 dankogai Exp dankogai $ */ #define PERL_NO_GET_CONTEXT @@ -78,11 +78,15 @@ encode_method(pTHX_ encode_t * enc, encpage_t * dir, SV * src, if (offset) { s += *offset; - slen -= *offset; + if (slen > *offset){ /* safeguard against slen overflow */ + slen -= *offset; + }else{ + slen = 0; + } tlen = slen; } - if (slen <= 0){ + if (slen == 0){ SvCUR_set(dst, 0); SvPOK_only(dst); goto ENCODE_END; diff --git a/ext/Encode/MANIFEST b/ext/Encode/MANIFEST index 4a8992e..2705308 100644 --- a/ext/Encode/MANIFEST +++ b/ext/Encode/MANIFEST @@ -54,6 +54,7 @@ t/Aliases.t test script t/CJKT.t test script t/Encode.t test script t/Encoder.t test script +t/Mod_EUCJP.pm module that t/enc_module.enc uses t/Unicode.t test script t/at-cn.t test script t/at-tw.t test script @@ -62,6 +63,8 @@ t/big5-eten.utf test data t/big5-hkscs.enc test data t/big5-hkscs.utf test data t/enc_eucjp.t test script +t/enc_module.enc test data for t/enc_module.t +t/enc_module.t test script t/enc_utf8.t test script t/encoding.t test script t/fallback.t test script diff --git a/ext/Encode/Unicode/Unicode.xs b/ext/Encode/Unicode/Unicode.xs index d0bedc5..2163fb5 100644 --- a/ext/Encode/Unicode/Unicode.xs +++ b/ext/Encode/Unicode/Unicode.xs @@ -1,5 +1,5 @@ /* - $Id: Unicode.xs,v 1.7 2003/02/20 14:42:34 dankogai Exp dankogai $ + $Id: Unicode.xs,v 1.7 2003/02/20 14:42:34 dankogai Exp $ */ #define PERL_NO_GET_CONTEXT diff --git a/ext/Encode/encoding.pm b/ext/Encode/encoding.pm index ec3cf57..43b599a 100644 --- a/ext/Encode/encoding.pm +++ b/ext/Encode/encoding.pm @@ -1,5 +1,5 @@ package encoding; -our $VERSION = do { my @r = (q$Revision: 1.41 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +our $VERSION = do { my @r = (q$Revision: 1.42 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; use Encode; use strict; @@ -62,19 +62,19 @@ sub import { $status ; }); }; - } $DEBUG and warn "Filter installed"; + } $DEBUG and warn "Filter installed"; for my $h (qw(STDIN STDOUT)){ if ($arg{$h}){ unless (defined find_encoding($arg{$h})) { require Carp; Carp::croak("Unknown encoding for $h, '$arg{$h}'"); } - eval { binmode($h, ":encoding($arg{$h})") }; + eval { binmode($h, ":raw :encoding($arg{$h})") }; }else{ unless (exists $arg{$h}){ eval { no warnings 'uninitialized'; - binmode($h, ":encoding($name)"); + binmode($h, ":raw :encoding($name)"); }; } } @@ -93,8 +93,8 @@ sub unimport{ binmode(STDIN, ":raw"); binmode(STDOUT, ":raw"); }else{ - binmode(STDIN); - binmode(STDOUT); + binmode(STDIN); + binmode(STDOUT); } if ($INC{"Filter/Util/Call.pm"}){ eval { filter_del() }; diff --git a/ext/Encode/t/Mod_EUCJP.pm b/ext/Encode/t/Mod_EUCJP.pm new file mode 100644 index 0000000..5693631 --- /dev/null +++ b/ext/Encode/t/Mod_EUCJP.pm @@ -0,0 +1,22 @@ +# $Id: Mod_EUCJP.pm,v 1.1 2003/02/28 01:40:27 dankogai Exp dankogai $ +# This file is in euc-jp +package Mod_EUCJP; +use encoding "euc-jp"; +sub new { + my $class = shift; + my $str = shift || qw/½é´üʸ»úÎó/; + my $self = bless { + str => '', + }, $class; + $self->set($str); + $self; +} +sub set { + my ($self,$str) = @_; + $self->{str} = $str; + $self; +} +sub str { shift->{str}; } +sub put { print shift->{str}; } +1; +__END__ diff --git a/ext/Encode/t/enc_eucjp.t b/ext/Encode/t/enc_eucjp.t index 151bd9a..4355c12 100644 --- a/ext/Encode/t/enc_eucjp.t +++ b/ext/Encode/t/enc_eucjp.t @@ -1,4 +1,4 @@ -# $Id: enc_eucjp.t,v 1.3 2003/02/20 14:42:34 dankogai Exp dankogai $ +# $Id: enc_eucjp.t,v 1.3 2003/02/20 14:42:34 dankogai Exp $ # This is the twin of enc_utf8.t . BEGIN { diff --git a/ext/Encode/t/enc_module.enc b/ext/Encode/t/enc_module.enc new file mode 100644 index 0000000..688aa1d --- /dev/null +++ b/ext/Encode/t/enc_module.enc @@ -0,0 +1,2 @@ +½é´üʸ»úÎó +¥Æ¥¹¥Èʸ»úÎó diff --git a/ext/Encode/t/enc_module.t b/ext/Encode/t/enc_module.t new file mode 100644 index 0000000..633eaaa --- /dev/null +++ b/ext/Encode/t/enc_module.t @@ -0,0 +1,56 @@ +# $Id: enc_module.t,v 1.1 2003/02/28 01:40:27 dankogai Exp dankogai $ +# This file is in euc-jp +BEGIN { + require Config; import Config; + if ($Config{'extensions'} !~ /\bEncode\b/) { + print "1..0 # Skip: Encode was not built\n"; + exit 0; + } + unless (find PerlIO::Layer 'perlio') { + print "1..0 # Skip: PerlIO was not built\n"; + exit 0; + } + if (ord("A") == 193) { + print "1..0 # encoding pragma does not support EBCDIC platforms\n"; + exit(0); + } +} +use lib 't'; +use lib qw(ext/Encode/t ../ext/Encode/t); # in case of perl core +use Mod_EUCJP; +use encoding "euc-jp"; +use Test::More tests => 3; +use File::Basename; +use File::Spec; +use File::Compare qw(compare_text); + +my $dir = dirname(__FILE__); +my $file0 = File::Spec->catfile($dir,"enc_module.enc"); +my $file1 = File::Spec->catfile($dir,"$$.enc"); + +my $obj = Mod_EUCJP->new; +# Isn't this dangerous in that we lose all possible warnings? +# Maybe a scoped use warnings 'something' instead? --jhi +local $SIG{__WARN__} = sub{}; # to silence reopening STD(IN|OUT) w/o closing + +open STDOUT, ">", $file1 or die "$file1:$!"; +print $obj->str, "\n"; +$obj->set("¥Æ¥¹¥Èʸ»úÎó"); +print $obj->str, "\n"; +close STDOUT; + +my $cmp = compare_text($file0, $file1); +is($cmp, 0, "encoding vs. STDOUT"); +unlink $file1 unless $cmp; + +my @cmp = qw/½é´üʸ»úÎó ¥Æ¥¹¥Èʸ»úÎó/; +open STDIN, "<", $file0 or die "$file0:$!"; +$obj = Mod_EUCJP->new; +my $i = 0; +while(){ + chomp; + is ($cmp[$i++], $_, "encoding vs. STDIN - $i"); +} + +__END__ + diff --git a/ext/Encode/t/enc_utf8.t b/ext/Encode/t/enc_utf8.t index 5da3047..98e541c 100644 --- a/ext/Encode/t/enc_utf8.t +++ b/ext/Encode/t/enc_utf8.t @@ -1,4 +1,4 @@ -# $Id: enc_utf8.t,v 1.3 2003/02/20 14:42:34 dankogai Exp dankogai $ +# $Id: enc_utf8.t,v 1.3 2003/02/20 14:42:34 dankogai Exp $ # This is the twin of enc_eucjp.t . BEGIN { diff --git a/ext/Encode/ucm/viscii.ucm b/ext/Encode/ucm/viscii.ucm index d73fbf2..d36ccad 100644 --- a/ext/Encode/ucm/viscii.ucm +++ b/ext/Encode/ucm/viscii.ucm @@ -1,7 +1,7 @@ # -# $Id: viscii.ucm,v 1.1 2003/02/20 14:42:34 dankogai Exp dankogai $ +# $Id: viscii.ucm,v 1.1 2003/02/20 14:42:34 dankogai Exp $ # -# Written $Id: viscii.ucm,v 1.1 2003/02/20 14:42:34 dankogai Exp dankogai $ +# Written $Id: viscii.ucm,v 1.1 2003/02/20 14:42:34 dankogai Exp $ # ./compile -n viscii -o Encode/viscii.ucm Encode/viscii.enc "viscii" 1