ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Perl-Strip/Strip.pm
(Generate patch)

Comparing Perl-Strip/Strip.pm (file contents):
Revision 1.3 by root, Mon Jan 23 02:24:31 2012 UTC vs.
Revision 1.4 by root, Thu Aug 3 03:05:56 2023 UTC

29 29
30=cut 30=cut
31 31
32package Perl::Strip; 32package Perl::Strip;
33 33
34our $VERSION = '1.1'; 34our $VERSION = '1.2';
35our $CACHE_VERSION = 2; 35our $CACHE_VERSION = 3;
36 36
37use common::sense; 37use common::sense;
38 38
39use PPI; 39use PPI;
40 40
132 my $next = $ws->next_token; 132 my $next = $ws->next_token;
133 133
134 if (!$prev || !$next) { 134 if (!$prev || !$next) {
135 $ws->delete; 135 $ws->delete;
136 } else { 136 } else {
137 if ($next->isa (PPI::Token::Whitespace::)) {
138 $ws->delete;
137 if ( 139 } elsif (
138 $next->isa (PPI::Token::Operator::) && $next->{content} =~ /^(?:,|=|!|!=|==|=>)$/ # no ., because of digits. == float 140 $next->isa (PPI::Token::Operator::) && $next->{content} =~ /^(?:,|=|!|!=|==|=>)$/ # no ., because of digits. == float
139 or $prev->isa (PPI::Token::Operator::) && $prev->{content} =~ /^(?:,|=|\.|!|!=|==|=>)$/ 141 or $prev->isa (PPI::Token::Operator::) && $prev->{content} =~ /^(?:,|=|\.|!|!=|==|=>)$/
140 or $prev->isa (PPI::Token::Structure::) 142 or $prev->isa (PPI::Token::Structure::)
141 or ($self->{optimise_size} && 143 or ($self->{optimise_size} &&
142 ($prev->isa (PPI::Token::Word::) 144 ($prev->isa (PPI::Token::Word::)
144 || $next->isa (PPI::Structure::Block::) 146 || $next->isa (PPI::Structure::Block::)
145 || $next->isa (PPI::Structure::List::) 147 || $next->isa (PPI::Structure::List::)
146 || $next->isa (PPI::Structure::Condition::))) 148 || $next->isa (PPI::Structure::Condition::)))
147 ) 149 )
148 ) { 150 ) {
151 # perl has some idiotic warnigns about nonexisting operators
152 if ($prev->isa (PPI::Token::Operator::) && $prev->{content} eq "="
153 && $next->isa (PPI::Token::Operator::) && $next->{content} =~ /[+\-]/
154 ) {
155 # avoid "Reverse %s operator" diagnostic
156 } else {
149 $ws->delete; 157 $ws->delete;
150 } elsif ($prev->isa (PPI::Token::Whitespace::)) { 158 }
151 $ws->{content} = ' ';
152 $prev->delete;
153 } else { 159 } else {
154 $ws->{content} = ' '; 160 $ws->{content} = ' ';
155 } 161 }
156 } 162 }
157 } 163 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines