diff options
-rw-r--r-- | MANIFEST | 3 | ||||
-rw-r--r-- | ext/Encode/AUTHORS | 1 | ||||
-rw-r--r-- | ext/Encode/Changes | 19 | ||||
-rw-r--r-- | ext/Encode/Encode.pm | 4 | ||||
-rw-r--r-- | ext/Encode/Encode.xs | 10 | ||||
-rw-r--r-- | ext/Encode/MANIFEST | 3 | ||||
-rw-r--r-- | ext/Encode/Unicode/Unicode.xs | 2 | ||||
-rw-r--r-- | ext/Encode/encoding.pm | 12 | ||||
-rw-r--r-- | ext/Encode/t/Mod_EUCJP.pm | 22 | ||||
-rw-r--r-- | ext/Encode/t/enc_eucjp.t | 2 | ||||
-rw-r--r-- | ext/Encode/t/enc_module.enc | 2 | ||||
-rw-r--r-- | ext/Encode/t/enc_module.t | 56 | ||||
-rw-r--r-- | ext/Encode/t/enc_utf8.t | 2 | ||||
-rw-r--r-- | ext/Encode/ucm/viscii.ucm | 4 |
14 files changed, 124 insertions, 18 deletions
@@ -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 4e3035c4d0..71879feae3 100644 --- a/ext/Encode/AUTHORS +++ b/ext/Encode/AUTHORS @@ -36,6 +36,7 @@ Paul Marquess <paul_marquess@yahoo.co.uk> Philip Newton <pne@cpan.org> Robin Barker <rmb1@cise.npl.co.uk> SADAHIRO Tomoyuki <SADAHIRO@cpan.org> +SUGAWARA Hajime <sugawara@hdt.co.jp> SUZUKI Norio <ZAP00217@nifty.com> Spider Boardman <spider@web.zk3.dec.com> Tatsuhiko Miyagawa <miyagawa@edge.co.jp> diff --git a/ext/Encode/Changes b/ext/Encode/Changes index 3900502b8c..32e4e83f4c 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: <a05200f12ba81fe9d6298@[172.16.52.1]> +! 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 <sugawara@hdt.co.jp>, + 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 ad1a27d8cd..dc4503adfc 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 1c0de8c536..6567be473e 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 4a8992ef01..2705308a64 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 d0bedc5951..2163fb525d 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 ec3cf57e53..43b599a1d0 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 0000000000..5693631c00 --- /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 151bd9aa5b..4355c12944 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 0000000000..688aa1dcf9 --- /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 0000000000..633eaaa9c0 --- /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(<STDIN>){ + 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 5da3047760..98e541c51c 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 d73fbf24ab..d36ccadfe9 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 <code_set_name> "viscii" <mb_cur_min> 1 |