From 5a7eec3ce8d33436788c9bc7f0006ac0b07c6d63 Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Sat, 16 Aug 2014 02:02:58 +0200 Subject: [PATCH] Imported Upstream version 3.001.012 --- META.json | 4 +-- META.yml | 32 +++++++++--------- author_tools/hobodecoder.pl | 5 +-- const-c.inc | 2 +- lib/Sereal/Encoder.pm | 2 +- srl_common.h | 7 ++++ srl_encoder.c | 8 +++++ t/700_roundtrip/v1/plain_canon.t | 4 +-- t/700_roundtrip/v1/snappy_canon.t | 3 +- t/700_roundtrip/v2/plain_canon.t | 4 +-- t/700_roundtrip/v2/snappy_canon.t | 3 +- t/700_roundtrip/v2/snappy_incr_canon.t | 7 ++-- t/700_roundtrip/v3/plain_canon.t | 4 +-- t/700_roundtrip/v3/snappy_canon.t | 3 +- t/700_roundtrip/v3/snappy_incr_canon.t | 7 ++-- t/lib/Sereal/TestSet.pm | 45 +++++++++++++++++++------- 16 files changed, 84 insertions(+), 56 deletions(-) diff --git a/META.json b/META.json index d07a304..1deadae 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "Steffen Mueller , Yves Orton " ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 6.9, CPAN::Meta::Converter version 2.141520", + "generated_by" : "ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630", "license" : [ "perl_5" ], @@ -55,5 +55,5 @@ "url" : "git://github.com/Sereal/Sereal.git" } }, - "version" : "3.001_011" + "version" : "3.001_012" } diff --git a/META.yml b/META.yml index 2bb664c..2f0d7aa 100644 --- a/META.yml +++ b/META.yml @@ -3,33 +3,33 @@ abstract: 'Fast, compact, powerful binary serialization' author: - 'Steffen Mueller , Yves Orton ' build_requires: - Data::Dumper: '0' - ExtUtils::ParseXS: '2.21' - File::Find: '0' - File::Path: '0' - File::Spec: '0' - Scalar::Util: '0' - Sereal::Decoder: '3.00' - Test::LongString: '0' - Test::More: '0.88' - Test::Warn: '0' + Data::Dumper: 0 + ExtUtils::ParseXS: 2.21 + File::Find: 0 + File::Path: 0 + File::Spec: 0 + Scalar::Util: 0 + Sereal::Decoder: 3.00 + Test::LongString: 0 + Test::More: 0.88 + Test::Warn: 0 configure_requires: - ExtUtils::MakeMaker: '0' + ExtUtils::MakeMaker: 0 dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 6.9, CPAN::Meta::Converter version 2.141520' +generated_by: 'ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: '1.4' + version: 1.4 name: Sereal-Encoder no_index: directory: - t - inc requires: - XSLoader: '0' - perl: '5.008' + XSLoader: 0 + perl: 5.008 resources: bugtracker: https://github.com/Sereal/Sereal/issues repository: git://github.com/Sereal/Sereal.git -version: 3.001_011 +version: 3.001_012 diff --git a/author_tools/hobodecoder.pl b/author_tools/hobodecoder.pl index 6dc4c0e..09878a0 100644 --- a/author_tools/hobodecoder.pl +++ b/author_tools/hobodecoder.pl @@ -92,10 +92,11 @@ sub parse_double { return unpack("d",$v); } sub parse_long_double { - $len_D||= eval { length(pack("D",0)) }; + $len_D ||= eval { length(pack("D",0.0)) }; die "Long double not supported" unless $len_D; - my $v= substr($data,0,$len_D,""); + my $v= substr($data, 0, $len_D, ""); $done .= $v; + warn "long double size: " . $len_D; return unpack("D",$v); } diff --git a/const-c.inc b/const-c.inc index 1c8e830..91e964b 100644 --- a/const-c.inc +++ b/const-c.inc @@ -763,7 +763,7 @@ constant (pTHX_ const char *name, STRLEN len, IV *iv_return) { Regenerate these constant functions by feeding this entire source file to perl -x -#!/usr/bin/perl -w +#!/home/yorton/perl5/perlbrew/perls/perl-5.16.3-ld/bin/perl -w use ExtUtils::Constant qw (constant_types C_constant XS_constant); my $types = {map {($_, 1)} qw(IV)}; diff --git a/lib/Sereal/Encoder.pm b/lib/Sereal/Encoder.pm index 0e71e18..7625ac4 100644 --- a/lib/Sereal/Encoder.pm +++ b/lib/Sereal/Encoder.pm @@ -5,7 +5,7 @@ use warnings; use Carp qw/croak/; use XSLoader; -our $VERSION = '3.001_011'; # Don't forget to update the TestCompat set for testing against installed decoders! +our $VERSION = '3.001_012'; # Don't forget to update the TestCompat set for testing against installed decoders! our $XS_VERSION = $VERSION; $VERSION= eval $VERSION; # not for public consumption, just for testing. diff --git a/srl_common.h b/srl_common.h index b50199a..dd25bc2 100644 --- a/srl_common.h +++ b/srl_common.h @@ -18,6 +18,13 @@ #if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__) || defined(__x86_64) /* SRL_X86_OR_X64_CPU is only used to help set the below macros. */ #define SRL_X86_OR_X64_CPU +#ifndef SRL_EXTENDED_PRECISION_LONG_DOUBLE +#define SRL_EXTENDED_PRECISION_LONG_DOUBLE 1 +#endif +#endif + +#ifndef SRL_EXTENDED_PRECISION_LONG_DOUBLE +#define SRL_EXTENDED_PRECISION_LONG_DOUBLE 0 #endif #ifndef SRL_USE_ALIGNED_LOADS_AND_STORES diff --git a/srl_encoder.c b/srl_encoder.c index 3b7d9a5..780748f 100644 --- a/srl_encoder.c +++ b/srl_encoder.c @@ -715,6 +715,14 @@ srl_dump_nv(pTHX_ srl_encoder_t *enc, SV *src) BUF_SIZE_ASSERT(enc, 1 + sizeof(nv)); /* heuristic: header + string + simple value */ srl_buf_cat_char_nocheck(enc,SRL_HDR_LONG_DOUBLE); Copy((char *)&nv, enc->buf.pos, sizeof(nv), char); +#if SRL_EXTENDED_PRECISION_LONG_DOUBLE + /* x86 uses an 80 bit extended precision. on 64 bit machines + * this is 16 bytes long, and on 32 bits its is 12 bytes long. + * the unused 2/6 bytes are not necessarily zeroed, potentially + * allowing internal memory to be exposed. We therefore zero + * the unused bytes here. */ + memset(enc->buf.pos+10, 0, sizeof(nv) - 10); +#endif enc->buf.pos += sizeof(nv); } } diff --git a/t/700_roundtrip/v1/plain_canon.t b/t/700_roundtrip/v1/plain_canon.t index e8b9f04..f16265e 100644 --- a/t/700_roundtrip/v1/plain_canon.t +++ b/t/700_roundtrip/v1/plain_canon.t @@ -14,12 +14,12 @@ use Sereal::TestSet qw(:all); use Test::More; my $ok = have_encoder_and_decoder(); -$ok= 0 if $Sereal::Encoder::VERSION < 3.001006; +$ok= 0 if $ok and $Sereal::Encoder::VERSION < 3.001006; if (not $ok) { plan skip_all => 'Did not find right version of encoder (want 3.001006)'; } else { - run_roundtrip_tests("plain_canon",{canonical => 1}); + run_roundtrip_tests("plain_canon", { canonical => 1 }); } pass(); diff --git a/t/700_roundtrip/v1/snappy_canon.t b/t/700_roundtrip/v1/snappy_canon.t index 605956d..bd673f1 100644 --- a/t/700_roundtrip/v1/snappy_canon.t +++ b/t/700_roundtrip/v1/snappy_canon.t @@ -14,7 +14,7 @@ use Sereal::TestSet qw(:all); use Test::More; my $ok = have_encoder_and_decoder(); -$ok= 0 if $Sereal::Encoder::VERSION < 3.001006; +$ok= 0 if $ok and $Sereal::Encoder::VERSION < 3.001006; if (not $ok) { plan skip_all => 'Did not find right version of encoder (want 3.001006)'; } @@ -22,7 +22,6 @@ else { run_roundtrip_tests('snappy_canon', { snappy => 1, canonical => 1 } ); } - pass(); done_testing(); diff --git a/t/700_roundtrip/v2/plain_canon.t b/t/700_roundtrip/v2/plain_canon.t index e8b9f04..f16265e 100644 --- a/t/700_roundtrip/v2/plain_canon.t +++ b/t/700_roundtrip/v2/plain_canon.t @@ -14,12 +14,12 @@ use Sereal::TestSet qw(:all); use Test::More; my $ok = have_encoder_and_decoder(); -$ok= 0 if $Sereal::Encoder::VERSION < 3.001006; +$ok= 0 if $ok and $Sereal::Encoder::VERSION < 3.001006; if (not $ok) { plan skip_all => 'Did not find right version of encoder (want 3.001006)'; } else { - run_roundtrip_tests("plain_canon",{canonical => 1}); + run_roundtrip_tests("plain_canon", { canonical => 1 }); } pass(); diff --git a/t/700_roundtrip/v2/snappy_canon.t b/t/700_roundtrip/v2/snappy_canon.t index 605956d..bd673f1 100644 --- a/t/700_roundtrip/v2/snappy_canon.t +++ b/t/700_roundtrip/v2/snappy_canon.t @@ -14,7 +14,7 @@ use Sereal::TestSet qw(:all); use Test::More; my $ok = have_encoder_and_decoder(); -$ok= 0 if $Sereal::Encoder::VERSION < 3.001006; +$ok= 0 if $ok and $Sereal::Encoder::VERSION < 3.001006; if (not $ok) { plan skip_all => 'Did not find right version of encoder (want 3.001006)'; } @@ -22,7 +22,6 @@ else { run_roundtrip_tests('snappy_canon', { snappy => 1, canonical => 1 } ); } - pass(); done_testing(); diff --git a/t/700_roundtrip/v2/snappy_incr_canon.t b/t/700_roundtrip/v2/snappy_incr_canon.t index 1cd5327..dc1e5b1 100644 --- a/t/700_roundtrip/v2/snappy_incr_canon.t +++ b/t/700_roundtrip/v2/snappy_incr_canon.t @@ -14,17 +14,14 @@ use Sereal::TestSet qw(:all); use Test::More; my $ok = have_encoder_and_decoder(); -$ok= 0 if $Sereal::Encoder::VERSION < 3.001006; +$ok= 0 if $ok and $Sereal::Encoder::VERSION < 3.001006; if (not $ok) { plan skip_all => 'Did not find right version of encoder (want 3.001006)'; } else { - run_roundtrip_tests( - 'snappy_incr_canon', { snappy_incr => 1, canonical => 1 } - ); + run_roundtrip_tests('snappy_incr_canon', { snappy_incr => 1, canonical => 1 }); } - pass(); done_testing(); diff --git a/t/700_roundtrip/v3/plain_canon.t b/t/700_roundtrip/v3/plain_canon.t index e8b9f04..f16265e 100644 --- a/t/700_roundtrip/v3/plain_canon.t +++ b/t/700_roundtrip/v3/plain_canon.t @@ -14,12 +14,12 @@ use Sereal::TestSet qw(:all); use Test::More; my $ok = have_encoder_and_decoder(); -$ok= 0 if $Sereal::Encoder::VERSION < 3.001006; +$ok= 0 if $ok and $Sereal::Encoder::VERSION < 3.001006; if (not $ok) { plan skip_all => 'Did not find right version of encoder (want 3.001006)'; } else { - run_roundtrip_tests("plain_canon",{canonical => 1}); + run_roundtrip_tests("plain_canon", { canonical => 1 }); } pass(); diff --git a/t/700_roundtrip/v3/snappy_canon.t b/t/700_roundtrip/v3/snappy_canon.t index 605956d..bd673f1 100644 --- a/t/700_roundtrip/v3/snappy_canon.t +++ b/t/700_roundtrip/v3/snappy_canon.t @@ -14,7 +14,7 @@ use Sereal::TestSet qw(:all); use Test::More; my $ok = have_encoder_and_decoder(); -$ok= 0 if $Sereal::Encoder::VERSION < 3.001006; +$ok= 0 if $ok and $Sereal::Encoder::VERSION < 3.001006; if (not $ok) { plan skip_all => 'Did not find right version of encoder (want 3.001006)'; } @@ -22,7 +22,6 @@ else { run_roundtrip_tests('snappy_canon', { snappy => 1, canonical => 1 } ); } - pass(); done_testing(); diff --git a/t/700_roundtrip/v3/snappy_incr_canon.t b/t/700_roundtrip/v3/snappy_incr_canon.t index 1cd5327..dc1e5b1 100644 --- a/t/700_roundtrip/v3/snappy_incr_canon.t +++ b/t/700_roundtrip/v3/snappy_incr_canon.t @@ -14,17 +14,14 @@ use Sereal::TestSet qw(:all); use Test::More; my $ok = have_encoder_and_decoder(); -$ok= 0 if $Sereal::Encoder::VERSION < 3.001006; +$ok= 0 if $ok and $Sereal::Encoder::VERSION < 3.001006; if (not $ok) { plan skip_all => 'Did not find right version of encoder (want 3.001006)'; } else { - run_roundtrip_tests( - 'snappy_incr_canon', { snappy_incr => 1, canonical => 1 } - ); + run_roundtrip_tests('snappy_incr_canon', { snappy_incr => 1, canonical => 1 }); } - pass(); done_testing(); diff --git a/t/lib/Sereal/TestSet.pm b/t/lib/Sereal/TestSet.pm index 6b18413..4982ff1 100644 --- a/t/lib/Sereal/TestSet.pm +++ b/t/lib/Sereal/TestSet.pm @@ -638,7 +638,7 @@ our @ScalarRoundtripTests = ( ["largeish negative int -12345678", -12345678], ( - map {["integer: $_", $_]} ( + map {["integer: $_", 0+$_]} ( # IV bounds of 8 bits -1, 0, 1, -127, -128, -129, 42, 126, 127, 128, 129, 254, 255, 256, 257, # IV bounds of 32 bits @@ -653,8 +653,7 @@ our @ScalarRoundtripTests = ( $eng0e0, $eng0e1, $eng2, ) ), - - ["float", 0.2], + (map { ["float $_", 0+$_] } (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9)), ["short ascii string", "fooo"], ["short latin1 string", "Müller"], ["short utf8 string", do {use utf8; " עדיין ח"} ], @@ -690,8 +689,8 @@ our @ScalarRoundtripTests = ( ["regexp with modifiers", qr/foo/i], ["float", 123013.139], ["negative float",-1234.59], - ["small float",0.41], - ["negative small float",-0.13], + ["small float 0.41",0.41], + ["negative small float -0.13",-0.13], ["small int", 123], ["empty string", ''], ["simple array", []], @@ -703,7 +702,16 @@ our @ScalarRoundtripTests = ( ["deep nest", [1,2,[3,4,{5=>6,7=>{8=>[]},9=>{}},{},[]]]], ["complex hash", { foo => 123, - bar => -159.23 , + bar => -159, pi => 3, + 'baz' =>"foo", + 'bop \''=> "\10" + ,'bop \'\\'=> "\x{100}" , + 'bop \'x\\x' =>"x\x{100}" , 'bing' => "x\x{100}", + x=>'y', z => 'p', i=> '1', l=>" \10", m=>"\10 ", n => " \10 ", + }], + ["complex hash with float", { + foo => 123, + bar => -159.23, a_pi => 3.14159, 'baz' =>"foo", 'bop \''=> "\10" ,'bop \'\\'=> "\x{100}" , @@ -712,7 +720,16 @@ our @ScalarRoundtripTests = ( }], ["more complex", { foo => [123], - "bar" => [-159.23 , { 'baz' => "foo", }, ], + "bar" => [-159, n => 3, { 'baz' => "foo", }, ], + 'bop \''=> { "\10" => { 'bop \'\\'=> "\x{100}", h=>{ + 'bop \'x\\x' =>"x\x{100}" , 'bing' => "x\x{100}", + x=>'y',}, z => 'p' , } , + i => '1' ,}, l=>" \10", m=>"\10 ", n => " \10 ", + o => undef ,p=>undef, q=>\undef, r=>\$eng0e0, u => \$eng0e1, w=>\$eng2 + }], + ["more complex with float", { + foo => [123], + "bar" => [-159.23, a_pi => 3.14159, { 'baz' => "foo", }, ], 'bop \''=> { "\10" => { 'bop \'\\'=> "\x{100}", h=>{ 'bop \'x\\x' =>"x\x{100}" , 'bing' => "x\x{100}", x=>'y',}, z => 'p' , } , @@ -804,6 +821,7 @@ sub _test { } return; } + sub _cmp_str { my ($v1, $v2)= @_; my $v1_is_utf8= is_utf8($v1); @@ -819,7 +837,6 @@ sub _cmp_str { and $diff_start < length($v2) and substr($v1, $diff_start,1) eq substr($v2, $diff_start,1); my $diff_end= length($v1) < length($v2) ? length($v1) : length($v2); - $diff_end-- if $diff_end; $diff_end-- while $diff_end > $diff_start and $diff_end > $diff_start @@ -866,8 +883,8 @@ sub _cmp_str { my $ret= sprintf( "strings different\n" . "first string difference at octet offset %d%s\n" - . "want-octets = %*s (octets: %*d, utf8-flag: %d)\n" . " got-octets = %*s (octets: %*d, utf8-flag: %d)\n" + . "want-octets = %*s (octets: %*d, utf8-flag: %d)\n" ,$diff_start, $issues, -$pad, $q1, $lpad, length($v1), $v1_is_utf8, -$pad, $q2, $lpad, length($v2), $v2_is_utf8, @@ -1066,10 +1083,14 @@ sub run_roundtrip_tests_internal { deep_cmp($decoded3, $decoded, "$name ($ename, $mname, decoded3 vs decoded)") or next; #test deep_cmp($decoded3, $decoded2, "$name ($ename, $mname, decoded3 vs decoded2)") or next; #test - if ( $ename =~ /canon/) { - deep_cmp($encoded2, $encoded, "$name ($ename, $mname, encoded2 vs encoded)") or next; #test - deep_cmp($encoded3, $encoded, "$name ($ename, $mname, encoded3 vs encoded)") or next; #test + if ( $ename =~ /canon/ ) { + deep_cmp($encoded2, $encoded, "$name ($ename, $mname, encoded2 vs encoded)") or do { + diag Dumper($encoded2); + diag Dumper($encoded); + next; #test + }; deep_cmp($encoded3, $encoded2, "$name ($ename, $mname, encoded3 vs encoded2)") or next; #test + deep_cmp($encoded3, $encoded, "$name ($ename, $mname, encoded3 vs encoded)") or next; #test if ($ENV{SEREAL_TEST_SAVE_OUTPUT} and $mname eq 'object-oriented') { use File::Path; -- 2.30.2