[svn:parrot] r45143 - trunk/lib/Parrot

petdance at svn.parrot.org petdance at svn.parrot.org
Wed Mar 24 01:24:41 UTC 2010


Author: petdance
Date: Wed Mar 24 01:24:41 2010
New Revision: 45143
URL: https://trac.parrot.org/parrot/changeset/45143

Log:
fixed some regex quotes. Removed unused var @directives. Throw in some explicit returns.

Modified:
   trunk/lib/Parrot/H2inc.pm

Modified: trunk/lib/Parrot/H2inc.pm
==============================================================================
--- trunk/lib/Parrot/H2inc.pm	Wed Mar 24 01:23:40 2010	(r45142)
+++ trunk/lib/Parrot/H2inc.pm	Wed Mar 24 01:24:41 2010	(r45143)
@@ -44,17 +44,17 @@
 
 sub parse_file {
     my ( $in_file, $out_file) = @_;
-    $out_file =~ s/\\/\//g; # transform Windows backslash
+    $out_file =~ s{\\}{/}g; # transform Windows backslash
 
-    my ( @directives, %values, $last_val, $cur, $or_continues );
+    my ( %values, $last_val, $cur, $or_continues );
     open my $fh, '<', $in_file or die "Can't open $in_file: $!\n";
     while ( my $line = <$fh> ) {
         if (
-            $line =~ m!
+            $line =~ m{
             &gen_from_(enum|def) \( ( [^)]* ) \)
             (?: \s+ prefix \( (\w+) \) )?
             (?: \s+ subst \( (s/.*?/.*?/[eig]?) \) )?
-            !x
+            }x
             )
         {
             $cur and die "Missing '&end_gen' in $in_file\n";
@@ -131,7 +131,7 @@
                 $values{$k} = $last_val = $v;
                 push @{ $cur->{defs} }, [ $k, $v ];
             }
-            elsif ( $line =~ m!^\s*(\w+)\s*(?:,\s*)?(?:/\*|$)! ) {
+            elsif ( $line =~ m{^\s*(\w+)\s*(?:,\s*)?(?:/\*|$)} ) {
                 my $k = $1;
                 my $v = $values{$k} = ++$last_val;
                 push @{ $cur->{defs} }, [ $k, $v ];
@@ -196,7 +196,7 @@
     my $keylen = (sort { $a <=> $b } map { length($_->[0]) } @_ )[-1] ;
     my $vallen = (sort { $a <=> $b } map { length($_->[1]) } @_ )[-1] ;
 
-    map {sprintf ".macro_const %-${keylen}s %${vallen}s", $_->[0], $_->[1]} @_;
+    return map {sprintf ".macro_const %-${keylen}s %${vallen}s", $_->[0], $_->[1]} @_;
 }
 
 =head2 C<const_to_perl()>
@@ -221,7 +221,7 @@
 
     my $keylen = (sort { $a <=> $b } map { length($_->[0]) } @_ )[-1] ;
 
-    map {sprintf "use constant %-${keylen}s => %s;", $_->[0], $_->[1]} @_;
+    return map {sprintf "use constant %-${keylen}s => %s;", $_->[0], $_->[1]} @_;
 }
 
 =head2 C<transform_name()>
@@ -271,7 +271,7 @@
 sub prepend_prefix {
     my $prefix = shift;
 
-    transform_name( sub { $prefix . $_[0] }, @_ );
+    return transform_name( sub { $prefix . $_[0] }, @_ );
 }
 
 =head2 C<generate_text()>
@@ -335,7 +335,7 @@
 sub print_generated_file {
     my $args = shift;
     open my $out_fh, '>', $args->{out} or die "Can't open $args->{out}: $!\n";
-    print $out_fh <<"EOF";
+    print {$out_fh} <<"EOF";
 # DO NOT EDIT THIS FILE.
 #
 # This file is generated automatically from
@@ -346,6 +346,8 @@
 $args->{gen}
 EOF
     close $out_fh;
+
+    return;
 }
 
 1;


More information about the parrot-commits mailing list