summaryrefslogtreecommitdiffstats
path: root/perl_checker.src
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-11-26 11:59:49 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-11-26 11:59:49 +0000
commit88bbe9c072d449c7ec86998b88df34144fa54474 (patch)
tree967731f0dd7bee53f17adb2afeb1cfae1ad166d5 /perl_checker.src
parent4e5b51f313c38d7018170710c5779adea50d14a7 (diff)
downloadperl-MDK-Common-88bbe9c072d449c7ec86998b88df34144fa54474.tar
perl-MDK-Common-88bbe9c072d449c7ec86998b88df34144fa54474.tar.gz
perl-MDK-Common-88bbe9c072d449c7ec86998b88df34144fa54474.tar.bz2
perl-MDK-Common-88bbe9c072d449c7ec86998b88df34144fa54474.tar.xz
perl-MDK-Common-88bbe9c072d449c7ec86998b88df34144fa54474.zip
warn about blocks ending with a ";"
Diffstat (limited to 'perl_checker.src')
-rw-r--r--perl_checker.src/parser.mly3
-rwxr-xr-xperl_checker.src/test/test_it6
2 files changed, 6 insertions, 3 deletions
diff --git a/perl_checker.src/parser.mly b/perl_checker.src/parser.mly
index e3ae85b..22c7454 100644
--- a/perl_checker.src/parser.mly
+++ b/perl_checker.src/parser.mly
@@ -114,8 +114,7 @@ line:
| PERL_CHECKER_COMMENT {sp_p($1); new_1esp [Perl_checker_comment($1.any, get_pos $1)] $1 }
| semi_colon {warn_rule [Warn_white_space] "unneeded \";\""; new_1esp [Semi_colon] $1 }
| sideff semi_colon {new_1esp [$1.any ; Semi_colon] $1 }
-| BRACKET lines BRACKET_END {new_esp $2.mcontext [lines_to_Block $2 $3] $1 $3}
-| BRACKET lines BRACKET_END semi_colon {new_esp $2.mcontext [lines_to_Block $2 $3] $1 $4}
+| BRACKET lines BRACKET_END {new_esp $2.mcontext [lines_to_Block $2 $3] $1 $3}
if_then_else: /* Real conditional expressions */
| IF PAREN expr PAREN_END BRACKET lines BRACKET_END elsif else_ {sp_p($1); sp_n($2); sp_0($3); sp_0_or_cr($4); sp_p($5); mcontext_check M_bool $3; to_Call_op (if $9.any = [] then M_none else mcontext_lmerge ($6.mcontext :: mcontext_lmaybe $8 @ [$9.mcontext])) "if" (prio_lo P_loose $3 :: lines_to_Block $6 $7 :: $8.any @ $9.any) $1 $9}
diff --git a/perl_checker.src/test/test_it b/perl_checker.src/test/test_it
index fc2e70f..2f7c599 100755
--- a/perl_checker.src/test/test_it
+++ b/perl_checker.src/test/test_it
@@ -65,7 +65,11 @@ foreach my $test (@tests) {
if ($l[-1] !~ /(;|[\s{]\})\s+$/) {
$l[-1] =~ s/^(.*?)(\s+$)/xxx($1);$2/;
} else {
- my $no_comma = $l[-1] =~ /(^\s*(for|foreach|if|unless|while|sub)\s)|(;\s+$)/;
+ # no comma for:
+ # - prefix for/foreach/...
+ # - already a comma
+ # - a block { ... }
+ my $no_comma = $l[-1] =~ /(^\s*(for|foreach|if|unless|while|sub)\s)|(;\s+$)|(^{.*}\s*$)/;
my $opt_comma = $no_comma ? '' : ';';
$l[-1] =~ s/(\s+$)/$opt_comma nop();$1/;
}