: Used in keywords.c and toke.c
Xop |bool |feature_is_enabled|NN const char *const name \
- |STRLEN namelen|bool negate
+ |STRLEN namelen
: ex: set ts=8 sts=4 sw=4 noet:
( \
CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_511 \
|| (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
- FEATURE_IS_ENABLED_d("arybase")) \
+ FEATURE_IS_ENABLED("arybase")) \
)
#define FEATURE___SUB___IS_ENABLED \
state => 'feature_state',
switch => 'feature_switch',
evalbytes => 'feature_evalbytes',
+ array_base => 'feature_arybase',
current_sub => 'feature___SUB__',
unicode_eval => 'feature_unieval',
unicode_strings => 'feature_unicode',
);
-my %default_feature = (
- array_base => 'feature_noarybase',
-);
-
our %feature_bundle = (
"5.10" => [qw(array_base say state switch)],
"5.11" => [qw(array_base say state switch unicode_strings)],
next;
}
if (!exists $feature{$name}) {
- if (!exists $default_feature{$name}) {
unknown_feature($name);
- }
- delete $^H{$default_feature{$name}}; next;
}
$^H{$feature{$name}} = 1;
$^H |= $hint_uni8bit if $name eq 'unicode_strings';
if (!@_) {
delete @^H{ values(%feature) };
$^H &= ~ $hint_uni8bit;
- @^H{ values(%default_feature) } = (1) x keys %default_feature;
return;
}
next;
}
if (!exists($feature{$name})) {
- if (!exists $default_feature{$name}) {
unknown_feature($name);
- }
- $^H{$default_feature{$name}} = 1; next;
}
else {
delete $^H{$feature{$name}};
# define FEATURE_IS_ENABLED(name) \
(((PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints) \
& HINT_LOCALIZE_HH) \
- && Perl_feature_is_enabled(aTHX_ STR_WITH_LEN(name), 0))
-# define FEATURE_IS_ENABLED_d(name) \
- (!((PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints) \
- & HINT_LOCALIZE_HH) \
- || Perl_feature_is_enabled(aTHX_ STR_WITH_LEN(name), 1))
+ && Perl_feature_is_enabled(aTHX_ STR_WITH_LEN(name)))
/* The longest string we pass in. */
# define MAX_FEATURE_LEN (sizeof("unicode_strings")-1)
#endif
#define PERL_ARGS_ASSERT_FBM_INSTR \
assert(big); assert(bigend); assert(littlestr)
-PERL_CALLCONV bool Perl_feature_is_enabled(pTHX_ const char *const name, STRLEN namelen, bool negate)
+PERL_CALLCONV bool Perl_feature_is_enabled(pTHX_ const char *const name, STRLEN namelen)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_FEATURE_IS_ENABLED \
assert(name)
state => 'state',
switch => 'switch',
evalbytes => 'evalbytes',
+ array_base => 'arybase',
current_sub => '__SUB__',
unicode_eval => 'unieval',
unicode_strings => 'unicode',
);
-# These work backwards--the presence of the hint elem disables the feature:
-my %default_feature = (
- array_base => 'noarybase',
-);
-
# NOTE: If a feature is ever enabled in a non-contiguous range of Perl
# versions, any code below that uses %BundleRanges will have to
# be changed to account.
my %feature_bundle = (
- default => [keys %default_feature],
+ default => [qw(array_base)],
"5.9.5" => [qw(say state switch array_base)],
"5.10" => [qw(say state switch array_base)],
"5.11" => [qw(say state switch unicode_strings array_base)],
}
print $pm ");\n\n";
-print $pm "my %default_feature = (\n";
-$width = length longest keys %default_feature;
-for(sort { length $a <=> length $b } keys %default_feature) {
- print $pm " $_" . " "x($width-length)
- . " => 'feature_$default_feature{$_}',\n";
-}
-print $pm ");\n\n";
-
print $pm "our %feature_bundle = (\n";
$width = length longest values %UniqueBundles;
for( sort { $UniqueBundles{$a} cmp $UniqueBundles{$b} }
EOH
for (
- sort { length $a <=> length $b } keys %feature, keys %default_feature
+ sort { length $a <=> length $b } keys %feature
) {
my($first,$last) =
map { (my $__ = uc) =~ y/.//d; $__ } @{$BundleRanges{$_}};
- my $default = '';
- my $name = $feature{$_} # skip "no"
- || ($default = '_d', substr $default_feature{$_}, 2);
+ my $name = $feature{$_};
my $NAME = uc $name;
if ($last && $first eq 'DEFAULT') { # ‘>= DEFAULT’ warns
print $h <<EOI;
( \\
CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_$last \\
|| (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \\
- FEATURE_IS_ENABLED$default("$name")) \\
+ FEATURE_IS_ENABLED("$name")) \\
)
EOI
(CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_$first && \\
CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_$last) \\
|| (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \\
- FEATURE_IS_ENABLED$default("$name")) \\
+ FEATURE_IS_ENABLED("$name")) \\
)
EOH3
( \\
CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_$first \\
|| (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \\
- FEATURE_IS_ENABLED$default("$name")) \\
+ FEATURE_IS_ENABLED("$name")) \\
)
EOH4
next;
}
if (!exists $feature{$name}) {
- if (!exists $default_feature{$name}) {
unknown_feature($name);
- }
- delete $^H{$default_feature{$name}}; next;
}
$^H{$feature{$name}} = 1;
$^H |= $hint_uni8bit if $name eq 'unicode_strings';
if (!@_) {
delete @^H{ values(%feature) };
$^H &= ~ $hint_uni8bit;
- @^H{ values(%default_feature) } = (1) x keys %default_feature;
return;
}
next;
}
if (!exists($feature{$name})) {
- if (!exists $default_feature{$name}) {
unknown_feature($name);
- }
- $^H{$default_feature{$name}} = 1; next;
}
else {
delete $^H{$feature{$name}};
* Check whether the named feature is enabled.
*/
bool
-Perl_feature_is_enabled(pTHX_ const char *const name, STRLEN namelen,
- bool negate)
+Perl_feature_is_enabled(pTHX_ const char *const name, STRLEN namelen)
{
dVAR;
char he_name[8 + MAX_FEATURE_LEN] = "feature_";
if (namelen > MAX_FEATURE_LEN)
return FALSE;
- if (negate) he_name[8] = 'n', he_name[9] = 'o';
- memcpy(&he_name[8 + 2*negate], name, namelen);
+ memcpy(&he_name[8], name, namelen);
return
- !cop_hints_fetch_pvn(
- PL_curcop, he_name, 8 + 2*negate + namelen, 0,
+ cop_hints_fetch_pvn(
+ PL_curcop, he_name, 8 + namelen, 0,
REFCOUNTED_HE_EXISTS
- )
- != !negate;
+ );
}
/*