diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/B/B.xs | 19 | ||||
-rw-r--r-- | ext/Devel-Peek/t/Peek.t | 4 |
2 files changed, 22 insertions, 1 deletions
diff --git a/ext/B/B.xs b/ext/B/B.xs index 1ca4fd8d99..44f8402691 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -1619,10 +1619,19 @@ PV(sv) U32 utf8 = 0; CODE: if (ix == 3) { +#ifndef PERL_FBM_TABLE_OFFSET + const MAGIC *const mg = mg_find(sv, PERL_MAGIC_bm); + + if (!mg) + croak("argument to B::BM::TABLE is not a PVBM"); + p = mg->mg_ptr; + len = mg->mg_len; +#else p = SvPV(sv, len); /* Boyer-Moore table is just after string and its safety-margin \0 */ p += len + PERL_FBM_TABLE_OFFSET; len = 256; +#endif } else if (ix == 2) { /* This used to read 257. I think that that was buggy - should have been 258. (The "\0", the flags byte, and 256 for the table.) @@ -1635,9 +1644,17 @@ PV(sv) first used by the compiler in 651aa52ea1faa806. It's used to get a "complete" dump of the buffer at SvPVX(), not just the PVBM table. This permits the generated bytecode to "load" - SvPVX in "one" hit. */ + SvPVX in "one" hit. + + 5.15 and later store the BM table via MAGIC, so the compiler + should handle this just fine without changes if PVBM now + always returns the SvPVX() buffer. */ p = SvPVX_const(sv); +#ifdef PERL_FBM_TABLE_OFFSET len = SvCUR(sv) + (SvVALID(sv) ? 256 + PERL_FBM_TABLE_OFFSET : 0); +#else + len = SvCUR(sv); +#endif } else if (ix) { p = SvPVX(sv); len = strlen(p); diff --git a/ext/Devel-Peek/t/Peek.t b/ext/Devel-Peek/t/Peek.t index 715d7f0102..c0cfa93bce 100644 --- a/ext/Devel-Peek/t/Peek.t +++ b/ext/Devel-Peek/t/Peek.t @@ -816,6 +816,8 @@ unless ($Config{useithreads}) { MAGIC = $ADDR MG_VIRTUAL = &PL_vtbl_bm MG_TYPE = PERL_MAGIC_bm\\(B\\) + MG_LEN = 256 + MG_PTR = $ADDR "(?:\\\\\d){256}" RARE = \d+ PREVIOUS = 1 USEFUL = 100 @@ -833,6 +835,8 @@ unless ($Config{useithreads}) { MAGIC = $ADDR MG_VIRTUAL = &PL_vtbl_bm MG_TYPE = PERL_MAGIC_bm\\(B\\) + MG_LEN = 256 + MG_PTR = $ADDR "(?:\\\\\d){256}" RARE = \d+ PREVIOUS = 1 USEFUL = 100 |