From 436e2720ec809d837c5606164f8cd77b70f4e81b Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 22 Aug 2021 15:18:35 -0700 Subject: [PATCH] cleanup perltidy_tab_test --- dev-bin/perltidy_tab_test.pl | 42 ++++++++++++++++++++---------------- local-docs/BugLog.pod | 2 +- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/dev-bin/perltidy_tab_test.pl b/dev-bin/perltidy_tab_test.pl index a8bbc1df..6a5f4bc9 100755 --- a/dev-bin/perltidy_tab_test.pl +++ b/dev-bin/perltidy_tab_test.pl @@ -36,36 +36,40 @@ my $total_error_count = 0; foreach my $file (@files) { unless ( -e $file && -f $file && -s $file ) { - print STDERR "skipping $file\n"; + print "skipping $file: not a regular file\n"; next; } # Best to skip files written by perltidy if ( $file =~ /\.(tdy|ERR|LOG|DEBUG)$/ ) { - print STDERR "skipping $file\n"; + print "skipping $file: wrong extension\n"; next; } - # Skip a file which produces an error - my $tmp = "tmp.out"; - my $cmd = "perltidy $file -o $tmp"; - system($cmd); - my $efile = "$file.ERR"; - if ( -e $efile ) { - unlink $efile; - unlink $tmp; - next; - print "Skipping $file: produces error\n"; - } - - my $tab_count_0 = file_tab_count($file); - my $basename = $file; if ( $basename =~ /^(.*)\/([^\/]+)$/ ) { $basename = $2 } + my $file0 = "$basename.0"; my $file1 = "$basename.1"; my $file2 = "$basename.2"; - add_tabs( $file, $file1 ); + # Skip a file which produces an error + my $efile = "$file0.ERR"; + my $cmd = "perltidy $file -o $file0 -se 2>$efile"; + system($cmd); + if ( -e $efile ) { + if ( -z $efile ) { + unlink $efile; + } + else { + unlink $efile; + unlink $file0; + print "Skipping $file: produces error\n"; + next; + } + } + + my $tab_count_0 = file_tab_count($file0); + add_tabs( $file0, $file1 ); my $tab_count_1 = file_tab_count($file1); $cmd = "perltidy $file1 -o $file2"; @@ -86,6 +90,7 @@ foreach my $file (@files) { # Clean up files if no error, otherwise leave them if ( $status eq "OK" && !-e $file2 . ".ERR" ) { + unlink $file0; unlink $file1; unlink $file2; } @@ -134,6 +139,7 @@ sub write_file { } use Perl::Tidy; + sub add_tabs { my ( $ifile, $ofile ) = @_; @@ -141,7 +147,7 @@ sub add_tabs { # convert code spaces to tabs and write result to $ofile # create a mask for use in avoiding placing tabs in unsafe places - my ( @lines ); + my (@lines); my %args = ( _source => $ifile, diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index d7d8a7df..9abfecad 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -10,7 +10,7 @@ which is fixed with this update. This fixes case b1194, and at the same time it simplifies the logic which handles issues b1183 and b1191. -21 Aug 2021. +21 Aug 2021, 62e5b01. =item B -- 2.39.5