You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2014/06/11 21:48:08 UTC
svn commit: r1602002 - in /avro/trunk: CHANGES.txt
lang/perl/lib/Avro/BinaryEncoder.pm lang/perl/lib/Avro/Schema.pm
lang/perl/t/02_bin_encode.t
Author: cutting
Date: Wed Jun 11 19:48:07 2014
New Revision: 1602002
URL: http://svn.apache.org/r1602002
Log:
AVRO-1470. Perl: Fix encoding of boolean values. Contributed by John Karp.
Modified:
avro/trunk/CHANGES.txt
avro/trunk/lang/perl/lib/Avro/BinaryEncoder.pm
avro/trunk/lang/perl/lib/Avro/Schema.pm
avro/trunk/lang/perl/t/02_bin_encode.t
Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1602002&r1=1602001&r2=1602002&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Wed Jun 11 19:48:07 2014
@@ -87,6 +87,8 @@ Trunk (not yet released)
AVRO-1462. Perl: Stop spurious serializer warnings about Non-ASCII
decimal characters. (John Karp via cutting)
+ AVRO-1470. Perl: Fix encoding of boolean values. (John Karp via cutting)
+
Avro 1.7.6 (15 January 2014)
NEW FEATURES
Modified: avro/trunk/lang/perl/lib/Avro/BinaryEncoder.pm
URL: http://svn.apache.org/viewvc/avro/trunk/lang/perl/lib/Avro/BinaryEncoder.pm?rev=1602002&r1=1602001&r2=1602002&view=diff
==============================================================================
--- avro/trunk/lang/perl/lib/Avro/BinaryEncoder.pm (original)
+++ avro/trunk/lang/perl/lib/Avro/BinaryEncoder.pm Wed Jun 11 19:48:07 2014
@@ -84,7 +84,7 @@ sub encode_null {
sub encode_boolean {
my $class = shift;
my ($schema, $data, $cb) = @_;
- $cb->( $data ? \0x1 : \0x0 );
+ $cb->( $data ? \"\x1" : \"\x0" );
}
sub encode_int {
Modified: avro/trunk/lang/perl/lib/Avro/Schema.pm
URL: http://svn.apache.org/viewvc/avro/trunk/lang/perl/lib/Avro/Schema.pm?rev=1602002&r1=1602001&r2=1602002&view=diff
==============================================================================
--- avro/trunk/lang/perl/lib/Avro/Schema.pm (original)
+++ avro/trunk/lang/perl/lib/Avro/Schema.pm Wed Jun 11 19:48:07 2014
@@ -309,8 +309,8 @@ sub is_data_valid {
return defined $data ? 0 : 1;
}
if ($type eq 'boolean') {
- return 0 if ref $type; # sometimes risky
- return 1 if $type =~ m{yes|no|y|n|t|f|true|false}i;
+ return 0 if ref $data; # sometimes risky
+ return 1 if $data =~ m{yes|no|y|n|t|f|true|false}i;
return 0;
}
return 0;
Modified: avro/trunk/lang/perl/t/02_bin_encode.t
URL: http://svn.apache.org/viewvc/avro/trunk/lang/perl/t/02_bin_encode.t?rev=1602002&r1=1602001&r2=1602002&view=diff
==============================================================================
--- avro/trunk/lang/perl/t/02_bin_encode.t (original)
+++ avro/trunk/lang/perl/t/02_bin_encode.t Wed Jun 11 19:48:07 2014
@@ -44,6 +44,9 @@ sub primitive_ok {
primitive_ok null => undef, '';
primitive_ok null => 'whatev', '';
+ primitive_ok boolean => 0, "\x0";
+ primitive_ok boolean => 1, "\x1";
+
## - high-bit of each byte should be set except for last one
## - rest of bits are:
## - little endian