From e58ab94734c18a940f324b1fbf599df06f91fbbd Mon Sep 17 00:00:00 2001 From: fukachan Date: Fri, 9 Nov 2001 15:09:03 +0000 Subject: check more by defined() --- fml/lib/Mail/ThreadTrack/Print.pm | 10 ++++++---- fml/lib/Mail/ThreadTrack/Print/Sort.pm | 22 ++++++++-------------- 2 files changed, 14 insertions(+), 18 deletions(-) (limited to 'fml/lib/Mail/ThreadTrack') diff --git a/fml/lib/Mail/ThreadTrack/Print.pm b/fml/lib/Mail/ThreadTrack/Print.pm index e4d2c808..777cc7de 100644 --- a/fml/lib/Mail/ThreadTrack/Print.pm +++ b/fml/lib/Mail/ThreadTrack/Print.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Print.pm,v 1.11 2001/11/09 11:30:30 fukachan Exp $ +# $FML: Print.pm,v 1.12 2001/11/09 12:08:45 fukachan Exp $ # package Mail::ThreadTrack::Print; @@ -138,7 +138,7 @@ sub _do_summary sub _print_thread_summary { - my ($self, $thread_id) = @_; + my ($self, $thread_id_list) = @_; my $mode = $self->get_mode || 'text'; my $rh_age = $self->{ _age } || {}; my $fd = $self->{ _fd } || \*STDOUT; @@ -146,12 +146,12 @@ sub _print_thread_summary my $format = "%10s %5s %8s %-20s %s\n"; if ($mode eq 'text') { - print $fd "\n"; printf($fd $format, 'date', 'age', 'status', 'thread id', 'articles'); print $fd "-" x60; print $fd "\n"; } else { + print $fd "
\n"; print "
action\n"; print "date\n"."age\n"."status\n"."thread id\n"; print "article summary\n"; @@ -159,7 +159,9 @@ sub _print_thread_summary my ($tid, @article_id, $article_id, $date, $age, $status) = (); my $dh = new Mail::Message::Date; - for $tid (@$thread_id) { + for $tid (@$thread_id_list) { + next unless defined $rh->{ _articles }->{ $tid }; + # get the first $article_id from the article_id list (@article_id) = split(/\s+/, $rh->{ _articles }->{ $tid }); $article_id = $article_id[0]; diff --git a/fml/lib/Mail/ThreadTrack/Print/Sort.pm b/fml/lib/Mail/ThreadTrack/Print/Sort.pm index 0b675206..a6ab1429 100644 --- a/fml/lib/Mail/ThreadTrack/Print/Sort.pm +++ b/fml/lib/Mail/ThreadTrack/Print/Sort.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Sort.pm,v 1.1 2001/11/09 11:28:42 fukachan Exp $ +# $FML: Sort.pm,v 1.2 2001/11/09 12:08:46 fukachan Exp $ # package Mail::ThreadTrack::Print::Sort; @@ -31,21 +31,13 @@ sub sort_thread_id $self->{ _age } = $age; $self->{ _cost } = $cost; - $self->_sort_thread_id($thread_id_list, $cost); -} - - -# Descriptions: -# Arguments: $self $args -# Side Effects: -# Return Value: none -sub _sort_thread_id -{ - my ($self, $thread_id_list, $cost) = @_; - @$thread_id_list = sort { - $cost->{$b} cmp $cost->{$a}; + (defined($cost->{$b}) ? $cost->{$b} : '') + cmp + (defined($cost->{$a}) ? $cost->{$a} : '') } @$thread_id_list; + + return $thread_id_list; } @@ -64,6 +56,8 @@ sub _calculate_age # $age hash referehence = { $thread_id => $age }; my (@aid, $last, $age, $date, $status, $tid) = (); for $tid (sort @$thread_id_list) { + next unless defined $rh->{ _articles }->{ $tid }; + # $last: get the latest one of article_id's (@aid) = split(/\s+/, $rh->{ _articles }->{ $tid }); $last = $aid[ $#aid ] || 0; -- cgit v1.2.1