[svn:parrot] r39604 - branches/cindent/t/codingstd
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Wed Jun 17 02:43:38 UTC 2009
Author: jkeenan
Date: Wed Jun 17 02:43:38 2009
New Revision: 39604
URL: https://trac.parrot.org/parrot/changeset/39604
Log:
Explicitly assign all regex captures.
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:21:42 2009 (r39603)
+++ branches/cindent/t/codingstd/c_indent.t Wed Jun 17 02:43:38 2009 (r39604)
@@ -77,59 +77,46 @@
$' !~ m{\*/};
## preprocessor scan
- if (
- $line =~ m/ ^ \s* \#
- (\s*)
- ( ifndef | ifdef | if )
- \s+(.*)
- /x
- )
+ if ( $line =~ m/^\s*\#(\s*)(ifndef|ifdef|if)\s+(.*)/ )
{
+ my ($prespace, $condition, $postspace) = ($1,$2,$3);
next if ($line =~ m/PARROT_IN_CORE|_GUARD/);
next if ($line =~ m/__cplusplus/);
my $indent = q{ } x @{ $state{stack} };
- if ( $1 ne $indent ) {
+ if ( $prespace ne $indent ) {
push @pp_indent => "$path:$state{line_cnt}\n"
. " got: $line"
- . "expected: #$indent$2 $3'\n";
+ . "expected: #$indent$condition $postspace'\n";
$pp_failed{"$path\n"} = 1;
}
- push @{ $state{stack} }, "#$2 $3";
+ push @{ $state{stack} }, "#$condition $postspace";
next;
}
- if (
- $line =~ m/ ^ \s* \#
- (\s*)
- ( else | elif )
- /x
- )
+ if ( $line =~ m/^\s*\#(\s*)(else|elif)/)
{
+ my ($prespace, $condition) = ($1,$2);
# stay where we are, but indenting should be
# back even with the opening brace.
my $indent = q{ } x ( @{ $state{stack} } - 1 );
- if ( $1 ne $indent ) {
+ if ( $prespace ne $indent ) {
push @pp_indent => "$path:$state{line_cnt}\n"
. " got: $line"
- . "expected: #$indent$2 -- it's inside of "
+ . "expected: #$indent$condition -- it's inside of "
. ( join ' > ', @{ $state{stack} } ) . "\n";
$pp_failed{"$path\n"} = 1;
}
next;
}
- if (
- $line =~ m/ ^ \s* \#
- (\s*)
- (endif)
- /x
- )
+ if ( $line =~ m/^\s*\#(\s*)(endif)/)
{
+ my ($prespace, $condition) = ($1,$2);
my $indent = q{ } x ( @{ $state{stack} } - 1 );
- if ( $1 ne $indent ) {
+ if ( $prespace ne $indent ) {
push @pp_indent => "$path:$state{line_cnt}\n"
. " got: $line"
- . "expected: #$indent$2 -- it's inside of "
+ . "expected: #$indent$condition -- it's inside of "
. ( join ' > ', @{ $state{stack} } ) . "\n";
$pp_failed{"$path\n"} = 1;
}
@@ -138,19 +125,15 @@
}
next unless @{ $state{stack} };
- if (
- $line =~ m/ ^ \s* \#
- (\s*)
- (.*)
- /x
- )
+ if ( $line =~ m/^\s*\#(\s*)(.*)/)
{
+ my ($prespace, $condition) = ($1,$2);
next if ($line =~ m/ASSERT_ARGS_/); # autogenerated by headerizer
my $indent = q{ } x (@{ $state{stack} });
- if ( $1 ne $indent ) {
+ if ( $prespace ne $indent ) {
push @pp_indent => "$path:$state{line_cnt}\n"
. " got: $line"
- . "expected: #$indent$2 -- it's inside of "
+ . "expected: #$indent$condition -- it's inside of "
. ( join ' > ', @{ $state{stack} } ) . "\n";
$pp_failed{"$path\n"} = 1;
}
@@ -164,15 +147,17 @@
# indenting is consistent within a func body.
if ($line =~ /^(\s*).*\{\s*$/) {
+ my $prespace = $1;
# note the beginning of a block, and its indent depth.
- $state{block_indent} = length($1);
+ $state{block_indent} = length($prespace);
next;
}
if ($line =~ /^\s*([\#\}])/) {
+ my $closing_punc = $1;
# skip the last line of the func or cpp directives.
- $state{block_indent} = undef if ( $1 eq "}" );
+ $state{block_indent} = undef if ( $closing_punc eq "}" );
next;
}
More information about the parrot-commits
mailing list