summaryrefslogtreecommitdiff
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
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.
-rw-r--r--charclass_invlists.h94
-rw-r--r--regcomp.c2
-rw-r--r--regen/mk_invlists.pl72
3 files changed, 120 insertions, 48 deletions
diff --git a/charclass_invlists.h b/charclass_invlists.h
index 4b950a9cc7..be2f5b7c4f 100644
--- a/charclass_invlists.h
+++ b/charclass_invlists.h
@@ -7,7 +7,7 @@
/* See the generating file for comments */
-#ifndef PERL_IN_XSUB_RE
+#if defined(PERL_IN_REGCOMP_C)
static const UV Latin1_invlist[] = {
2, /* Number of elements */
@@ -27,11 +27,11 @@ static const UV AboveLatin1_invlist[] = {
0x100
};
-#endif /* #ifndef PERL_IN_XSUB_RE */
+#endif /* defined(PERL_IN_REGCOMP_C) */
#if 'A' == 65 /* ASCII/Latin1 */
-#ifndef PERL_IN_XSUB_RE
+#if defined(PERL_IN_PERL_C)
static const UV ASCII_invlist[] = { /* for ASCII/Latin1 */
2, /* Number of elements */
@@ -304,7 +304,9 @@ static const UV Cased_invlist[] = { /* for ASCII/Latin1 */
0x1F18A
};
-#endif /* #ifndef PERL_IN_XSUB_RE */
+#endif /* defined(PERL_IN_PERL_C) */
+
+#if defined(PERL_IN_REGCOMP_C)
static const UV NonL1_Perl_Non_Final_Folds_invlist[] = { /* for ASCII/Latin1 */
45, /* Number of elements */
@@ -358,8 +360,6 @@ static const UV NonL1_Perl_Non_Final_Folds_invlist[] = { /* for ASCII/Latin1 */
0x1F7D
};
-#ifndef PERL_IN_XSUB_RE
-
static const UV _Perl_Any_Folds_invlist[] = { /* for ASCII/Latin1 */
235, /* Number of elements */
148565664, /* Version and data structure type */
@@ -668,6 +668,10 @@ static const UV _Perl_Folds_To_Multi_Char_invlist[] = { /* for ASCII/Latin1 */
0xFB18
};
+#endif /* defined(PERL_IN_REGCOMP_C) */
+
+#if defined(PERL_IN_UTF8_C)
+
static const UV _Perl_IDCont_invlist[] = { /* for ASCII/Latin1 */
1267, /* Number of elements */
148565664, /* Version and data structure type */
@@ -3044,6 +3048,10 @@ static const UV _Perl_IDStart_invlist[] = { /* for ASCII/Latin1 */
0x2FA1E
};
+#endif /* defined(PERL_IN_UTF8_C) */
+
+#if defined(PERL_IN_REGCOMP_C)
+
static const UV UpperLatin1_invlist[] = { /* for ASCII/Latin1 */
3, /* Number of elements */
148565664, /* Version and data structure type */
@@ -3054,6 +3062,10 @@ static const UV UpperLatin1_invlist[] = { /* for ASCII/Latin1 */
0x100
};
+#endif /* defined(PERL_IN_REGCOMP_C) */
+
+#if defined(PERL_IN_PERL_C)
+
static const UV VertSpace_invlist[] = { /* for ASCII/Latin1 */
7, /* Number of elements */
148565664, /* Version and data structure type */
@@ -12305,7 +12317,7 @@ static const UV XPosixXDigit_invlist[] = { /* for ASCII/Latin1 */
0xFF47
};
-#endif /* #ifndef PERL_IN_XSUB_RE */
+#endif /* defined(PERL_IN_PERL_C) */
#endif /* ASCII/Latin1 */
@@ -12314,7 +12326,7 @@ static const UV XPosixXDigit_invlist[] = { /* for ASCII/Latin1 */
&& '^' == 95 && '~' == 161 && '!' == 90 && '#' == 123 && '|' == 79 \
&& '$' == 91 && '@' == 124 && '`' == 121
-#ifndef PERL_IN_XSUB_RE
+#if defined(PERL_IN_PERL_C)
static const UV ASCII_invlist[] = { /* for EBCDIC 1047 */
54, /* Number of elements */
@@ -12665,7 +12677,9 @@ static const UV Cased_invlist[] = { /* for EBCDIC 1047 */
0x1F18A
};
-#endif /* #ifndef PERL_IN_XSUB_RE */
+#endif /* defined(PERL_IN_PERL_C) */
+
+#if defined(PERL_IN_REGCOMP_C)
static const UV NonL1_Perl_Non_Final_Folds_invlist[] = { /* for EBCDIC 1047 */
45, /* Number of elements */
@@ -12719,8 +12733,6 @@ static const UV NonL1_Perl_Non_Final_Folds_invlist[] = { /* for EBCDIC 1047 */
0x1F7D
};
-#ifndef PERL_IN_XSUB_RE
-
static const UV _Perl_Any_Folds_invlist[] = { /* for EBCDIC 1047 */
267, /* Number of elements */
148565664, /* Version and data structure type */
@@ -13061,6 +13073,10 @@ static const UV _Perl_Folds_To_Multi_Char_invlist[] = { /* for EBCDIC 1047 */
0xFB18
};
+#endif /* defined(PERL_IN_REGCOMP_C) */
+
+#if defined(PERL_IN_UTF8_C)
+
static const UV _Perl_IDCont_invlist[] = { /* for EBCDIC 1047 */
1291, /* Number of elements */
148565664, /* Version and data structure type */
@@ -15487,6 +15503,10 @@ static const UV _Perl_IDStart_invlist[] = { /* for EBCDIC 1047 */
0x2FA1E
};
+#endif /* defined(PERL_IN_UTF8_C) */
+
+#if defined(PERL_IN_REGCOMP_C)
+
static const UV UpperLatin1_invlist[] = { /* for EBCDIC 1047 */
55, /* Number of elements */
148565664, /* Version and data structure type */
@@ -15549,6 +15569,10 @@ static const UV UpperLatin1_invlist[] = { /* for EBCDIC 1047 */
0x100
};
+#endif /* defined(PERL_IN_REGCOMP_C) */
+
+#if defined(PERL_IN_PERL_C)
+
static const UV VertSpace_invlist[] = { /* for EBCDIC 1047 */
9, /* Number of elements */
148565664, /* Version and data structure type */
@@ -24912,7 +24936,7 @@ static const UV XPosixXDigit_invlist[] = { /* for EBCDIC 1047 */
0xFF47
};
-#endif /* #ifndef PERL_IN_XSUB_RE */
+#endif /* defined(PERL_IN_PERL_C) */
#endif /* EBCDIC 1047 */
@@ -24921,7 +24945,7 @@ static const UV XPosixXDigit_invlist[] = { /* for EBCDIC 1047 */
&& '^' == 176 && '~' == 161 && '!' == 90 && '#' == 123 && '|' == 79 \
&& '$' == 91 && '@' == 124 && '`' == 121
-#ifndef PERL_IN_XSUB_RE
+#if defined(PERL_IN_PERL_C)
static const UV ASCII_invlist[] = { /* for EBCDIC 037 */
56, /* Number of elements */
@@ -25270,7 +25294,9 @@ static const UV Cased_invlist[] = { /* for EBCDIC 037 */
0x1F18A
};
-#endif /* #ifndef PERL_IN_XSUB_RE */
+#endif /* defined(PERL_IN_PERL_C) */
+
+#if defined(PERL_IN_REGCOMP_C)
static const UV NonL1_Perl_Non_Final_Folds_invlist[] = { /* for EBCDIC 037 */
45, /* Number of elements */
@@ -25324,8 +25350,6 @@ static const UV NonL1_Perl_Non_Final_Folds_invlist[] = { /* for EBCDIC 037 */
0x1F7D
};
-#ifndef PERL_IN_XSUB_RE
-
static const UV _Perl_Any_Folds_invlist[] = { /* for EBCDIC 037 */
263, /* Number of elements */
148565664, /* Version and data structure type */
@@ -25662,6 +25686,10 @@ static const UV _Perl_Folds_To_Multi_Char_invlist[] = { /* for EBCDIC 037 */
0xFB18
};
+#endif /* defined(PERL_IN_REGCOMP_C) */
+
+#if defined(PERL_IN_UTF8_C)
+
static const UV _Perl_IDCont_invlist[] = { /* for EBCDIC 037 */
1287, /* Number of elements */
148565664, /* Version and data structure type */
@@ -28080,6 +28108,10 @@ static const UV _Perl_IDStart_invlist[] = { /* for EBCDIC 037 */
0x2FA1E
};
+#endif /* defined(PERL_IN_UTF8_C) */
+
+#if defined(PERL_IN_REGCOMP_C)
+
static const UV UpperLatin1_invlist[] = { /* for EBCDIC 037 */
57, /* Number of elements */
148565664, /* Version and data structure type */
@@ -28144,6 +28176,10 @@ static const UV UpperLatin1_invlist[] = { /* for EBCDIC 037 */
0x100
};
+#endif /* defined(PERL_IN_REGCOMP_C) */
+
+#if defined(PERL_IN_PERL_C)
+
static const UV VertSpace_invlist[] = { /* for EBCDIC 037 */
9, /* Number of elements */
148565664, /* Version and data structure type */
@@ -37493,7 +37529,7 @@ static const UV XPosixXDigit_invlist[] = { /* for EBCDIC 037 */
0xFF47
};
-#endif /* #ifndef PERL_IN_XSUB_RE */
+#endif /* defined(PERL_IN_PERL_C) */
#endif /* EBCDIC 037 */
@@ -37502,7 +37538,7 @@ static const UV XPosixXDigit_invlist[] = { /* for EBCDIC 037 */
&& '^' == 106 && '~' == 255 && '!' == 90 && '#' == 123 && '|' == 79 \
&& '$' == 91 && '@' == 124 && '`' == 74
-#ifndef PERL_IN_XSUB_RE
+#if defined(PERL_IN_PERL_C)
static const UV ASCII_invlist[] = { /* for EBCDIC POSIX-BC */
58, /* Number of elements */
@@ -37855,7 +37891,9 @@ static const UV Cased_invlist[] = { /* for EBCDIC POSIX-BC */
0x1F18A
};
-#endif /* #ifndef PERL_IN_XSUB_RE */
+#endif /* defined(PERL_IN_PERL_C) */
+
+#if defined(PERL_IN_REGCOMP_C)
static const UV NonL1_Perl_Non_Final_Folds_invlist[] = { /* for EBCDIC POSIX-BC */
45, /* Number of elements */
@@ -37909,8 +37947,6 @@ static const UV NonL1_Perl_Non_Final_Folds_invlist[] = { /* for EBCDIC POSIX-BC
0x1F7D
};
-#ifndef PERL_IN_XSUB_RE
-
static const UV _Perl_Any_Folds_invlist[] = { /* for EBCDIC POSIX-BC */
265, /* Number of elements */
148565664, /* Version and data structure type */
@@ -38249,6 +38285,10 @@ static const UV _Perl_Folds_To_Multi_Char_invlist[] = { /* for EBCDIC POSIX-BC *
0xFB18
};
+#endif /* defined(PERL_IN_REGCOMP_C) */
+
+#if defined(PERL_IN_UTF8_C)
+
static const UV _Perl_IDCont_invlist[] = { /* for EBCDIC POSIX-BC */
1289, /* Number of elements */
148565664, /* Version and data structure type */
@@ -40671,6 +40711,10 @@ static const UV _Perl_IDStart_invlist[] = { /* for EBCDIC POSIX-BC */
0x2FA1E
};
+#endif /* defined(PERL_IN_UTF8_C) */
+
+#if defined(PERL_IN_REGCOMP_C)
+
static const UV UpperLatin1_invlist[] = { /* for EBCDIC POSIX-BC */
57, /* Number of elements */
148565664, /* Version and data structure type */
@@ -40735,6 +40779,10 @@ static const UV UpperLatin1_invlist[] = { /* for EBCDIC POSIX-BC */
0xFF
};
+#endif /* defined(PERL_IN_REGCOMP_C) */
+
+#if defined(PERL_IN_PERL_C)
+
static const UV VertSpace_invlist[] = { /* for EBCDIC POSIX-BC */
9, /* Number of elements */
148565664, /* Version and data structure type */
@@ -50096,7 +50144,7 @@ static const UV XPosixXDigit_invlist[] = { /* for EBCDIC POSIX-BC */
0xFF47
};
-#endif /* #ifndef PERL_IN_XSUB_RE */
+#endif /* defined(PERL_IN_PERL_C) */
#endif /* EBCDIC POSIX-BC */
@@ -50142,5 +50190,5 @@ static const UV XPosixXDigit_invlist[] = { /* for EBCDIC POSIX-BC */
* a17a0330e57d774343a53c019f1bc69827c2676982a1bf48e0898a76710e8877 lib/unicore/extracted/DNumType.txt
* c2cb810a67cc5fb4a8d236b6c1bc6dd4d89733d8603881997e8aae2c816a3db1 lib/unicore/extracted/DNumValues.txt
* 746472de66b936ac885ca6d6e68058242b4e909e3260c6317f3ec719f78f76cc lib/unicore/version
- * 7e16ea29ac35eda35bb9d7d5e4259f3f966a8c6018abe130125a14b665637eb2 regen/mk_invlists.pl
+ * d2f4d6b72ebe8a99a7be2ebe9aecb388f207806e3a4b72aaeac76d64b95233ed regen/mk_invlists.pl
* ex: set ro: */
diff --git a/regcomp.c b/regcomp.c
index 68f6bfdc43..82be6417d7 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -6413,7 +6413,6 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
DEBUG_r(if (!PL_colorset) reginitcolors());
-#ifndef PERL_IN_XSUB_RE
/* Initialize these here instead of as-needed, as is quick and avoids
* having to test them each time otherwise */
if (! PL_AboveLatin1) {
@@ -6431,7 +6430,6 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
PL_InBitmap = _add_range_to_invlist(PL_InBitmap, 0,
NUM_ANYOF_CODE_POINTS - 1);
}
-#endif
pRExC_state->code_blocks = NULL;
pRExC_state->num_code_blocks = 0;
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();
}