From 6976cee33e524456a81f646a3fa65f279c6c190d Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 9 May 2011 12:07:17 +0100 Subject: [PATCH] Emulate the value of BmFLAGS() using SvTAIL(). Don't set BmFLAGS() in Perl_fbm_compile() Originally fbm_compile() had an I32 flags argument, which seems to have been part of case folding/locale improvements. bbce6d69784bf43b removed this. SvTAIL() was only used in once place until c277df42229d99fe. 2779dcf1a3ceec16 added the U32 flags argument to fbm_compile(), not used until cf93c79d660ae36c. That commit also added FBMcf_TAIL and FBMcf_TAIL{z,Z,DOLLAR} but didn't use the last three. Additionally, it stored the BmFLAGS as part of the compiled table: + table[-1] = flags; /* Not used yet */ f722798beaa43749 added FBMcf_TAIL_DOLLARM, renumbered FBMcf_TAIL{z,Z,DOLLAR}, but still didn't use anything other than FBMcf_TAIL. The core, nothing on CPAN, and nothing visible to Google codesearch, has ever used the 4 specialist flags. The only use is 0 or FBMcf_TAIL, which is in lockstep with SvTAIL() of 0 or non-0. --- sv.h | 10 +++------- util.c | 1 - 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/sv.h b/sv.h index 3d48316..e4e1f7a 100644 --- a/sv.h +++ b/sv.h @@ -1294,13 +1294,10 @@ the scalar's value cannot change unless written to. /* SvPOKp not SvPOK in the assertion because the string can be tainted! eg perl -T -e '/$^X/' */ + +#define BmFLAGS(sv) (SvTAIL(sv) ? FBMcf_TAIL : 0) + #if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) -# define BmFLAGS(sv) \ - (*({ SV *const _bmflags = MUTABLE_SV(sv); \ - assert(SvTYPE(_bmflags) == SVt_PVGV); \ - assert(SvVALID(_bmflags)); \ - &(((XPVGV*) SvANY(_bmflags))->xnv_u.xbm_s.xbm_flags); \ - })) # define BmRARE(sv) \ (*({ SV *const _bmrare = MUTABLE_SV(sv); \ assert(SvTYPE(_bmrare) == SVt_PVGV); \ @@ -1321,7 +1318,6 @@ the scalar's value cannot change unless written to. &(((XPVGV*) SvANY(_bmprevious))->xnv_u.xbm_s.xbm_previous); \ })) #else -# define BmFLAGS(sv) ((XPVGV*) SvANY(sv))->xnv_u.xbm_s.xbm_flags # define BmRARE(sv) ((XPVGV*) SvANY(sv))->xnv_u.xbm_s.xbm_rare # define BmUSEFUL(sv) ((XPVGV*) SvANY(sv))->xiv_u.xivu_i32 # define BmPREVIOUS(sv) ((XPVGV*) SvANY(sv))->xnv_u.xbm_s.xbm_previous diff --git a/util.c b/util.c index 1c68f3d..24a482f 100644 --- a/util.c +++ b/util.c @@ -601,7 +601,6 @@ Perl_fbm_compile(pTHX_ SV *sv, U32 flags) frequency = PL_freq[s[i]]; } } - BmFLAGS(sv) = (U8)flags; BmRARE(sv) = s[rarest]; BmPREVIOUS(sv) = rarest; BmUSEFUL(sv) = 100; /* Initial value */ -- 2.7.4