summaryrefslogtreecommitdiff
path: root/regen
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2015-02-18 21:49:16 -0700
committerKarl Williamson <khw@cpan.org>2015-02-19 22:55:01 -0700
commitbffc0129838467aca7ff705648325416f784103b (patch)
treeb73ba6e3d4b25c1c22063a51f45937eb2e565544 /regen
parent99f21fb92b1b4439457ea2dcec73032345fe4fea (diff)
downloadperl-bffc0129838467aca7ff705648325416f784103b.tar.gz
regen/mk_invlists.pl: Revamp #if generation
This changes where the symbols are defined to a single file each. This may save text space, depending on the compiler. The next commit will cause this hdr to be included in more places, so it becomes more important to do this. At the same time this removes the guard for #ifndef PERL_IN_XSUB_RE. The code now is executed regardless of that. This is simpler, and previously there might have been the possibility of uninitialized memory being read, should re_comp.o be executed before recomp.o.
Diffstat (limited to 'regen')
-rw-r--r--regen/mk_invlists.pl72
1 files changed, 49 insertions, 23 deletions
diff --git a/regen/mk_invlists.pl b/regen/mk_invlists.pl
index 69027d43fe..73ea1ec314 100644
--- a/regen/mk_invlists.pl
+++ b/regen/mk_invlists.pl
@@ -38,11 +38,23 @@ my $out_fh = open_new('charclass_invlists.h', '>',
{style => '*', by => $0,
from => "Unicode::UCD"});
-my $is_in_ifndef_ext_re = 0;
+my $in_file_pound_if = 0;
print $out_fh "/* See the generating file for comments */\n\n";
-my %include_in_ext_re = ( NonL1_Perl_Non_Final_Folds => 1 );
+# The symbols generated by this program are all currently defined only in a
+# single dot c each. The code knows where most of them go, but this hash
+# gives overrides for the exceptions to the typical place
+my %exceptions_to_where_to_define =
+ ( NonL1_Perl_Non_Final_Folds => 'PERL_IN_REGCOMP_C',
+ AboveLatin1 => 'PERL_IN_REGCOMP_C',
+ Latin1 => 'PERL_IN_REGCOMP_C',
+ UpperLatin1 => 'PERL_IN_REGCOMP_C',
+ _Perl_Any_Folds => 'PERL_IN_REGCOMP_C',
+ _Perl_Folds_To_Multi_Char => 'PERL_IN_REGCOMP_C',
+ _Perl_IDCont => 'PERL_IN_UTF8_C',
+ _Perl_IDStart => 'PERL_IN_UTF8_C',
+ );
my @a2n;
@@ -63,10 +75,36 @@ sub a2n($) {
return $a2n[$cp];
}
-sub end_ifndef_ext_re {
- if ($is_in_ifndef_ext_re) {
- print $out_fh "\n#endif\t/* #ifndef PERL_IN_XSUB_RE */\n";
- $is_in_ifndef_ext_re = 0;
+sub end_file_pound_if {
+ if ($in_file_pound_if) {
+ print $out_fh "\n#endif\t/* $in_file_pound_if */\n";
+ $in_file_pound_if = 0;
+ }
+}
+
+sub switch_pound_if ($$) {
+ my $name = shift;
+ my $new_pound_if = shift;
+
+ # Switch to new #if given by the 2nd argument. If there is an override
+ # for this, it instead switches to that. The 1st argument is the
+ # static's name, used to look up the overrides
+
+ if (exists $exceptions_to_where_to_define{$name}) {
+ $new_pound_if = $exceptions_to_where_to_define{$name};
+ }
+
+ # Exit current #if if the new one is different from the old
+ if ($in_file_pound_if
+ && $in_file_pound_if !~ /$new_pound_if/)
+ {
+ end_file_pound_if;
+ }
+
+ # Enter new #if, if not already in it.
+ if (! $in_file_pound_if) {
+ $in_file_pound_if = "defined($new_pound_if)";
+ print $out_fh "\n#if $in_file_pound_if\n";
}
}
@@ -90,15 +128,7 @@ sub output_invlist ($$;$) {
}
my $count = @$invlist;
- if ($is_in_ifndef_ext_re) {
- if (exists $include_in_ext_re{$name}) {
- end_ifndef_ext_re;
- }
- }
- elsif (! exists $include_in_ext_re{$name}) {
- print $out_fh "\n#ifndef PERL_IN_XSUB_RE\n" unless exists $include_in_ext_re{$name};
- $is_in_ifndef_ext_re = 1;
- }
+ switch_pound_if ($name, 'PERL_IN_PERL_C');
print $out_fh "\nstatic const UV ${name}_invlist[] = {";
print $out_fh " /* for $charset */" if $charset;
@@ -165,7 +195,8 @@ sub output_invmap ($$$$$$$) {
}
}
- end_ifndef_ext_re;
+ # Inversion map stuff is currently used only by regexec
+ switch_pound_if($name, 'PERL_IN_REGEXEC_C');
{
my $short_name = (prop_aliases($prop_name))[0];
@@ -213,11 +244,6 @@ sub output_invmap ($$$$$$$) {
print $out_fh "\n";
}
print $out_fh "};\n";
-
- unless ($is_in_ifndef_ext_re) {
- print $out_fh "\n#ifndef PERL_IN_XSUB_RE\n";
- $is_in_ifndef_ext_re = 1;
- }
}
sub mk_invlist_from_sorted_cp_list {
@@ -289,7 +315,7 @@ sub UpperLatin1 {
output_invlist("Latin1", [ 0, 256 ]);
output_invlist("AboveLatin1", [ 256 ]);
-end_ifndef_ext_re;
+end_file_pound_if;
# We construct lists for all the POSIX and backslash sequence character
# classes in two forms:
@@ -677,7 +703,7 @@ for my $charset (get_supported_code_pages()) {
output_invlist($prop_name, \@invlist, $charset);
output_invmap($prop_name, \@invmap, $lookup_prop, $map_format, $map_default, $extra_enums, $charset) if @invmap;
}
- end_ifndef_ext_re;
+ end_file_pound_if;
print $out_fh "\n" . get_conditional_compile_line_end();
}