]> git.donarmstrong.com Git - bugscan.git/blobdiff - scanlib.pm
return $bugs and use $bugs in scandir
[bugscan.git] / scanlib.pm
index 7cd2e63386c39cb3fa2abebef87f3391e0439c08..cc32b457839033ece9f22cf3b14cbfa72355d09b 100644 (file)
@@ -20,6 +20,8 @@ use Debbugs::Packages;
 use Debbugs::Versions;
 use Debbugs::Status;
 use Fcntl qw(O_RDONLY);
+use IO::File;
+use IO::Dir;
 
 use File::Basename;
 use lib dirname(__FILE__);
@@ -140,24 +142,22 @@ sub scanspool() {
 }
 
 sub scanspooldir {
-       my ($dir)               = @_;
-       my $f;                  # While we're currently processing
-       my @list;               # List of files to process
+       my ($dir,$bugs) = @_;
        my $skip;               # Flow control
        my $walk;               # index variable
        my $taginfo;    # Tag info
                                        
        my @archs_with_source = ( @bugcfg::architectures, 'source' );
 
-       chdir($dir) or die "chdir $dir: $!\n";
+#      chdir($dir) or die "chdir $dir: $!\n";
 
-       opendir(DIR, $dir) or die "opendir $dir: $!\n";
-       @list = grep { s/\.summary$// }
-                       grep { m/^\d+\.summary$/ } 
-                       readdir(DIR);
-       closedir(DIR);
+       my $d = IO::Dir->new($dir) or die "Unable to opendir: $dir $!\n";
+       my @list = grep { s/\.summary$// }
+        grep { m/^\d+\.summary$/ }
+        $d->read;
+       $d->close;
 
-       for $f (@list) {
+       for my $f (@list) {
                my $bug = Debbugs::Status::read_bug(summary => "$f.summary");
                next if (!defined($bug));
                
@@ -249,8 +249,9 @@ sub scanspooldir {
                my $taginfo = get_taginfo($bi);
                my $relinfo = get_relinfo($bi);
 
-               $bugs{$f} = $bi;
+               $bugs->{$f} = $bi;
        }
+    return $bugs;
 }
 
 
@@ -260,7 +261,9 @@ sub readstatus {
                or die "$filename: $!";
 
     while (1) {
-               chomp (my $type = <STATUS>);
+               my $type = <STATUS>;
+        last if not defined $type;
+        chomp $type;
                if ($type eq 'package') {
                        chomp (my $package = <STATUS>);
                        chomp (my $section = <STATUS>);