From: Steve Hancock Date: Mon, 25 Mar 2024 22:17:51 +0000 (-0700) Subject: fix c352 X-Git-Tag: 20240202.03~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0355bdf07b8f4a7931181625d9cbf9a596108f17;p=perltidy.git fix c352 --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index fd487e0f..2bc654d0 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -23940,6 +23940,11 @@ EOM ) ); return if ( !$combine_ok ); + + # added for issue c352 + if ($this_line_is_semicolon_terminated) { + $forced_breakpoint_to_go[$iend_1] = 0; + } } else { # not a special type @@ -24173,6 +24178,11 @@ EOM ); return if ( !$combine_ok ); + + # added for issue c352 + if ($this_line_is_semicolon_terminated) { + $forced_breakpoint_to_go[$iend_1] = 0; + } } # handle leading keyword.. diff --git a/t/snippets/c352.in b/t/snippets/c352.in new file mode 100644 index 00000000..47ba3a9d --- /dev/null +++ b/t/snippets/c352.in @@ -0,0 +1,4 @@ + # issue c352, recombine a small terminal quote + $text .= filter_blocks( $code, line( substr( $source, 0, $pos[0] ), $line ) ) . ")"; + print( ( $Pipe->ResizeBuffer($NewSize) == $NewSize ) ? "Successful" : "Unsucessful" ) . "!\n\n"; + my $func = 'encode_utf8(' . ( !defined $str ? 'undef' : is_utf8($str) ? '$utf8_str' : '$ascii_str' ) . ')'; diff --git a/t/snippets/expect/c352.def b/t/snippets/expect/c352.def new file mode 100644 index 00000000..28ec750b --- /dev/null +++ b/t/snippets/expect/c352.def @@ -0,0 +1,11 @@ + # issue c352, recombine a small terminal quote + $text .= filter_blocks( $code, + line( substr( $source, 0, $pos[0] ), $line ) ) . ")"; + print( ( $Pipe->ResizeBuffer($NewSize) == $NewSize ) + ? "Successful" + : "Unsucessful" ) . "!\n\n"; + my $func = + 'encode_utf8(' + . ( !defined $str ? 'undef' + : is_utf8($str) ? '$utf8_str' + : '$ascii_str' ) . ')'; diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 629f7b8f..395f7c99 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -412,6 +412,8 @@ ../snippets29.t dia.dia2 ../snippets29.t dia.dia3 ../snippets29.t git134.def +../snippets29.t git135.def +../snippets29.t git135.git135 ../snippets3.t ce_wn1.ce_wn ../snippets3.t ce_wn1.def ../snippets3.t colin.colin @@ -552,5 +554,4 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets29.t git135.def -../snippets29.t git135.git135 +../snippets29.t c352.def diff --git a/t/snippets29.t b/t/snippets29.t index 352dd8f1..06538f48 100644 --- a/t/snippets29.t +++ b/t/snippets29.t @@ -12,6 +12,7 @@ #9 git134.def #10 git135.def #11 git135.git135 +#12 c352.def # To locate test #13 you can search for its name or the string '#13' @@ -54,6 +55,13 @@ BEGIN { ############################ $rsources = { + 'c352' => <<'----------', + # issue c352, recombine a small terminal quote + $text .= filter_blocks( $code, line( substr( $source, 0, $pos[0] ), $line ) ) . ")"; + print( ( $Pipe->ResizeBuffer($NewSize) == $NewSize ) ? "Successful" : "Unsucessful" ) . "!\n\n"; + my $func = 'encode_utf8(' . ( !defined $str ? 'undef' : is_utf8($str) ? '$utf8_str' : '$ascii_str' ) . ')'; +---------- + 'dia' => <<'----------', return $this->{'content'}[$row][$col]; return $this->{'content'}->[$row]->[$col]; @@ -421,6 +429,24 @@ $mask = ~( ~$mask | $DeadBits{$word} ) if $no_fatal; #11........... }, + + 'c352.def' => { + source => "c352", + params => "def", + expect => <<'#12...........', + # issue c352, recombine a small terminal quote + $text .= filter_blocks( $code, + line( substr( $source, 0, $pos[0] ), $line ) ) . ")"; + print( ( $Pipe->ResizeBuffer($NewSize) == $NewSize ) + ? "Successful" + : "Unsucessful" ) . "!\n\n"; + my $func = + 'encode_utf8(' + . ( !defined $str ? 'undef' + : is_utf8($str) ? '$utf8_str' + : '$ascii_str' ) . ')'; +#12........... + }, }; my $ntests = 0 + keys %{$rtests};