From 6a612d844833c0d21df2a1b3f71079f9cef19a87 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 30 Aug 2023 17:52:31 -0700 Subject: [PATCH] add some missing terminal else blocks Some dangling elsif's still exist in Formatter and Tokenizer --- lib/Perl/Tidy.pm | 29 +++++++++++++---- lib/Perl/Tidy/HtmlWriter.pm | 17 ++++++++-- lib/Perl/Tidy/VerticalAligner.pm | 53 ++++++++++++++++++++++++-------- 3 files changed, 78 insertions(+), 21 deletions(-) diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 1f3a40dc..51810b4d 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -2067,17 +2067,21 @@ EOM $msg .= " (-pbp contains -st; see manual)" if ($saw_pbp); Die("$msg\n"); } - elsif ($destination_stream) { + + if ($destination_stream) { Die( "You may not specify a destination array and -o together\n" ); } - elsif ( defined( $rOpts->{'output-path'} ) ) { + + if ( defined( $rOpts->{'output-path'} ) ) { Die("You may not specify -o and -opath together\n"); } - elsif ( defined( $rOpts->{'output-file-extension'} ) ) { + + if ( defined( $rOpts->{'output-file-extension'} ) ) { Die("You may not specify -o and -oext together\n"); } + $output_file = $rOpts->{outfile}; $output_name = $output_file; @@ -2610,7 +2614,8 @@ sub process_iteration_layer { { $max_iterations = 1; } - elsif ( $max_iterations > 6 ) { + + if ( $max_iterations > 6 ) { $max_iterations = 6; } @@ -2834,6 +2839,9 @@ EOM print {*STDERR} "STRANGE no conv in $display_name: stopping on it=$iter, but not converged in formatter\n"; } + else { + ## looks ok + } } # we are stopping the iterations early; @@ -3608,13 +3616,16 @@ sub generate_options { foreach my $opt (@option_string) { my $long_name = $opt; $long_name =~ s/(!|=.*|:.*)$//; - unless ( defined( $option_category{$long_name} ) ) { + if ( !defined( $option_category{$long_name} ) ) { if ( $long_name =~ /^html-linked/ ) { $category = 10; # HTML options } elsif ( $long_name =~ /^pod2html/ ) { $category = 11; # Pod2html } + else { + $category = 12; # HTML properties + } $option_category{$long_name} = $category_name[$category]; } } @@ -4184,6 +4195,9 @@ sub _process_command_line { Perl::Tidy::Tokenizer->dump_token_types(*STDOUT); Exit(0); } + else { + ## no more special cases + } } if ( $saw_dump_profile && $saw_ignore_profile ) { @@ -5217,6 +5231,9 @@ sub read_config_file { last; } } + else { + ## done + } # Now store any parameters if ($body) { @@ -5267,7 +5284,7 @@ sub strip_comment { } # handle case of no quotes - elsif ( $instr !~ /['"]/ ) { + if ( $instr !~ /['"]/ ) { # We now require a space before the # of a side comment # this allows something like: diff --git a/lib/Perl/Tidy/HtmlWriter.pm b/lib/Perl/Tidy/HtmlWriter.pm index e4e5a507..06cf6676 100644 --- a/lib/Perl/Tidy/HtmlWriter.pm +++ b/lib/Perl/Tidy/HtmlWriter.pm @@ -747,6 +747,9 @@ sub pod_to_html { $kwd =~ s/^pod//; push @args, "--no$kwd"; } + else { + ## ok - not defined + } } # "flush", @@ -1179,14 +1182,19 @@ PRE_END my $css_string; my $fh_css = Perl::Tidy::IOScalar->new( \$css_string, 'w' ); - # use css linked to another file + # use css linked to another file, if ( $rOpts->{'html-linked-style-sheet'} ) { $fh_css->print( qq()); } - # use css embedded in this file - elsif ( !$rOpts->{'nohtml-style-sheets'} ) { + # or no css, + elsif ( $rOpts->{'nohtml-style-sheets'} ) { + + } + + # or use css embedded in this file + else { $fh_css->print( <<'ENDCSS');