my $token_beg = $rLL->[$Kbeg]->[_TOKEN_];
# allow space(s) after the qw
- if ( length($token_beg) > 3 && substr( $token_beg, 2, 1 ) eq ' ' ) {
+ if ( length($token_beg) > 3 && substr( $token_beg, 2, 1 ) =~ m/\s/ )
+ {
$token_beg =~ s/\s+//;
}
# usually indicates a pattern. We can use this to break ties.
my $is_pattern_by_spacing =
- ( $i > 1 && $next_token ne ' ' && $rtokens->[ $i - 2 ] eq ' ' );
+ ( $i > 1 && $next_token !~ m/^\s/ && $rtokens->[ $i - 2 ] =~ m/^\s/ );
# look for a possible ending / on this line..
my $in_quote = 1;
$max_token_index );
if ($error) { warning("Possibly invalid sub\n") }
- # Patch part #2 to fixes cases b994 and b1053:
- # Do not let spaces be part of the token of an anonymous sub keyword
- # which we marked as type 'k' above...i.e. for something like:
- # 'sub : lvalue { ...'
- # Back up and let it be parsed as a blank
+ # Patch part #2 to fixes cases b994 and b1053:
+ # Do not let spaces be part of the token of an anonymous sub
+ # keyword which we marked as type 'k' above...i.e. for
+ # something like:
+ # 'sub : lvalue { ...'
+ # Back up and let it be parsed as a blank
if ( $type eq 'k'
&& $attrs
&& $i > $i_entry
- && substr( $rtokens->[$i], 0, 1 ) eq ' ' )
+ && substr( $rtokens->[$i], 0, 1 ) =~ m/\s/ )
{
$i--;
}
=over 4
+=item B<Fix some problems involving tabs characters, case c062>
+
+This update fixes some problems found in random testing with tab characters.
+For example, In the following snippet there is a tab character after 'sub'
+
+ do sub : lvalue {
+ return;
+ }
+
+Running perltidy on this repeatedly keep increasing the space between
+'sub' and ':'
+
+ # OLD: perltidy
+ do sub : lvalue {
+ return;
+ }
+
+ # OLD: perltidy
+ do sub : lvalue {
+ return;
+ }
+
+etc.
+
+ # NEW: perltidy
+ do sub : lvalue {
+ return;
+ }
+
+Problems like this can occur if string comparisons use ' ' instead of
+the regex \s when working on spaces. Several instances of this were located
+and corrected.
+
+This fixes issue c062.
+
+18 Aug 2021.
+
=item B<Correct parsing error, case c061>
Testing with random input produced an error condition involving a