This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regen/mk_PL_charclass.pl: Refactor a print
[perl5.git] / regen / keywords.pl
index eeed6d4..b77fd67 100755 (executable)
@@ -13,14 +13,12 @@ use Devel::Tokenizer::C 0.05;
 
 require 'regen/regen_lib.pl';
 
-my $h = safer_open('keywords.h-new', 'keywords.h');
-my $c = safer_open('keywords.c-new', 'keywords.c');
-
-print $h read_only_top(lang => 'C', by => 'regen/keywords.pl',
-                      from => 'its data', file => 'keywords.h', style => '*',
-                      copyright => [1994 .. 1997, 1999 .. 2002, 2005 .. 2007]);
-print $c read_only_top(lang => 'C', by => 'regen/keywords.pl',
-                      from => 'its data', style => '*');
+my $h = open_new('keywords.h', '>',
+                { by => 'regen/keywords.pl', from => 'its data',
+                  file => 'keywords.h', style => '*',
+                  copyright => [1994 .. 1997, 1999 .. 2002, 2005 .. 2007]});
+my $c = open_new('keywords.c', '>',
+                { by => 'regen/keywords.pl', from => 'its data', style => '*'});
 
 my %by_strength;
 
@@ -35,6 +33,8 @@ while (<DATA>) {
     push @{$by_strength{$strength}}, $keyword;
 }
 
+# If this hash changes, make sure the equivalent hash in
+# dist/B-Deparse/Deparse.pm is also updated.
 my %feature_kw = (
        given   => 'switch',
        when    => 'switch',
@@ -45,6 +45,12 @@ my %feature_kw = (
        say     => 'say',
 
        state   => 'state',
+
+       evalbytes=>'evalbytes',
+
+       __SUB__ => '__SUB__',
+
+       fc      => 'fc',
        );
 
 my %pos = map { ($_ => 1) } @{$by_strength{'+'}};
@@ -64,12 +70,11 @@ print $c <<"END";
 #define PERL_IN_KEYWORDS_C
 #include "perl.h"
 #include "keywords.h"
+#include "feature.h"
 
 I32
 Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords)
 {
-  dVAR;
-
   PERL_ARGS_ASSERT_KEYWORD;
 
 $switch
@@ -91,7 +96,7 @@ END
   elsif (my $feature = $feature_kw{$k}) {
     $feature =~ s/([\\"])/\\$1/g;
     return <<END;
-return (all_keywords || FEATURE_IS_ENABLED("$feature") ? ${sign}KEY_$k : 0);
+return (all_keywords || FEATURE_\U$feature\E_IS_ENABLED ? ${sign}KEY_$k : 0);
 END
   }
   return <<END;
@@ -101,6 +106,10 @@ END
 
 read_only_bottom_close_and_rename($_, [$0]) foreach $c, $h;
 
+
+# coresub_op in op.c expects __FILE__, __LINE__ and __PACKAGE__ to be the
+# first three.
+
 __END__
 
  NULL
@@ -109,10 +118,10 @@ __END__
 -__PACKAGE__
 +__DATA__
 +__END__
+-__SUB__
 +AUTOLOAD
 +BEGIN
 +UNITCHECK
--CORE
 +DESTROY
 +END
 +INIT
@@ -161,10 +170,12 @@ __END__
 -eof
 -eq
 +eval
+-evalbytes
 -exec
 +exists
 -exit
 -exp
+-fc
 -fcntl
 -fileno
 -flock