From: Steve Hancock Date: Sun, 30 Oct 2022 17:13:29 +0000 (-0700) Subject: fix issue tokenizing 'x' operator, b1410 X-Git-Tag: 20221112~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=36b3b2bbd2d47f0a1731a17ce1d772c7469950f1;p=perltidy.git fix issue tokenizing 'x' operator, b1410 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index c5aaa464..cfabffee 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -10694,6 +10694,14 @@ my %MyTokens= ( --maximum-line-length=66 --noadd-whitespace +==> b1410.in <== +my $line = join( LD_X, map { LD_H x ( $_ + 2 ) } @$widths ); + +my $line = join( LD_X, map { LD_H x( $_ + 2 ) } @$widths ); + +==> b1410.par <== +# (no params) + ==> b1413.in <== &PDL::_conv2d_int( $a, $kern, $c, diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 930c5a0b..fe6d0230 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -3796,7 +3796,7 @@ EOM # have not seen that SPACE is a constant. In this case 'x' is # probably an operator. The only disadvantage with an incorrect # guess is that the space after it may be incorrect. For example - # $str .= SPACE x ( 16 - length($str) ); + # $str .= SPACE x ( 16 - length($str) ); See also b1410. if ( $tok eq 'x' && $last_nonblank_type eq 'w' ) { $type = 'x' } # Fix part 2 for git #63. Leave type as 'w' to keep @@ -3821,16 +3821,22 @@ EOM $statement_type = $tok; # next '{' is block $type = 'k'; # for keyword syntax coloring } + if ( $next_nonblank_token eq '(' ) { - # patch for SWITCH/CASE if switch and given not keywords - # Switch is not a perl 5 keyword, but we will gamble - # and mark switch followed by paren as a keyword. This - # is only necessary to get html syntax coloring nice, - # and does not commit this as being a switch/case. - if ( $next_nonblank_token eq '(' - && ( $tok eq 'switch' || $tok eq 'given' ) ) - { - $type = 'k'; # for keyword syntax coloring + # patch for SWITCH/CASE if switch and given not keywords + # Switch is not a perl 5 keyword, but we will gamble + # and mark switch followed by paren as a keyword. This + # is only necessary to get html syntax coloring nice, + # and does not commit this as being a switch/case. + if ( $tok eq 'switch' || $tok eq 'given' ) { + $type = 'k'; # for keyword syntax coloring + } + + # mark 'x' as operator for something like this (see b1410) + # my $line = join( LD_X, map { LD_H x ( $_ + 2 ) } @$widths ); + elsif ( $tok eq 'x' && $last_nonblank_type eq 'w' ) { + $type = 'x'; + } } } return;