]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Log.pm
Package member key is the fully-qualified name; fix error in get
[debbugs.git] / Debbugs / Log.pm
index 29559dd05f8bc378961f7516b500423c86f0527d..d824d9a996d1b3fdce8fae13954fb28d7614e55c 100644 (file)
@@ -203,17 +203,25 @@ sub new
     bless $self, $class;
 
     if (exists $param{logfh}) {
-        $self->{logfh} = $param{logfh}
-    }
-    elsif (exists $param{log_name}) {
-        $self->{logfh} = IO::File->new($param{log_name},'r') or
-             die "Unable to open bug log $param{log_name} for reading: $!";
-    }
-    elsif (exists $param{bug_num}) {
-        my $location = getbuglocation($param{bug_num},'log');
-        my $bug_log = getbugcomponent($param{bug_num},'log',$location);
-        $self->{logfh} = IO::File->new($bug_log, 'r') or
-             die "Unable to open bug log $bug_log for reading: $!";
+        $self->{logfh} = $param{logfh}
+    } else {
+       my $bug_log;
+       if (exists $param{bug_num}) {
+           my $location = getbuglocation($param{bug_num},'log');
+           $bug_log = getbugcomponent($param{bug_num},'log',$location);
+       } else {
+           $bug_log = $param{log_name};
+       }
+       if ($bug_log =~ m/\.gz$/) {
+           my $oldpath = $ENV{'PATH'};
+           $ENV{'PATH'} = '/bin:/usr/bin';
+           open($self->{logfh},'-|','gzip','-dc',$bug_log) or
+               die "Unable to open $bug_log for reading: $!";
+            $ENV{'PATH'} = $oldpath;
+       } else {
+            open($self->{logfh},'<',$bug_log) or
+                die "Unable to open $bug_log for reading: $!";
+       }
     }
 
     $self->{state} = 'kill-init';
@@ -241,6 +249,7 @@ sub read_record
     my $record = {};
 
     while (defined (my $line = <$logfh>)) {
+        $record->{start} = $logfh->tell() if not defined $record->{start};
        chomp $line;
        ++$this->{linenum};
        if (length($line) == 1 and exists $states{ord($line)}) {
@@ -504,7 +513,6 @@ sub record_regex {
     } else {
         my @result = $record->{text} =~ m/$regex/;
         return @result;
-        return $record->{text};
     }
 }
 
@@ -517,3 +525,8 @@ simply a means for extracting and rewriting raw records.
 =cut
 
 1;
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End: