Change 30141 by [EMAIL PROTECTED] on 2007/02/05 22:46:22
Integrate:
[ 29520]
Rename FBM_TABLE_OFFSET to PERL_FBM_TABLE_OFFSET prior to moving it
to a header.
[ 29522]
Convert the -1 to a more explicit PERL_FBM_FLAGS_OFFSET_FROM_TABLE.
[ 29524]
Move PERL_FBM_TABLE_OFFSET and PERL_FBM_FLAGS_OFFSET_FROM_TABLE to sv.h
[but not this bit:
Stow BmRARE in the SvPVX, and so delete xbm_rare.
Can you see what it is yet?
]
[ 29525]
Add BmPREVIOUS_set(), and use it in the one place that BmPREVIOUS is
modified.
[ 29538]
Correct some assumptions about PVBM table offset in B.xs
[ 29541]
In theory Perl_magic_setbm() should clear SvTAIL() too. In practice,
I don't think that it matters as this routine is never actualy called
because nothing exposes PVBMs to the world so that the world can assign
to them.
[ 29635]
Eliminate BmPREVIOUS_set - with the complexity gone from how the datum
is stored, there's no need for it.
[ 29637]
In Perl_fbm_compile, really rarest should be U32 not I32, as it is
set from a U32, and used as an array index.
Affected files ...
... //depot/maint-5.8/perl/ext/B/B.xs#27 integrate
... //depot/maint-5.8/perl/mg.c#146 integrate
... //depot/maint-5.8/perl/sv.h#76 edit
... //depot/maint-5.8/perl/util.c#144 integrate
Differences ...
==== //depot/maint-5.8/perl/ext/B/B.xs#27 (text) ====
Index: perl/ext/B/B.xs
--- perl/ext/B/B.xs#26~30095~ 2007-02-02 09:46:17.000000000 -0800
+++ perl/ext/B/B.xs 2007-02-05 14:46:22.000000000 -0800
@@ -1248,13 +1248,16 @@
sv_setpvn(ST(0), NULL, 0);
}
+# 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. Not that anything
+# anywhere calls this method. NWC.
void
SvPVBM(sv)
B::PV sv
CODE:
ST(0) = sv_newmortal();
sv_setpvn(ST(0), SvPVX_const(sv),
- SvCUR(sv) + (SvTYPE(sv) == SVt_PVBM ? 257 : 0));
+ SvCUR(sv) + (SvVALID(sv) ? 256 + PERL_FBM_TABLE_OFFSET : 0));
STRLEN
@@ -1407,7 +1410,7 @@
CODE:
str = SvPV(sv, len);
/* Boyer-Moore table is just after string and its safety-margin \0 */
- ST(0) = sv_2mortal(newSVpvn(str + len + 1, 256));
+ ST(0) = sv_2mortal(newSVpvn(str + len + PERL_FBM_TABLE_OFFSET, 256));
MODULE = B PACKAGE = B::GV PREFIX = Gv
==== //depot/maint-5.8/perl/mg.c#146 (text) ====
Index: perl/mg.c
--- perl/mg.c#145~30074~ 2007-01-29 14:57:54.000000000 -0800
+++ perl/mg.c 2007-02-05 14:46:22.000000000 -0800
@@ -2140,6 +2140,7 @@
{
PERL_UNUSED_ARG(mg);
sv_unmagic(sv, PERL_MAGIC_bm);
+ SvTAIL_off(sv);
SvVALID_off(sv);
return 0;
}
==== //depot/maint-5.8/perl/sv.h#76 (text) ====
Index: perl/sv.h
--- perl/sv.h#75~29997~ 2007-01-26 02:30:23.000000000 -0800
+++ perl/sv.h 2007-02-05 14:46:22.000000000 -0800
@@ -1012,6 +1012,9 @@
#define BmUSEFUL(sv) ((XPVBM*) SvANY(sv))->xbm_useful
#define BmPREVIOUS(sv) ((XPVBM*) SvANY(sv))->xbm_previous
+#define PERL_FBM_TABLE_OFFSET 2 /* Number of bytes between EOS and
table */
+#define PERL_FBM_FLAGS_OFFSET_FROM_TABLE -1
+
#define FmLINES(sv) ((XPVFM*) SvANY(sv))->xfm_lines
#define LvTYPE(sv) ((XPVLV*) SvANY(sv))->xlv_type
==== //depot/maint-5.8/perl/util.c#144 (text) ====
Index: perl/util.c
--- perl/util.c#143~30109~ 2007-02-03 10:52:20.000000000 -0800
+++ perl/util.c 2007-02-05 14:46:22.000000000 -0800
@@ -451,8 +451,6 @@
return NULL;
}
-#define FBM_TABLE_OFFSET 2 /* Number of bytes between EOS and table*/
-
/* As a space optimization, we do not compile tables for strings of length
0 and 1, and for strings of length 2 unless FBMcf_TAIL. These are
special-cased in fbm_instr().
@@ -476,7 +474,7 @@
register const U8 *s;
register U32 i;
STRLEN len;
- I32 rarest = 0;
+ U32 rarest = 0;
U32 frequency = 256;
if (flags & FBMcf_TAIL) {
@@ -495,11 +493,12 @@
const U8 mlen = (len>255) ? 255 : (U8)len;
register U8 *table;
- Sv_Grow(sv, len + 256 + FBM_TABLE_OFFSET);
- table = (unsigned char*)(SvPVX_mutable(sv) + len + FBM_TABLE_OFFSET);
- s = table - 1 - FBM_TABLE_OFFSET; /* last char */
+ Sv_Grow(sv, len + 256 + PERL_FBM_TABLE_OFFSET);
+ table
+ = (unsigned char*)(SvPVX_mutable(sv) + len + PERL_FBM_TABLE_OFFSET);
+ s = table - 1 - PERL_FBM_TABLE_OFFSET; /* last char */
memset((void*)table, mlen, 256);
- table[-1] = (U8)flags;
+ table[PERL_FBM_FLAGS_OFFSET_FROM_TABLE] = (U8)flags;
i = 0;
sb = s - mlen + 1; /* first char (maybe) */
while (s >= sb) {
@@ -519,7 +518,7 @@
}
}
BmRARE(sv) = s[rarest];
- BmPREVIOUS(sv) = (U16)rarest;
+ BmPREVIOUS(sv) = rarest;
BmUSEFUL(sv) = 100; /* Initial value */
if (flags & FBMcf_TAIL)
SvTAIL_on(sv);
@@ -682,7 +681,8 @@
return NULL;
{
- register const unsigned char * const table = little + littlelen +
FBM_TABLE_OFFSET;
+ register const unsigned char * const table
+ = little + littlelen + PERL_FBM_TABLE_OFFSET;
register const unsigned char *oldlittle;
--littlelen; /* Last char found by table lookup */
@@ -717,7 +717,8 @@
}
}
check_end:
- if ( s == bigend && (table[-1] & FBMcf_TAIL)
+ if ( s == bigend
+ && (table[PERL_FBM_FLAGS_OFFSET_FROM_TABLE] & FBMcf_TAIL)
&& memEQ((char *)(bigend - littlelen),
(char *)(oldlittle - littlelen), littlelen) )
return (char*)bigend - littlelen;
End of Patch.