diff options
| author | fukachan <fukachan> | 2002-06-01 03:01:52 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2002-06-01 03:01:52 +0000 |
| commit | 79d8ab97822af34edc1985e33fb14f209c63676c (patch) | |
| tree | f77d76a4d1c1d929d6a36b79789d78a14ee9f0ec /fml | |
| parent | ceb2ec733ea4470f8056af2a305653dca4dc836f (diff) | |
| download | fml8-79d8ab97822af34edc1985e33fb14f209c63676c.tar.gz fml8-79d8ab97822af34edc1985e33fb14f209c63676c.tar.bz2 fml8-79d8ab97822af34edc1985e33fb14f209c63676c.zip | |
defined() overhaul
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/lib/FML/Article.pm | 5 | ||||
| -rw-r--r-- | fml/lib/FML/CGI/ThreadTrack.pm | 54 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Kernel.pm | 17 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Utils.pm | 8 | ||||
| -rw-r--r-- | fml/lib/IO/Adapter/File.pm | 10 | ||||
| -rw-r--r-- | fml/lib/IO/File/Atomic.pm | 39 | ||||
| -rw-r--r-- | fml/lib/Tie/JournaledFile.pm | 6 |
7 files changed, 83 insertions, 56 deletions
diff --git a/fml/lib/FML/Article.pm b/fml/lib/FML/Article.pm index a23c589b..05ad4bfd 100644 --- a/fml/lib/FML/Article.pm +++ b/fml/lib/FML/Article.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: Article.pm,v 1.38 2002/04/18 22:24:53 fukachan Exp $ +# $FML: Article.pm,v 1.39 2002/04/22 04:59:53 fukachan Exp $ # package FML::Article; @@ -170,11 +170,10 @@ sub spool_in my $file = $self->filepath($id); unless (-f $file) { - use FileHandle; my $fh = new FileHandle; - $fh->open($file, "w"); if (defined $fh) { + $fh->open($file, "w"); $curproc->{ article }->{ header }->print($fh); print $fh "\n"; $curproc->{ article }->{ body }->print($fh); diff --git a/fml/lib/FML/CGI/ThreadTrack.pm b/fml/lib/FML/CGI/ThreadTrack.pm index e0b8156a..50ac6238 100644 --- a/fml/lib/FML/CGI/ThreadTrack.pm +++ b/fml/lib/FML/CGI/ThreadTrack.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: ThreadTrack.pm,v 1.16 2002/03/20 03:17:47 fukachan Exp $ +# $FML: ThreadTrack.pm,v 1.17 2002/04/10 09:51:24 fukachan Exp $ # package FML::CGI::ThreadTrack; @@ -98,37 +98,43 @@ sub run_cgi_main use Mail::ThreadTrack; my $thread = new Mail::ThreadTrack $ttargs; - $thread->set_mode('html'); - if ($action eq 'list') { - $thread->summary(); - } - elsif ($action eq 'show') { - my $id = $curproc->safe_param_article_id(); - my $tid = $thread->_create_thread_id_strings($id); - $thread->show($tid); - } - elsif ($action eq 'change_status') { - # fmlthread.cgi is for administorator, so you can change status. - if ($myname eq 'fmlthread.cgi') { - my $list = $curproc->safe_paramlist2_threadcgi_change_status(); - for my $param (@$list) { - my ($ml, $id, $value) = @$param; - if ($value eq 'closed') { - my $tid = $thread->_create_thread_id_strings($id); - print "closed $tid", br, "\n"; - $thread->close($tid); + if (defined $thread) { + $thread->set_mode('html'); + + if ($action eq 'list') { + $thread->summary(); + } + elsif ($action eq 'show') { + my $id = $curproc->safe_param_article_id(); + my $tid = $thread->_create_thread_id_strings($id); + $thread->show($tid); + } + elsif ($action eq 'change_status') { + # fmlthread.cgi is for administorator, so you can change status. + if ($myname eq 'fmlthread.cgi') { + my $list = $curproc->safe_paramlist2_threadcgi_change_status(); + for my $param (@$list) { + my ($ml, $id, $value) = @$param; + if ($value eq 'closed') { + my $tid = $thread->_create_thread_id_strings($id); + print "closed $tid", br, "\n"; + $thread->close($tid); + } } } + else { + print "Warning: only administrator change status\n"; + } + + $thread->summary(); } else { - print "Warning: only administrator change status\n"; + $thread->summary(); } - - $thread->summary(); } else { - $thread->summary(); + croak("fail to create thread object"); } } diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm index 4a1532f9..31dfa1e3 100644 --- a/fml/lib/FML/Process/Kernel.pm +++ b/fml/lib/FML/Process/Kernel.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: Kernel.pm,v 1.101 2002/05/27 08:55:43 fukachan Exp $ +# $FML: Kernel.pm,v 1.102 2002/05/30 16:06:57 fukachan Exp $ # package FML::Process::Kernel; @@ -472,9 +472,11 @@ sub parse_incoming_message modulus => $modulus, }; - my $wh = $obj->open(); - $msg->print($wh); - $obj->close(); + if (defined $obj) { + my $wh = $obj->open(); + $msg->print($wh) if defined $wh; + $obj->close(); + } } } @@ -1279,7 +1281,12 @@ sub open_outgoing_message_channel modulus => $modulus, }; - return $obj->open(); + if (defined $obj) { + return $obj->open(); + } + else { + return undef; + } } return undef; diff --git a/fml/lib/FML/Process/Utils.pm b/fml/lib/FML/Process/Utils.pm index 6b41a6c6..e1c0798f 100644 --- a/fml/lib/FML/Process/Utils.pm +++ b/fml/lib/FML/Process/Utils.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: Utils.pm,v 1.21 2002/05/25 06:58:24 fukachan Exp $ +# $FML: Utils.pm,v 1.22 2002/05/27 08:45:41 fukachan Exp $ # package FML::Process::Utils; @@ -371,8 +371,10 @@ sub __ml_home_prefix_search_in_virtual_maps MAP: for my $map (@$virtual_maps) { my $obj = new IO::Adapter $map; - $obj->open(); - $dir = $obj->find("^$virtual_domain"); + if (defined $obj) { + $obj->open(); + $dir = $obj->find("^$virtual_domain"); + } last MAP if $dir; } ($virtual_domain, $dir) = split(/\s+/, $dir); diff --git a/fml/lib/IO/Adapter/File.pm b/fml/lib/IO/Adapter/File.pm index c9dc6f3c..f919bd14 100644 --- a/fml/lib/IO/Adapter/File.pm +++ b/fml/lib/IO/Adapter/File.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: File.pm,v 1.27 2001/12/24 07:44:35 fukachan Exp $ +# $FML: File.pm,v 1.28 2002/01/27 13:11:58 fukachan Exp $ # package IO::Adapter::File; @@ -156,8 +156,10 @@ sub touch use IO::File; my $fh = new IO::File; - $fh->open($file, "a"); - $fh->close; + if (defined $fh) { + $fh->open($file, "a"); + $fh->close; + } } @@ -344,7 +346,7 @@ sub add my $fh = $self->{ _fh }; my $wh = $self->{ _wh }; - if (defined $fh) { + if (defined $fh && defined $wh) { FILE_IO: while (<$fh>) { print $wh $_; diff --git a/fml/lib/IO/File/Atomic.pm b/fml/lib/IO/File/Atomic.pm index fae18401..fcf58f11 100644 --- a/fml/lib/IO/File/Atomic.pm +++ b/fml/lib/IO/File/Atomic.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: Atomic.pm,v 1.13 2002/02/02 08:04:54 fukachan Exp $ +# $FML: Atomic.pm,v 1.14 2002/04/08 12:44:27 fukachan Exp $ # package IO::File::Atomic; @@ -25,8 +25,10 @@ IO::File::Atomic - atomic IO operation use IO::File::Atomic; my $wh = IO::File::Atomic->open($file); - print $wh "new/updated things ..."; - $wh->close unless $wh->error; + if (defined $wh) { + print $wh "new/updated things ..."; + $wh->close unless $wh->error; + } In C<close()> runs, the C<$file> is replaced with the new content. Updating is defered until C<close()>. @@ -41,21 +43,25 @@ In usual cases, you use this module in the following way. # get handle to update $file my $wh = IO::File::Atomic->open($file); - while (<$rh>) { - print $wh "new/updated things ..."; + if (defined $rh && defined $wh) { + while (<$rh>) { + print $wh "new/updated things ..."; + } + $wh->close; + $rh->close; } - $wh->close; - $rh->close; You can use this method to open $file for both read and write. use IO::File::Atomic; my ($rh, $wh) = IO::File::Atomic->rw_open($file); - while (<$rh>) { - print $wh "new/updated things ..."; + if (defined $rh && defined $wh) { + while (<$rh>) { + print $wh "new/updated things ..."; + } + $wh->close; + $rh->close; } - $wh->close; - $rh->close; To copy from $src to $dst, @@ -84,10 +90,15 @@ The request is forwarded to SUPER CLASS's new(). # Return Value: OBJ sub new { - my ($self) = shift; + my ($self, @argv) = shift; my $me = $self->SUPER::new(); - $me->open(@_) if @_; - $me; + if (defined $me) { + $me->open(@argv) if defined @argv; + return $me; + } + elese { + return undef; + } } diff --git a/fml/lib/Tie/JournaledFile.pm b/fml/lib/Tie/JournaledFile.pm index 6ce9ac8a..7744f097 100644 --- a/fml/lib/Tie/JournaledFile.pm +++ b/fml/lib/Tie/JournaledFile.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: JournaledFile.pm,v 1.13 2002/02/01 12:04:04 fukachan Exp $ +# $FML: JournaledFile.pm,v 1.14 2002/02/02 08:04:55 fukachan Exp $ # package Tie::JournaledFile; @@ -327,9 +327,9 @@ sub _puts use IO::File; my $fh = new IO::File; - $fh->open($file, "a"); - if (defined $fh) { + $fh->open($file, "a"); + use Time::localtime; my $date = ctime(time); if (defined $string) { |
