This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make ‘make regen’ regenerate the tree in perllexwarn
[perl5.git] / regen / regcharclass_multi_char_folds.pl
index ce2d781..f04be85 100644 (file)
@@ -9,15 +9,19 @@ use Unicode::UCD "prop_invmap";
 # of the sequences of code points that are multi-character folds in the
 # current Unicode version.  If the parameter is 1, all such folds are
 # returned.  If the parameters is 0, only the ones containing exclusively
-# ASCII characters are returned.  In the latter case all combinations of ASCII
-# characters that can fold to the base one are returned.  Thus for 'ss', it
-# would return in addition, 'Ss', 'sS', and 'SS'.  This is because this code
-# is designed to help regcomp.c, and EXACTFish regnodes.  For non-UTF-8
-# patterns, the strings are not folded, so we need to check for the upper and
-# lower case versions.  For UTF-8 patterns, the strings are folded, so we only
-# need to worry about the fold version.  There are no non-ASCII Latin1
-# multi-char folds currently, and none likely to be ever added, so this
-# doesn't worry about that case, except to croak should it happen.
+# Latin1 characters are returned.  In the latter case all combinations of
+# Latin1 characters that can fold to the base one are returned.  Thus for
+# 'ss', it would return in addition, 'Ss', 'sS', and 'SS'.  This is because
+# this code is designed to help regcomp.c, and EXACTFish regnodes.  For
+# non-UTF-8 patterns, the strings are not folded, so we need to check for the
+# upper and lower case versions.  For UTF-8 patterns, the strings are folded,
+# so we only need to worry about the fold version.  There are no non-ASCII
+# Latin1 multi-char folds currently, and none likely to be ever added.  Thus
+# the output is the same as if it were just asking for ASCII characters, not
+# full Latin1.  Hence, it is suitable for generating things that match
+# EXACTFA.  It does check for and croak if there ever were to be an upper
+# Latin1 range multi-character fold.
+#
 # This is designed for input to regen/regcharlass.pl.
 
 sub gen_combinations ($;) {
@@ -100,6 +104,29 @@ sub multi_char_folds ($) {
         }
     }
 
+    # \x17F is the small LONG S, which folds to 's'.  Both Capital and small
+    # LATIN SHARP S fold to 'ss'.  Therefore, they should also match two 17F's
+    # in a row under regex /i matching.  But under /iaa regex matching, all
+    # three folds to 's' are prohibited, but the sharp S's should still match
+    # two 17F's.  This prohibition causes our regular regex algorithm that
+    # would ordinarily allow this match to fail.  This is the only instance in
+    # all Unicode of this kind of issue.  By adding a special case here, we
+    # can use the regular algorithm (with some other changes elsewhere as
+    # well).
+    #
+    # It would be possible to re-write the above code to automatically detect
+    # and handle this case, and any others that might eventually get added to
+    # the Unicode standard, but I (khw) don't think it's worth it.  I believe
+    # that it's extremely unlikely that more folds to ASCII characters are
+    # going to be added, and if I'm wrong, fold_grind.t has the intelligence
+    # to detect them, and test that they work, at which point another special
+    # case could be added here if necessary.
+    #
+    # No combinations of this with 's' need be added, as any of these
+    # containing 's' are prohibted under /iaa.
+    push @folds, "\"\x{17F}\x{17F}\"";
+
+
     return @folds;
 }