summaryrefslogtreecommitdiff
path: root/regen/regcharclass.pl
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-06-30 12:29:32 -0600
committerKarl Williamson <khw@cpan.org>2021-08-07 04:46:45 -0600
commit8787aefa956b0b3132aee309414bee4cc28895be (patch)
tree4beaa29948bfef89d0c6715b7d42e31d7719ef10 /regen/regcharclass.pl
parent66af77d6a34e55b1fe5818d4274aaf43f7d7f653 (diff)
downloadperl-8787aefa956b0b3132aee309414bee4cc28895be.tar.gz
regcharclass.pl: White-space comment only
A future commit will put a block around this; indent now.
Diffstat (limited to 'regen/regcharclass.pl')
-rwxr-xr-xregen/regcharclass.pl34
1 files changed, 19 insertions, 15 deletions
diff --git a/regen/regcharclass.pl b/regen/regcharclass.pl
index d6385e12cf..63423e18d3 100755
--- a/regen/regcharclass.pl
+++ b/regen/regcharclass.pl
@@ -1087,25 +1087,29 @@ sub _cond_as_str {
$ranges[-1] = $ranges[-1][0] if $ranges[-1][0] == $ranges[-1][1];
}
};
- for my $condition ( @cond ) {
- if ( !@ranges || $condition != $ranges[-1][1] + 1 ) {
- # Not adjacent to the existing range. Remove that from being a
- # range if only a single value;
- $Update->();
- push @ranges, [ $condition, $condition ];
- } else { # Adjacent to the existing range; add to the range
- $ranges[-1][1]++;
+
+ # Go through the code points (@cond) and collapse them as much as
+ # possible into ranges
+ for my $condition ( @cond ) {
+ if ( !@ranges || $condition != $ranges[-1][1] + 1 ) {
+ # Not adjacent to the existing range. Remove that from being a
+ # range if only a single value;
+ $Update->();
+ push @ranges, [ $condition, $condition ];
+ } else { # Adjacent to the existing range; add to the range
+ $ranges[-1][1]++;
+ }
}
- }
- $Update->();
+ $Update->();
- return $self->_combine( $test, @ranges )
- if $combine;
+ # _combine is used for cp type matching.
+ return $self->_combine( $test, @ranges ) if $combine;
- # If the input set has certain characteristics, we can optimize tests
- # for it.
+ # If the input set has certain characteristics, we can optimize tests
+ # for it.
- return 1 if @cond == 256; # If all bytes match, is trivially true
+ # Return if all bytes match, hence is trivially true
+ return 1 if @cond == 256;
# If this is a single UTF-8 range which includes all possible
# continuation bytes, and we aren't checking for well-formedness, this