a little tweak, sending that to Dan.
p4raw-id: //depot/perl@18816
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
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
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>
# 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>
#
-# $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);
/*
- $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
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;
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
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
/*
- $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
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;
$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)");
};
}
}
binmode(STDIN, ":raw");
binmode(STDOUT, ":raw");
}else{
- binmode(STDIN);
- binmode(STDOUT);
+ binmode(STDIN);
+ binmode(STDOUT);
}
if ($INC{"Filter/Util/Call.pm"}){
eval { filter_del() };
--- /dev/null
+# $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__
-# $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 {
--- /dev/null
+½é´üʸ»úÎó
+¥Æ¥¹¥Èʸ»úÎó
--- /dev/null
+# $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__
+
-# $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 {
#
-# $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