]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix rare -xlp instability b1314 involving one-line blocks
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 3 Feb 2022 21:04:45 +0000 (13:04 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 3 Feb 2022 21:04:45 +0000 (13:04 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 542e0449337cca1820674cdf16d5dcbcf35cc6ec..d2fd516e502c09adb7633efd5b803a3a70201137 100644 (file)
@@ -9309,6 +9309,50 @@ WriteMakefile(
 --indent-columns=8
 --maximum-line-length=63
 
+==> b1314.in <==
+# S1
+WriteMakefile(
+        'NAME'         => 'Gimp::Net',
+        'VERSION_FROM' => '../Gimp.pm',
+
+#'INC' => "$INC1 $CPPFLAGS $pdl_inc $cfg{GLIB_CFLAGS} $CFLAGS",
+        'INC' => "$INC1 $CPPFLAGS $pdl_inc $CFLAGS",
+        'DEFINE'   => "$DEFINE1 $DEFS",
+        'TYPEMAPS' =>
+              [ "$topdir/typemap", @pdl_typemaps ],
+
+#dynamic_lib   => { OTHERLDFLAGS => "$LDFLAGS $LIBS $cfg{GLIB_LIBS}" },
+        dynamic_lib =>
+              { OTHERLDFLAGS => "$LDFLAGS $LIBS" },
+        'PM' => {
+                'Net.pm' => '$(INST_LIBDIR)/Net.pm',
+        },
+);
+
+# S2
+WriteMakefile(
+     'NAME'         => 'Gimp::Net',
+     'VERSION_FROM' => '../Gimp.pm',
+
+#'INC' => "$INC1 $CPPFLAGS $pdl_inc $cfg{GLIB_CFLAGS} $CFLAGS",
+     'INC'      => "$INC1 $CPPFLAGS $pdl_inc $CFLAGS",
+     'DEFINE'   => "$DEFINE1 $DEFS",
+     'TYPEMAPS' =>
+           [ "$topdir/typemap", @pdl_typemaps ],
+
+#dynamic_lib   => { OTHERLDFLAGS => "$LDFLAGS $LIBS $cfg{GLIB_LIBS}" },
+     dynamic_lib =>
+           { OTHERLDFLAGS => "$LDFLAGS $LIBS" },
+     'PM' => { 'Net.pm' => '$(INST_LIBDIR)/Net.pm', },
+);
+
+==> b1314.par <==
+--comma-arrow-breakpoints=2
+--continuation-indentation=6
+--extended-line-up-parentheses
+--indent-columns=8
+--maximum-line-length=54
+
 ==> b140.in <==
 $cmd[ $i ]=[
         $s, $e, $cmd, \@hunk, $i ] ;
index 7d920fd11bdf79f9f738884d0b42597233c9625c..13ffdabb443cd663a0752f75dbdd3ab51d3ba04f 100644 (file)
@@ -334,6 +334,7 @@ my (
     @levels_to_go,
     @leading_spaces_to_go,
     @reduced_spaces_to_go,
+    @standard_spaces_to_go,
     @mate_index_to_go,
     @ci_levels_to_go,
     @nesting_depth_to_go,
@@ -12382,6 +12383,8 @@ EOM
             $leading_spaces_to_go[$max_index_to_go] =
               $reduced_spaces + $rOpts_continuation_indentation * $ci_level;
         }
+        $standard_spaces_to_go[$max_index_to_go] =
+          $leading_spaces_to_go[$max_index_to_go];
 
         DEBUG_STORE && do {
             my ( $a, $b, $c ) = caller();
@@ -18946,6 +18949,21 @@ EOM
                     my $excess =
                       $self->excess_line_length( $i_opening_minus, $i );
 
+                    # Use standard spaces for indentation of lists in -lp mode
+                    # if it gives a longer line length. This helps to avoid an
+                    # instability due to forming and breaking one-line blocks.
+                    # This fixes case b1314.
+                    my $indentation = $leading_spaces_to_go[$i_opening_minus];
+                    if ( ref($indentation)
+                        && $ris_broken_container->{$type_sequence} )
+                    {
+                        my $lp_spaces = $indentation->get_spaces();
+                        my $std_spaces =
+                          $standard_spaces_to_go[$i_opening_minus];
+                        my $diff = $std_spaces - $lp_spaces;
+                        if ( $diff > 0 ) { $excess += $diff }
+                    }
+
                     my $tol = $length_tol;
 
                     # boost tol for an -lp container