Open GoogleCodeExporter opened 9 years ago
What steps will reproduce the problem? 1. Patch protobuf-perlxs-1.1/examples/embedded with the following: Index: examples/embedded/test.pl =================================================================== --- examples/embedded/test.pl (revision 191663) +++ examples/embedded/test.pl (working copy) @@ -84,6 +84,8 @@ my $packed = $error->pack; my $length = length($packed); my $elapsed = tv_interval($now); + $error->clear(); + $error->unpack($packed); print "Built/packed error of $length bytes in $elapsed seconds\n"; @@ -116,6 +118,8 @@ my $packed = $error->pack; my $length = length($packed); my $elapsed = tv_interval($now); + $error->clear(); + $error->unpack($packed); print "Built/packed error of $length bytes in $elapsed seconds\n"; 2. perl Makefile.PL && make && make test What is the expected output? What do you see instead? I see output like this: Built/packed error of 141 bytes in 6.8e-05 seconds $VAR1 = { 'datetime' => 1415276412, 'severity' => 3, 'message' => 'Here iing" test' }; Built/packed error of 141 bytes in 6.2e-05 seconds $VAR1 = { 'message' => 'Here iing" test', 'datetime' => 1415276412, 'severity' => 3 }; instead of Built/packed error of 173 bytes in 7.7e-05 seconds $VAR1 = { 'pid' => 29231, 'message' => 'Here is a warning', 'trace' => [ { 'file' => 'test.pl', 'line' => 51 }, { 'line' => 43, 'file' => 'test.pl' }, { 'line' => 39, 'file' => 'test.pl' }, { 'file' => 'test.pl', 'line' => 35 }, { 'file' => 'test.pl', 'line' => 31 }, { 'line' => 27, 'file' => 'test.pl' }, { 'line' => 23, 'file' => 'test.pl' }, { 'line' => 19, 'file' => 'test.pl' }, { 'file' => 'test.pl', 'line' => 15 }, { 'line' => 11, 'file' => 'test.pl' } ], 'hostname' => 'spider-man', 'severity' => 3, 'datetime' => 1415276538 }; Built/packed error of 173 bytes in 6.1e-05 seconds $VAR1 = { 'pid' => 29231, 'message' => 'Here is a warning', 'trace' => [ { 'file' => 'test.pl', 'line' => 51 }, { 'line' => 43, 'file' => 'test.pl' }, { 'file' => 'test.pl', 'line' => 39 }, { 'file' => 'test.pl', 'line' => 35 }, { 'file' => 'test.pl', 'line' => 31 }, { 'file' => 'test.pl', 'line' => 27 }, { 'line' => 23, 'file' => 'test.pl' }, { 'file' => 'test.pl', 'line' => 19 }, { 'file' => 'test.pl', 'line' => 15 }, { 'file' => 'test.pl', 'line' => 12 } ], 'datetime' => 1415276538, 'severity' => 3, 'hostname' => 'spider-man' }; What version of the product are you using? On what operating system? - protobuf-perlxs-1.1 - Ubuntu 14.10 - $ perl -v This is perl 5, version 20, subversion 1 (v5.20.1) built for x86_64-linux-gnu-thread-multi (with 37 registered patches, see perl -V for more detail) Please provide any additional information below. I fixed this by that patch: Index: src/google/protobuf/compiler/perlxs/perlxs_generator.cc =================================================================== --- src/google/protobuf/compiler/perlxs/perlxs_generator.cc (revision 191667) +++ src/google/protobuf/compiler/perlxs/perlxs_generator.cc (working copy) @@ -123,21 +123,19 @@ printer.Print("class $base$_OutputStream :\n" " public google::protobuf::io::ZeroCopyOutputStream {\n" "public:\n" + " explicit $base$_OutputStream(SV * sv) : sv_(sv) {}\n" - " explicit $base$_OutputStream(SV * sv) :\n" - " sv_(sv), len_(0) {}\n" " ~$base$_OutputStream() {}\n" "\n" " bool Next(void** data, int* size)\n" " {\n" + " STRLEN byteCount = SvCUR(sv_);\n" + " STRLEN available = SvLEN(sv_) - byteCount;\n" + " if (available <= 16)\n" + " {\n" + " SvGROW(sv_, 2 * byteCount);\n" + " available = SvLEN(sv_) - byteCount;\n" + " }\n" + " SvCUR_set(sv_, byteCount + available);\n" + " *data = SvPVX(sv_) + byteCount;\n" + " *size = available;\n" - " STRLEN nlen = len_ << 1;\n" - "\n" - " if ( nlen < 16 ) nlen = 16;\n" - " SvGROW(sv_, nlen);\n" - " *data = SvEND(sv_) + len_;\n" - " *size = SvLEN(sv_) - len_;\n" - " len_ = nlen;\n" "\n" " return true;\n" " }\n" @@ -147,7 +145,11 @@ " SvCUR_set(sv_, SvLEN(sv_) - count);\n" " }\n" "\n" + " void Sync() {}\n" - " void Sync() {\n" - " if ( SvCUR(sv_) == 0 ) {\n" - " SvCUR_set(sv_, len_);\n" - " }\n" - " }\n" "\n" " int64_t ByteCount() const\n" " {\n" @@ -156,6 +158,7 @@ "\n" "private:\n" " SV * sv_;\n" - " STRLEN len_;\n" "\n" " GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($base$_OutputStream);\n" "};\n"
Original issue reported on code.google.com by s2...@land.ru on 6 Nov 2014 at 12:32
s2...@land.ru
Original issue reported on code.google.com by
s2...@land.ru
on 6 Nov 2014 at 12:32