From: Nicholas Clark Date: Mon, 11 Dec 2006 22:18:53 +0000 (+0000) Subject: Move PERL_FBM_TABLE_OFFSET and PERL_FBM_FLAGS_OFFSET_FROM_TABLE to sv.h X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=373b357f184d67d2c589b8aca81c803276397db5;p=p5sagit%2Fp5-mst-13.2.git Move PERL_FBM_TABLE_OFFSET and PERL_FBM_FLAGS_OFFSET_FROM_TABLE to sv.h Stow BmRARE in the SvPVX, and so delete xbm_rare. Can you see what it is yet? p4raw-id: //depot/perl@29524 --- diff --git a/sv.h b/sv.h index 4d7ad36..8c98c89 100644 --- a/sv.h +++ b/sv.h @@ -546,7 +546,6 @@ struct xpvbm { HV* xmg_stash; /* class package */ U16 xbm_previous; /* how many characters in string before rare? */ - U8 xbm_rare; /* rarest character in string */ }; /* This structure must match XPVCV in cv.h */ @@ -1310,12 +1309,22 @@ the scalar's value cannot change unless written to. } \ } STMT_END + +#define PERL_FBM_TABLE_OFFSET 5 /* Number of bytes between EOS and table */ +#define PERL_FBM_FLAGS_OFFSET_FROM_TABLE -1 +#define PERL_FBM_RARE_OFFSET_FROM_TABLE -4 + +/* SvPOKp not SvPOK in the assertion because the string can be tainted! eg + perl -T -e '/$^X/' +*/ #if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) # define BmRARE(sv) \ (*({ SV *const _svi = (SV *) (sv); \ assert(SvTYPE(_svi) == SVt_PVBM); \ assert(SvVALID(_svi)); \ - &(((XPVBM*) SvANY(_svi))->xbm_rare); \ + assert(SvPOKp(_svi)); \ + (U8*)(SvEND(_svi) \ + + PERL_FBM_TABLE_OFFSET + PERL_FBM_RARE_OFFSET_FROM_TABLE); \ })) # define BmUSEFUL(sv) \ (*({ SV *const _svi = (SV *) (sv); \ @@ -1331,7 +1340,10 @@ the scalar's value cannot change unless written to. &(((XPVBM*) SvANY(_svi))->xbm_previous); \ })) #else -# define BmRARE(sv) ((XPVBM*) SvANY(sv))->xbm_rare +# define BmRARE(sv) \ + (*(U8*)(SvEND(sv) \ + + PERL_FBM_TABLE_OFFSET + PERL_FBM_RARE_OFFSET_FROM_TABLE)) + # define BmUSEFUL(sv) ((XPVBM*) SvANY(sv))->xiv_u.xivu_i32 # define BmPREVIOUS(sv) ((XPVBM*) SvANY(sv))->xbm_previous #endif diff --git a/util.c b/util.c index 1ce8128..daf88da 100644 --- a/util.c +++ b/util.c @@ -454,9 +454,6 @@ Perl_rninstr(pTHX_ register const char *big, const char *bigend, const char *lit return NULL; } -#define PERL_FBM_TABLE_OFFSET 2 /* Number of bytes between EOS and table*/ -#define PERL_FBM_FLAGS_OFFSET_FROM_TABLE -1 - /* 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().