Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rakudo/rakudo
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Jun 29, 2010
2 parents 6ea4d0c + 4e69c43 commit 451b409
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/core/IO/ArgFiles.pm
@@ -1,21 +1,20 @@
class IO::ArgFiles is IO {
has $!filenames;
has @!filenames;
has $!filename;
has $!current_file;
has $!ins;

method new($filenames) {
if $filenames.elems {
self.bless(*, :filenames($filenames));
} else {
push $filenames, "-";
self.bless(*, :filenames($filenames));
submethod BUILD {
if @*ARGS {
@!filenames = @*ARGS.eager;
} else {
@!filenames = '-';
}
}

method eof() {
$.next_file;
$!current_file.eof && $!filenames.elems == 0;
$!current_file.eof && !@!filenames.elems;
}

method getc() {
Expand Down Expand Up @@ -46,15 +45,15 @@ class IO::ArgFiles is IO {
method next_file() {
if (!defined $!current_file) || ($!current_file.eof) {
$!current_file.close if $!current_file && $!filename ne '-';
fail if $!filenames.elems == 0;
$!filename = $!filenames.shift;
fail if @!filenames.elems == 0;
$!filename = @!filenames.shift;
$!current_file = $!filename eq '-' ?? $*IN !! open($!filename);
}
}
}

sub ARGFILES_CREATE() {
IO::ArgFiles.new(@*ARGS);
IO::ArgFiles.new();
}

# vim: ft=perl6

0 comments on commit 451b409

Please sign in to comment.