summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorFuji, Goro <gfuji@cpan.org>2010-10-06 17:52:32 +0900
committerFuji, Goro <gfuji@cpan.org>2010-10-06 17:52:32 +0900
commit77a7d3d26aaf957c4f231fdc2090d1b8e842e78c (patch)
tree8a859e96671a2158370158d8105167c968d579ce /perl
parent4321b80999696a6d4e5340fec8f729e11c0ada06 (diff)
downloadmsgpack-python-77a7d3d26aaf957c4f231fdc2090d1b8e842e78c.tar.gz
perl: Fix utf8 mode not to be reseted by $unpacker->reset method
Diffstat (limited to 'perl')
-rw-r--r--perl/Changes5
-rw-r--r--perl/t/15_utf8.t32
-rw-r--r--perl/xs-src/unpack.c2
3 files changed, 26 insertions, 13 deletions
diff --git a/perl/Changes b/perl/Changes
index 333a824..091c875 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,8 @@
+
+0.30
+
+ - fix utf8 mode not to be reseted by $unpacker->reset method
+
0.29
- add $unpacker->utf8 mode, decoding strings as UTF-8.
diff --git a/perl/t/15_utf8.t b/perl/t/15_utf8.t
index d7d17b8..f3163df 100644
--- a/perl/t/15_utf8.t
+++ b/perl/t/15_utf8.t
@@ -5,23 +5,29 @@ use Data::MessagePack;
use utf8;
my $data = [42, undef, 'foo', "\x{99f1}\x{99dd}"];
-my $packed = Data::MessagePack->pack($data);
+my $packed = Data::MessagePack->pack($data) x 2;
my $u = Data::MessagePack::Unpacker->new()->utf8();
-ok $u->get_utf8();
-$u->execute($packed);
-my $d = $u->data();
-$u->reset();
-is_deeply $d, $data, 'decoded';
+my $p = 0;
+for(1 .. 2) {
+ ok $u->get_utf8();
+ $p = $u->execute($packed, $p);
+ my $d = $u->data();
+ $u->reset();
+ is_deeply $d, $data, 'decoded';
+}
is $u->utf8(0), $u, 'utf8(0)';
-ok !$u->get_utf8();
-$u->execute($packed);
-$d = $u->data();
-$u->reset();
-my $s = $data->[3];
-utf8::encode($s);
-is_deeply $d->[3], $s, 'not decoded';
+$p = 0;
+for(1 .. 2) {
+ ok !$u->get_utf8();
+ $p = $u->execute($packed, $p);
+ my $d = $u->data();
+ $u->reset();
+ my $s = $data->[3];
+ utf8::encode($s);
+ is_deeply $d->[3], $s, 'not decoded';
+}
done_testing;
diff --git a/perl/xs-src/unpack.c b/perl/xs-src/unpack.c
index f39d8c1..caf8662 100644
--- a/perl/xs-src/unpack.c
+++ b/perl/xs-src/unpack.c
@@ -443,10 +443,12 @@ XS(xs_unpacker_reset) {
}
UNPACKER(ST(0), mp);
+ bool const utf8 = mp->user.utf8; // save
SV* const data = template_data(mp);
SvREFCNT_dec(data);
_reset(ST(0));
+ mp->user.utf8 = utf8;
XSRETURN(0);
}