diff options
author | Karl Williamson <khw@cpan.org> | 2019-11-14 09:36:48 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-11-16 10:49:19 -0700 |
commit | d960bb7e6d65f80e1e6bba024d17d54e589914e5 (patch) | |
tree | 846b3738d6e04bd8a9992e2b0f8f8dd9a4bb71a9 /regen | |
parent | 53b298b6ef3bc08a2369663849893145c56583db (diff) | |
download | perl-d960bb7e6d65f80e1e6bba024d17d54e589914e5.tar.gz |
regen/regcharclass_multi_char_folds.pl: Use printable char
It makes the result more legible if it uses the printable character
instead of an escape sequence when appropriate.
Although, currently, the value is re-escaped for output. This helped
during debugging.
Diffstat (limited to 'regen')
-rw-r--r-- | regen/regcharclass_multi_char_folds.pl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/regen/regcharclass_multi_char_folds.pl b/regen/regcharclass_multi_char_folds.pl index 9840eb9391..a49dcb333e 100644 --- a/regen/regcharclass_multi_char_folds.pl +++ b/regen/regcharclass_multi_char_folds.pl @@ -45,7 +45,9 @@ sub gen_combinations ($;) { foreach my $j (0 .. @{$fold_ref->[$i]} - 1) { # Append its representation to what we have currently - my $new_string = sprintf "$string\\x{%X}", $fold_ref->[$i][$j]; + my $new_string = $fold_ref->[$i][$j] =~ /[[:print:]]/ + ? ($string . chr $fold_ref->[$i][$j]) + : sprintf "$string\\x{%X}", $fold_ref->[$i][$j]; if ($i >= @$fold_ref - 1) { # Final level: just return it push @ret, "\"$new_string\""; @@ -83,8 +85,12 @@ sub multi_char_folds ($) { die sprintf("regcomp.c can't cope with a latin1 multi-char fold (found in the fold of 0x%X", $cp_ref->[$i]) if grep { $_ < 256 && chr($_) !~ /[[:ascii:]]/ } @{$folds_ref->[$i]}; # Create a line that looks like "\x{foo}\x{bar}\x{baz}" of the code - # points that make up the fold. - my $fold = join "", map { sprintf "\\x{%X}", $_ } @{$folds_ref->[$i]}; + # points that make up the fold (use the actual character if + # printable). + my $fold = join "", map { chr $_ =~ /[[:print:]]/a + ? chr $_ + : sprintf "\\x{%X}", $_ + } @{$folds_ref->[$i]}; $fold = "\"$fold\""; # Skip if something else already has this fold |