Author: bernhard
Date: Sat Mar  4 08:22:21 2006
New Revision: 11788

Modified:
   trunk/docs/submissions.pod
   trunk/lib/Parrot/BuildUtil.pm
   trunk/lib/Parrot/Configure.pm
   trunk/lib/Parrot/Configure/Step.pm
   trunk/lib/Parrot/OpsFile.pm
   trunk/lib/Parrot/Pmc2c/Library.pm
   trunk/lib/Parrot/Revision.pm
   trunk/lib/Parrot/Test.pm

Log:
Use indirekt file handles.
Use three-argument open.


Modified: trunk/docs/submissions.pod
==============================================================================
--- trunk/docs/submissions.pod  (original)
+++ trunk/docs/submissions.pod  Sat Mar  4 08:22:21 2006
@@ -160,10 +160,11 @@
 
     svn propedit svn:ignore <PATH>
 
-In order to keep the two different checks synchronized, the MANIFEST.SKIP file
-should be regenerated with:
+In order to keep the two different checks synchronized, 
+the MANIFEST and MANIFEST.SKIP file should be regenerated with:
+
+    perl tools/dev/mk_manifest_and_skip.pl
 
-    perl tools/dev/gen_manifest_skip.pl > MANIFEST.SKIP
 
 =head1 How To Submit Something New
 

Modified: trunk/lib/Parrot/BuildUtil.pm
==============================================================================
--- trunk/lib/Parrot/BuildUtil.pm       (original)
+++ trunk/lib/Parrot/BuildUtil.pm       Sat Mar  4 08:22:21 2006
@@ -38,21 +38,19 @@
     }
 
     # Obtain the official version number from the VERSION file.
-    open VERSION, "<VERSION" or die "Could not open VERSION file!";
-    $parrot_version = <VERSION>;
-    close VERSION;
+    open my $VERSION, '<', 'VERSION' or die "Could not open VERSION file!";
+    $parrot_version = <$VERSION>;
+    close $VERSION;
 
     chomp $parrot_version;
     $parrot_version =~ s/\s+//g;
     @parrot_version = split(/\./, $parrot_version);
 
-    if ( scalar(@parrot_version) < 3 )
-    {
+    if ( scalar(@parrot_version) < 3 ) {
         die "Too few components to VERSION file contents: '$parrot_version' 
(should be 3 or 4)!"
     }
 
-    if ( scalar(@parrot_version) > 4 )
-    {
+    if ( scalar(@parrot_version) > 4 ) {
         die "Too many components to VERSION file contents: '$parrot_version' 
(should be 3 or 4)!"
     }
 
@@ -65,6 +63,7 @@
         $#parrot_version = 3;
     }
     $parrot_version = join('.', @parrot_version);
+
     return wantarray ? @parrot_version : $parrot_version;
 }
 

Modified: trunk/lib/Parrot/Configure.pm
==============================================================================
--- trunk/lib/Parrot/Configure.pm       (original)
+++ trunk/lib/Parrot/Configure.pm       Sat Mar  4 08:22:21 2006
@@ -1,4 +1,4 @@
-# Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
+# Copyright: 2001-2006 The Perl Foundation.  All Rights Reserved.
 # $Id$
 
 =pod

Modified: trunk/lib/Parrot/Configure/Step.pm
==============================================================================
--- trunk/lib/Parrot/Configure/Step.pm  (original)
+++ trunk/lib/Parrot/Configure/Step.pm  Sat Mar  4 08:22:21 2006
@@ -1,4 +1,4 @@
-# Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
+# Copyright: 2001-2006 The Perl Foundation.  All Rights Reserved.
 # $Id$
 
 =head1 NAME
@@ -110,7 +110,7 @@
 sub file_checksum
 {
     my ($filename, $ignorePattern) = @_;
-    open(my $file, "< $filename") or die "Can't open $filename: $!";
+    open(my $file, '<', $filename) or die "Can't open $filename: $!";
     my $sum = 0;
     while (<$file>) {
         next if defined($ignorePattern) && /$ignorePattern/;
@@ -176,11 +176,9 @@
 {
     my ($source, $target, %options) = @_;
 
-    open(my $in, "< $source") or die "Can't open $source: $!";
+    open my $in, '<', $source or die "Can't open $source: $!";
 
-    # don't change the name of the outfile handle
-    # feature.pl / feature_h.in need OUT
-    open(my $out, "> $target.tmp") or die "Can't open $target.tmp: $!";
+    open my $out, '>', "$target.tmp" or die "Can't open $target.tmp: $!";
 
     if ($options{commentType}) {
         my @comment = (
@@ -211,9 +209,10 @@
         # everything after the line starting with #perl is eval'ed
         if ($line =~ /^#perl/ && $options{feature_file}) {
             # OUT was/is used at the output filehandle in eval'ed scripts
+            # e.g. feature.pl or feature_h.in 
             local *OUT = $out;
             my $text = do {local $/; <$in>};
-           # interoplate @foo@ values
+            # interoplate @foo@ values
             $text =~ s{ \@ (\w+) \@ }{\$conf->data->get("$1")}gx;
             eval $text;
             die $@ if $@;
@@ -508,7 +507,7 @@
 {
     my $filename = shift;
 
-    open(my $fh, $filename) or die "Can't open $filename: $!";
+    open(my $fh, '<', $filename) or die "Can't open $filename: $!";
     my $text = do {local $/; <$fh>};
     close($fh) or die "Can't close $filename: $!";
 

Modified: trunk/lib/Parrot/OpsFile.pm
==============================================================================
--- trunk/lib/Parrot/OpsFile.pm (original)
+++ trunk/lib/Parrot/OpsFile.pm Sat Mar  4 08:22:21 2006
@@ -1,5 +1,5 @@
 #! perl -w
-# Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
+# Copyright: 2001-2006 The Perl Foundation.  All Rights Reserved.
 # $Id$
 
 =head1 NAME
@@ -150,10 +150,11 @@
 
 =cut
 
-use strict;
-
 package Parrot::OpsFile;
 
+use strict;
+use warnings;
+
 use Parrot::Op;
 use Parrot::Config;
 
@@ -164,13 +165,11 @@
     @EXPORT = qw(%op_body);
 };
 
-#
-# trim()
+# private sub  _trim()
 #
 # Trim leading and trailing spaces.
-#
 
-sub trim
+sub _trim
 {
     my $value = shift;
 
@@ -219,19 +218,19 @@
 sub read_ops
 {
     my ($self, $file, $nolines) = @_;
+
     my $ops_file = "src/" . $file;
 
-    open OPS, $file or die "Could not open ops file '$file' ($!)!";
 
     die "Parrot::OpFunc::init(): No file specified!\n" unless defined $file;
 
-    $self->{FILE} .= $file.', ';
+    $self->{FILE} .= $file . ', ';
 
     my $orig = $file;
 
-    open OPS, $file or die "Can't open $file, $!/$^E";
+    open my $OPS, '<', $file or die "Can't open $file, $!/$^E";
 
-    if (! ($file =~ s/\.ops$/.c/))
+    if ( ! ($file =~ s/\.ops$/.c/) )
     {
         $file .= ".c";
     }
@@ -254,7 +253,7 @@
     my $flags;
     my @labels;
 
-    while (<OPS>)
+    while (<$OPS>)
     {
         $seen_pod = 1 if m|^=|;
 
@@ -329,8 +328,8 @@
 
             $type       = defined($1) ? 'inline' : 'function';
             $short_name = $2;
-            $args       = trim(lc $3);
-            $flags      = $4 ? trim(lc $4) : "";
+            $args       = _trim(lc $3);
+            $flags      = $4 ? _trim(lc $4) : "";
             @args       = split(/\s*,\s*/, $args);
             @argdirs    = ();
             @labels     = ();
@@ -439,7 +438,7 @@
         die "Parrot::OpsFile: File ended with incomplete op definition!\n";
     }
 
-    close OPS or die "Could not close ops file '$file' ($!)!";
+    close $OPS or die "Could not close ops file '$file' ($!)!";
 
     return;
 }
@@ -800,6 +799,3 @@
 =cut
 
 1;
-
-
-

Modified: trunk/lib/Parrot/Pmc2c/Library.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c/Library.pm   (original)
+++ trunk/lib/Parrot/Pmc2c/Library.pm   Sat Mar  4 08:22:21 2006
@@ -59,21 +59,20 @@
 sub _write_a_file($$$) {
     my ($generator, $h_name, $c_name) = @_;
     my $opt = $generator->{opt};
-    local (*H, *C);
 
     print Data::Dumper->Dump([$generator]) if $opt->{debug} > 1;
     my $cout = $generator->gen_c($c_name);
     print $cout if $opt->{debug};
     print "Writing $c_name\n" if $opt->{verbose};
-    open C, ">$c_name" or die "Can't write '$c_name";
-    print C $cout;
-    close C;
+    open my $C, '>', $c_name or die "Can't write '$c_name";
+    print $C $cout;
+    close $C;
     my $hout = $generator->gen_h($h_name);
     print $hout if $opt->{debug};
     print "Writing $h_name\n" if $opt->{verbose};
-    open H, ">$h_name" or die "Can't write '$h_name";
-    print H $hout;
-    close H;
+    open my $H, '>', $h_name or die "Can't write '$h_name";
+    print $H $hout;
+    close $H;
 }
 
 =item C<write_all_files()>

Modified: trunk/lib/Parrot/Revision.pm
==============================================================================
--- trunk/lib/Parrot/Revision.pm        (original)
+++ trunk/lib/Parrot/Revision.pm        Sat Mar  4 08:22:21 2006
@@ -19,8 +19,10 @@
 =cut
 
 package Parrot::Revision;
+
 use strict;
-use 5.006;
+use warnings;
+use 5.008;
 
 our $svn_entries = undef;
 
@@ -30,8 +32,8 @@
 
     # code taken from pugs/util/version_h.pl rev 859
     if (-r $svn_entries) {
-        open FH, $svn_entries or die $!;
-        while (<FH>) {
+        open my $FH, '<', $svn_entries or die $!;
+        while (<$FH>) {
             /^ *committed-rev=.(\d+)./ or next;
             return $1;
         }

Modified: trunk/lib/Parrot/Test.pm
==============================================================================
--- trunk/lib/Parrot/Test.pm    (original)
+++ trunk/lib/Parrot/Test.pm    Sat Mar  4 08:22:21 2006
@@ -305,11 +305,10 @@
 sub generate_code {
     my ($code, $directory, $test_no, $code_f) = @_;
 
-    local( *CODE );
-    open(CODE, "> $code_f") or die "Unable to open '$code_f'";
-    binmode(CODE);
-    print CODE $code;
-    close( CODE );
+    open my $CODE, '>', $code_f or die "Unable to open '$code_f'";
+    binmode $CODE;
+    print $CODE $code;
+    close $CODE;
 
     return;
 }
@@ -560,7 +559,6 @@
             my $test_no = $builder->current_test() + 1;
 
             $expected =~ s/\cM\cJ/\n/g;
-            local( *SOURCE );
             my $source_f = per_test('.c', $test_no);
             my $obj_f = per_test($PConfig{o}, $test_no);
             my $exe_f = per_test($PConfig{exe}, $test_no);
@@ -570,11 +568,11 @@
             my $pdb_f = per_test('.pdb', $test_no);
             my $ilk_f = per_test('.ilk', $test_no);
 
-            open SOURCE, "> $source_f" or die "Unable to open '$source_f'";
-            binmode SOURCE;
-            print SOURCE "/* DO NOT EDIT - Autogenerated test file */\n";
-            print SOURCE $source;
-            close SOURCE;
+            open my $SOURCE, '>', $source_f or die "Unable to open 
'$source_f'";
+            binmode $SOURCE;
+            print $SOURCE "/* DO NOT EDIT - Autogenerated test file */\n";
+            print $SOURCE $source;
+            close $SOURCE;
 
             my $libparrot_shared = "$PConfig{rpath_blib} -L$PConfig{blib_dir} 
-lparrot";
             my $libparrot_static  = 
$PConfig{blib_dir}.$PConfig{slash}.$PConfig{libparrot_static};

Reply via email to