From: Steve Hancock Date: Sat, 28 Nov 2020 14:21:25 +0000 (-0800) Subject: remove unwanted spaces in a package declaration X-Git-Tag: 20201202~5 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=008443dd0a7aa5eb37291b9a4d5264128692dc0f;p=perltidy.git remove unwanted spaces in a package declaration --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 79ec3533..8fe58fbb 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -5397,6 +5397,13 @@ sub respace_tokens { $rtoken_vars->[_TOKEN_] = $token; } + # clean up spaces in package identifiers, like + # "package Bob::Dog;" + if ($token =~ /^package\s/) { + $token =~ s/\s+/ /g; + $rtoken_vars->[_TOKEN_] = $token; + } + # trim identifiers of trailing blanks which can occur # under some unusual circumstances, such as if the # identifier 'witch' has trailing blanks on input here: @@ -10193,7 +10200,7 @@ EOM } # break before all package declarations - elsif ( $leading_token =~ /^(package\s)/ ) { + elsif ( substr( $leading_token, 0, 8 ) eq 'package ' ) { $want_blank = $rOpts->{'blank-lines-before-packages'}; } } diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 3d28fcf2..1e83ebbb 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,18 @@ =over 4 +=item B + +Testing revealed that for a line such as + + package Bob::Dog; + +which has extra spaces or even tabs after the keyword 'package', the +extra spaces or tabs were not being removed. This was fixed 28 Nov 2020. +The line now formats to + + package Bob::Dog; + =item B For the parameter combination --indent-only and --closing-side-comments, old