Skip to content
Browse files

C: fix index #144 fbm, bump B::C back to 1.42_50

missed SvCUR, and had wrong SvLEN
  • Loading branch information...
1 parent d1d652b commit b4f2b31eec42648ed09242ff52cba230fce7f25d @rurban committed Nov 6, 2013
Showing with 21 additions and 3 deletions.
  1. +1 −0 MANIFEST
  2. +5 −3 lib/B/C.pm
  3. +15 −0 t/issue144.t
View
1 MANIFEST
@@ -137,6 +137,7 @@ t/issue98.t
t/issue105.t
t/issue130.t
t/issue141.t
+t/issue144.t
t/modules.pm
t/modules.t
t/mymodules
View
8 lib/B/C.pm
@@ -12,7 +12,7 @@
package B::C;
use strict;
-our $VERSION = '1.43';
+our $VERSION = '1.42_50';
my %debug;
our $check;
my $eval_pvs = '';
@@ -1983,13 +1983,15 @@ sub B::BM::save {
return $sym if !$PERL510 and defined $sym;
$sv = bless $sv, "B::BM" if $PERL510;
my $pv = pack "a*", ( $sv->PV . "\0" . $sv->TABLE );
- my $len = length(pack "a*", $sv->PV);
+ my $cur = length(pack "a*", $sv->PV);
+ my $len = length($pv);
if ($PERL510) {
warn "Saving FBM for GV $sym\n" if $debug{gv};
$init->add( sprintf( "$sym = (GV*)newSV_type(SVt_PVGV);" ),
sprintf( "SvFLAGS($sym) = 0x%x;", $sv->FLAGS),
sprintf( "SvREFCNT($sym) = %u;", $sv->REFCNT + 1 ),
sprintf( "SvPVX($sym) = %s;", cstring($pv) ),
+ sprintf( "SvCUR_set($sym, %d);", $cur ),
sprintf( "SvLEN_set($sym, %d);", $len ),
sprintf( "BmRARE($sym) = %d;", $sv->RARE ),
sprintf( "BmPREVIOUS($sym) = %d;", $sv->PREVIOUS ),
@@ -2003,7 +2005,7 @@ sub B::BM::save {
$xpvbmsect->add(
sprintf("%s, %u, %u, %s, %s, 0, 0, %d, %u, 0x%x",
defined($pv) && $B::C::pv_copy_on_grow ? cstring($pv) : "(char*)ptr_undef",
- $len, $len + 258, ivx($sv->IVX), nvx($sv->NVX),
+ $cur, $len, ivx($sv->IVX), nvx($sv->NVX),
$sv->USEFUL, $sv->PREVIOUS, $sv->RARE
));
$svsect->add(sprintf("&xpvbm_list[%d], %lu, 0x%x",
View
15 t/issue144.t
@@ -0,0 +1,15 @@
+#! /usr/bin/env perl
+# http://code.google.com/p/perl-compiler/issues/detail?id=144
+# BM search for \0
+use Test::More tests => 1;
+use strict;
+BEGIN {
+ unshift @INC, 't';
+ require "test.pl";
+}
+
+#use B::C;
+#my $todo = ($B::C::VERSION < '1.43' ? "TODO " : "");
+#$todo = "" if $] >= 5.016 or $] < 5.010;
+my $todo = "";
+ctestok(1, "C", 'ccode144i', 'print "ok" if 12 == index("long message\0xx","\0")', "${todo}BM search for \\0");

0 comments on commit b4f2b31

Please sign in to comment.
Something went wrong with that request. Please try again.