Skip to content
Browse files

Use indirekt file handles.

Use three-argument open.


git-svn-id: https://svn.parrot.org/parrot/trunk@11788 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent dd8dc05 commit 69e07c01d346d5a969cbe5486a73e5a8e24bdabd @bschmalhofer bschmalhofer committed Mar 4, 2006
View
7 docs/submissions.pod
@@ -160,10 +160,11 @@ The list of these ignore files can be set up with:
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
View
13 lib/Parrot/BuildUtil.pm
@@ -38,21 +38,19 @@ sub parrot_version
}
# 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 @@ sub parrot_version
$#parrot_version = 3;
}
$parrot_version = join('.', @parrot_version);
+
return wantarray ? @parrot_version : $parrot_version;
}
View
2 lib/Parrot/Configure.pm
@@ -1,4 +1,4 @@
-# Copyright: 2001-2005 The Perl Foundation. All Rights Reserved.
+# Copyright: 2001-2006 The Perl Foundation. All Rights Reserved.
# $Id$
=pod
View
15 lib/Parrot/Configure/Step.pm
@@ -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 @@ not included in the checksum.
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 @@ sub genfile
{
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 @@ sub genfile
# 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 @@ sub _slurp
{
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: $!";
View
32 lib/Parrot/OpsFile.pm
@@ -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 @@ parentheses and add a space around the argument, like so:
=cut
-use strict;
-
package Parrot::OpsFile;
+use strict;
+use warnings;
+
use Parrot::Op;
use Parrot::Config;
@@ -164,13 +165,11 @@ BEGIN {
@EXPORT = qw(%op_body);
};
-#
-# trim()
+# private sub _trim()
#
# Trim leading and trailing spaces.
-#
-sub trim
+sub _trim
{
my $value = shift;
@@ -219,19 +218,19 @@ Reads in the specified .ops file, gathering information about the ops.
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 @@ sub read_ops
my $flags;
my @labels;
- while (<OPS>)
+ while (<$OPS>)
{
$seen_pod = 1 if m|^=|;
@@ -329,8 +328,8 @@ sub read_ops
$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 @@ sub read_ops
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 @@ sub push_op
=cut
1;
-
-
-
View
13 lib/Parrot/Pmc2c/Library.pm
@@ -59,21 +59,20 @@ sub new {
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()>
View
8 lib/Parrot/Revision.pm
@@ -19,8 +19,10 @@ Get parrot's current and configure time revision.
=cut
package Parrot::Revision;
+
use strict;
-use 5.006;
+use warnings;
+use 5.008;
our $svn_entries = undef;
@@ -30,8 +32,8 @@ sub __get_revision {
# 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;
}
View
20 lib/Parrot/Test.pm
@@ -305,11 +305,10 @@ sub per_test {
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 @@ sub _generate_functions {
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 @@ sub _generate_functions {
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};

0 comments on commit 69e07c0

Please sign in to comment.
Something went wrong with that request. Please try again.