summaryrefslogtreecommitdiff
path: root/regen
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-04-28 17:52:42 -0600
committerKarl Williamson <khw@cpan.org>2014-05-31 10:34:00 -0600
commit43b443dd0ed4ebfbf49ce8ba1d876258c7ef7c45 (patch)
tree98cdbe27b713aeaf4b8263d65d86e75a0c5a2878 /regen
parent0f5e3c713841d776646bdbfc3aa8af65037a8dbb (diff)
downloadperl-43b443dd0ed4ebfbf49ce8ba1d876258c7ef7c45.tar.gz
regen/mk_invlists.pl: Remove unnecessary #if's
Even though this file is not intended to be human consumable, it is annoying to see #if ... #endif #if ... where the #endif and #if could be consolidated. It turns out not to be hard to do that.
Diffstat (limited to 'regen')
-rw-r--r--regen/mk_invlists.pl24
1 files changed, 22 insertions, 2 deletions
diff --git a/regen/mk_invlists.pl b/regen/mk_invlists.pl
index d69c37df21..3fb79dde97 100644
--- a/regen/mk_invlists.pl
+++ b/regen/mk_invlists.pl
@@ -22,10 +22,19 @@ my $out_fh = open_new('charclass_invlists.h', '>',
{style => '*', by => $0,
from => "Unicode::UCD"});
+my $is_in_ifndef_ext_re = 0;
+
print $out_fh "/* See the generating file for comments */\n\n";
my %include_in_ext_re = ( NonL1_Perl_Non_Final_Folds => 1 );
+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 output_invlist ($$;$) {
my $name = shift;
my $invlist = shift; # Reference to inversion list array
@@ -46,7 +55,16 @@ sub output_invlist ($$;$) {
}
my $count = @$invlist;
- print $out_fh "\n#ifndef PERL_IN_XSUB_RE\n" unless exists $include_in_ext_re{$name};
+ 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;
+ }
+
print $out_fh "\nstatic const UV ${name}_invlist[] = {";
print $out_fh " /* for $charset */" if $charset;
print $out_fh "\n";
@@ -67,7 +85,6 @@ sub output_invlist ($$;$) {
print $out_fh "\t$invlist->[-1]\n";
print $out_fh "};\n";
- print $out_fh "\n#endif\n" unless exists $include_in_ext_re{$name};
}
sub mk_invlist_from_cp_list {
@@ -126,6 +143,8 @@ sub UpperLatin1 {
output_invlist("Latin1", [ 0, 256 ]);
output_invlist("AboveLatin1", [ 256 ]);
+end_ifndef_ext_re;
+
# We construct lists for all the POSIX and backslash sequence character
# classes in two forms:
# 1) ones which match only in the ASCII range
@@ -274,6 +293,7 @@ for my $charset (get_supported_code_pages()) {
output_invlist($prop_name, \@invlist, $charset);
}
+ end_ifndef_ext_re;
print $out_fh "\n" . get_conditional_compile_line_end();
}