X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FLog.pm;h=d824d9a996d1b3fdce8fae13954fb28d7614e55c;hb=1fbaca61f2f551b5b2645ce2233a1d964bc93b30;hp=29559dd05f8bc378961f7516b500423c86f0527d;hpb=db93d66b63361ea75bd464d0d28cf779b90f19ee;p=debbugs.git diff --git a/Debbugs/Log.pm b/Debbugs/Log.pm index 29559dd..d824d9a 100644 --- a/Debbugs/Log.pm +++ b/Debbugs/Log.pm @@ -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: