[svn:parrot] r39603 - branches/cindent/t/codingstd
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Wed Jun 17 02:21:43 UTC 2009
Author: jkeenan
Date: Wed Jun 17 02:21:42 2009
New Revision: 39603
URL: https://trac.parrot.org/parrot/changeset/39603
Log:
Substitute named variable for $_.
Modified:
branches/cindent/t/codingstd/c_indent.t
Modified: branches/cindent/t/codingstd/c_indent.t
==============================================================================
--- branches/cindent/t/codingstd/c_indent.t Wed Jun 17 02:13:27 2009 (r39602)
+++ branches/cindent/t/codingstd/c_indent.t Wed Jun 17 02:21:42 2009 (r39603)
@@ -59,35 +59,39 @@
in_comment => 0,
);
- foreach (@source) {
+ foreach my $line (@source) {
$state{line_cnt}++;
- next unless defined $_;
- chomp;
+ next unless defined $line;
+ chomp $line;
$state{prev_last_char} = $state{last_char};
- $state{last_char} = substr( $_, -1, 1 );
+ $state{last_char} = substr( $line, -1, 1 );
# ignore multi-line comments (except the first line)
- $state{in_comment} = 0, next if $state{in_comment} && m{\*/} && $' !~ m{/\*};
+ $state{in_comment} = 0, next if $state{in_comment} &&
+ $line =~ m{\*/} &&
+ $' !~ m{/\*};
next if $state{in_comment};
- $state{in_comment} = 1 if m{/\*} && $' !~ m{\*/};
+ $state{in_comment} = 1
+ if $line =~ m{/\*} &&
+ $' !~ m{\*/};
## preprocessor scan
if (
- m/ ^ \s* \#
+ $line =~ m/ ^ \s* \#
(\s*)
( ifndef | ifdef | if )
\s+(.*)
/x
)
{
- next if (m/PARROT_IN_CORE|_GUARD/);
- next if (m/__cplusplus/);
+ next if ($line =~ m/PARROT_IN_CORE|_GUARD/);
+ next if ($line =~ m/__cplusplus/);
my $indent = q{ } x @{ $state{stack} };
if ( $1 ne $indent ) {
push @pp_indent => "$path:$state{line_cnt}\n"
- . " got: $_"
+ . " got: $line"
. "expected: #$indent$2 $3'\n";
$pp_failed{"$path\n"} = 1;
}
@@ -95,7 +99,7 @@
next;
}
if (
- m/ ^ \s* \#
+ $line =~ m/ ^ \s* \#
(\s*)
( else | elif )
/x
@@ -107,7 +111,7 @@
my $indent = q{ } x ( @{ $state{stack} } - 1 );
if ( $1 ne $indent ) {
push @pp_indent => "$path:$state{line_cnt}\n"
- . " got: $_"
+ . " got: $line"
. "expected: #$indent$2 -- it's inside of "
. ( join ' > ', @{ $state{stack} } ) . "\n";
$pp_failed{"$path\n"} = 1;
@@ -115,7 +119,7 @@
next;
}
if (
- m/ ^ \s* \#
+ $line =~ m/ ^ \s* \#
(\s*)
(endif)
/x
@@ -124,7 +128,7 @@
my $indent = q{ } x ( @{ $state{stack} } - 1 );
if ( $1 ne $indent ) {
push @pp_indent => "$path:$state{line_cnt}\n"
- . " got: $_"
+ . " got: $line"
. "expected: #$indent$2 -- it's inside of "
. ( join ' > ', @{ $state{stack} } ) . "\n";
$pp_failed{"$path\n"} = 1;
@@ -135,17 +139,17 @@
next unless @{ $state{stack} };
if (
- m/ ^ \s* \#
+ $line =~ m/ ^ \s* \#
(\s*)
(.*)
/x
)
{
- next if (m/ASSERT_ARGS_/); # autogenerated by headerizer
+ next if ($line =~ m/ASSERT_ARGS_/); # autogenerated by headerizer
my $indent = q{ } x (@{ $state{stack} });
if ( $1 ne $indent ) {
push @pp_indent => "$path:$state{line_cnt}\n"
- . " got: $_"
+ . " got: $line"
. "expected: #$indent$2 -- it's inside of "
. ( join ' > ', @{ $state{stack} } ) . "\n";
$pp_failed{"$path\n"} = 1;
@@ -158,14 +162,14 @@
# probably overkill for this task. For now we just check the
# first line of a function, and assume that more likely than not
# indenting is consistent within a func body.
- if (/^(\s*).*\{\s*$/) {
+ if ($line =~ /^(\s*).*\{\s*$/) {
# note the beginning of a block, and its indent depth.
$state{block_indent} = length($1);
next;
}
- if (/^\s*([\#\}])/) {
+ if ($line =~ /^\s*([\#\}])/) {
# skip the last line of the func or cpp directives.
$state{block_indent} = undef if ( $1 eq "}" );
@@ -179,7 +183,7 @@
# first line of a top-level block (first line of a function,
# in other words)
- my ($indent) = /^(\s*)/;
+ my ($indent) = $line =~ /^(\s*)/;
if ( length($indent) != 4 ) {
push @c_indent => "$path:$state{line_cnt}\n"
. " apparent non-4 space indenting ("
@@ -191,7 +195,7 @@
$state{block_indent} = undef;
}
- my ($indent) = /^(\s+)/ or next;
+ my ($indent) = $line =~ /^(\s+)/ or next;
$indent = length($indent);
# Ignore the indentation of the current line if that
@@ -200,7 +204,10 @@
# The indentation of the previous line is not considered.
# Check sanity by verifying that the indentation of the current line
# is divisible by four.
- if ( $indent % 4 && !$state{in_comment} && $state{prev_last_char} eq ';' ) {
+ if ( $indent % 4 &&
+ !$state{in_comment} &&
+ $state{prev_last_char} eq ';'
+ ) {
push @c_indent => "$path:$state{line_cnt}\n"
. " apparent non-4 space indenting ($indent space"
. ( $indent == 1 ? '' : 's' ) . ")\n";
More information about the parrot-commits
mailing list