summaryrefslogtreecommitdiff
path: root/fml/lib/Mail/Message
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-12-22 03:09:56 +0000
committerfukachan <fukachan>2002-12-22 03:09:56 +0000
commitca12ba7373d99c92f2ca6dc1585b3028bbd05c29 (patch)
tree3e151ed09943062107c75f320d4714449dc2eaea /fml/lib/Mail/Message
parent9b0d28906c98372ca271f501ea435f2d418f2a5f (diff)
downloadfml8-ca12ba7373d99c92f2ca6dc1585b3028bbd05c29.tar.gz
fml8-ca12ba7373d99c92f2ca6dc1585b3028bbd05c29.tar.bz2
fml8-ca12ba7373d99c92f2ca6dc1585b3028bbd05c29.zip
FNF-ify. fix comments.
cosmetics.
Diffstat (limited to 'fml/lib/Mail/Message')
-rw-r--r--fml/lib/Mail/Message/Checksum.pm6
-rw-r--r--fml/lib/Mail/Message/Date.pm30
-rw-r--r--fml/lib/Mail/Message/Encode.pm93
-rw-r--r--fml/lib/Mail/Message/Language/Japanese/Subject.pm10
4 files changed, 114 insertions, 25 deletions
diff --git a/fml/lib/Mail/Message/Checksum.pm b/fml/lib/Mail/Message/Checksum.pm
index 16c710f2..4dfb1852 100644
--- a/fml/lib/Mail/Message/Checksum.pm
+++ b/fml/lib/Mail/Message/Checksum.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: Checksum.pm,v 1.4 2002/09/11 23:18:25 fukachan Exp $
+# $FML: Checksum.pm,v 1.5 2002/09/22 14:57:03 fukachan Exp $
#
package Mail::Message::Checksum;
@@ -70,6 +70,7 @@ sub _init
$self->{ _type } = 'native';
}
else {
+ # XXX-TODO: hmm, we should remove search_program() dependence?
eval qq{ require File::Utils; import File::Utils qw(search_program);};
my $prog = search_program('md5') || search_program('md5sum');
if (defined $prog) {
@@ -79,7 +80,6 @@ sub _init
}
-
=head2 C<md5(\$string)>
return the md5 checksum of the given string C<$string>.
@@ -212,7 +212,7 @@ sub cksum2
Log("ERROR: no such file $file");
}
- ($crc, $total);
+ return ($crc, $total);
}
diff --git a/fml/lib/Mail/Message/Date.pm b/fml/lib/Mail/Message/Date.pm
index 64b9e238..b48677ab 100644
--- a/fml/lib/Mail/Message/Date.pm
+++ b/fml/lib/Mail/Message/Date.pm
@@ -2,7 +2,7 @@
#
# Copyright (C) 2000,2001,2002 Ken'ichi Fukamachi
#
-# $FML: Date.pm,v 1.13 2002/09/11 23:18:25 fukachan Exp $
+# $FML: Date.pm,v 1.14 2002/09/22 14:57:03 fukachan Exp $
#
package Mail::Message::Date;
@@ -73,7 +73,7 @@ sub new
# Descriptions: prepare date by several time format
-# Arguments: OBJ($self) HASH_REF($args)
+# Arguments: NUM($time)
# Side Effects: create object
# Return Value: HASH_REF
sub _date
@@ -88,6 +88,7 @@ sub _date
my @Month = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
+ # XXX-TODO: default timezone is +0900. o.k. ? :-)
$TimeZone ||= '+0900';
my ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime($time))[0..6];
@@ -127,7 +128,7 @@ sub log_file_style
{
my ($self, $time) = @_;
my $p = _date($time || time);
- $p->{'log_file_style'};
+ return $p->{'log_file_style'};
}
@@ -139,7 +140,7 @@ sub mail_header_style
{
my ($self, $time) = @_;
my $p = _date($time || time);
- $p->{'mail_header_style'};
+ return $p->{'mail_header_style'};
}
@@ -151,7 +152,7 @@ sub YYYYMMDD
{
my ($self, $time) = @_;
my $p = _date($time || time);
- $p->{'YYYYMMDD'};
+ return $p->{'YYYYMMDD'};
}
@@ -165,7 +166,7 @@ sub YYYYxMMxDD
my $date = _date($time || time);
$sep ||= '/'; # 1999/09/13 by default
- $date->{ YYYY }. $sep . $date->{ MM }. $sep. $date->{ DD };
+ return $date->{ YYYY }. $sep . $date->{ MM }. $sep. $date->{ DD };
}
@@ -177,7 +178,7 @@ sub current_time
{
my ($self, $time) = @_;
my $p = _date($time || time);
- $p->{'current_time'};
+ return $p->{'current_time'};
}
@@ -189,7 +190,7 @@ sub precise_current_time
{
my ($self, $time) = @_;
my $p = _date($time || time);
- $p->{'precise_current_time'};
+ return $p->{'precise_current_time'};
}
@@ -226,7 +227,7 @@ sub stardate
$integer = $integer % 10000;
- sprintf("[%d]%04d.%02.2s", $issue, $integer, $fraction);
+ return sprintf("[%d]%04d.%02.2s", $issue, $integer, $fraction);
}
@@ -290,6 +291,9 @@ sub date_to_unixtime
my (%month);
my ($zone);
+ # XXX-TODO: method-ify date_to_unixtime() ?
+ # XXX-TODO: more documents
+
$in =~ s/[\s\n]*$//;
require 'timelocal.pl';
@@ -338,7 +342,10 @@ sub date_to_unixtime
}
elsif ($in =~
/(\d+)\s+(\w+)\s+(\d+)\s+(\d+):(\d+)\s+([\+\-])(\d\d)(\d\d)/) {
- if ($debug_mti) { print STDERR "Date2UnixTime: Standard without \$sec\n";}
+ if ($debug_mti) {
+ print STDERR "Date2UnixTime: Standard without \$sec\n";
+ }
+
$day = $1;
$month = ($month{$2} || $month) - 1;
$year = $3 > 1900 ? $3 - 1900 : $3;
@@ -403,7 +410,8 @@ sub date_to_unixtime
my $t;
eval('$t = &timegm($sec,$min,$hour,$day,$month,$year) + $shift*3600');
_log($@) if $@;
- $t;
+
+ return $t;
}
diff --git a/fml/lib/Mail/Message/Encode.pm b/fml/lib/Mail/Message/Encode.pm
index 9f8e1742..39c11970 100644
--- a/fml/lib/Mail/Message/Encode.pm
+++ b/fml/lib/Mail/Message/Encode.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: Encode.pm,v 1.8 2002/09/22 15:01:23 fukachan Exp $
+# $FML: Encode.pm,v 1.9 2002/11/26 13:55:46 fukachan Exp $
#
package Mail::Message::Encode;
@@ -24,6 +24,8 @@ Mail::Message::Encode - encode/decode/charset conversion routines
=head2 C<new()>
+standard constructor.
+
=cut
@@ -53,7 +55,17 @@ sub new
}
-# Descriptions: speculate code of $str
+=head2 C<detect_code($str)>
+
+speculate the code of $str string.
+$str is checked by Unicode::Japanese.
+
+C<CAUTION>: we handle only Japanese.
+
+=cut
+
+
+# Descriptions: speculate code of $str string.
# Arguments: OBJ($self) STR($str)
# Side Effects: none
# Return Value: STR
@@ -62,7 +74,7 @@ sub detect_code
my ($self, $str) = @_;
my $lang = $self->{ _language };
- # code by default
+ # XXX-TODO: care for non Japanese.
if ($lang eq 'japanese') {
use Unicode::Japanese;
my $obj = new Unicode::Japanese;
@@ -90,6 +102,19 @@ sub detect_code
# utf8 UTF8
+=head2 convert($str, $out_code, $in_code)
+
+convert $str to $out_code code.
+$in_code is used as a hint.
+
+=head2 convert_str_ref($str_ref, $out_code, $in_code)
+
+convert string reference $str_str to $out_code code.
+$in_code is used as a hint.
+
+=cut
+
+
# Descriptions: convert $str to $out_code code
# Arguments: OBJ($self) STR($str) STR($out_code) STR($in_code)
# Side Effects: none
@@ -115,6 +140,7 @@ sub convert_str_ref
croak("convert_str_ref: invalid input data");
}
+ # XXX-TODO: care for non Japanese.
if ($lang eq 'japanese') {
# 1. if the encoding for the given $str_ref is unknown, return ASAP.
unless (defined $in_code) {
@@ -169,7 +195,23 @@ sub _jp_str_ref
}
-# Descriptions: run $proc($s) after $s is converted to $out_code code
+=head2 run_in_code($proc, $s, $args, $out_code, $in_code)
+
+run $proc($s) under $out_code environment.
+So, execute $proc like this.
+
+ my $obj = new Mail::Message::Encode;
+ my $conv_status = $obj->convert_str_ref($s, $out_code, $in_code);
+
+ &$proc($s, $args);
+
+It means run $proc() after $s is converted to $out_code code.
+
+=cut
+
+
+# Descriptions: run $proc($s) under $out_code environment.
+# It means run $proc() after $s is converted to $out_code code.
# Arguments: OBJ($self) CODE_REF($proc) STR($s) HASH_REF($args)
# STR($out_code) STR($in_code)
# Side Effects: none
@@ -181,6 +223,8 @@ sub run_in_code
my $obj = new Mail::Message::Encode;
my $conv_status = $obj->convert_str_ref($s, $out_code, $in_code);
+
+ # XXX-TODO: validate $proc name regexp.
eval q{
$proc_status = &$proc($s, $args);
};
@@ -195,6 +239,10 @@ sub run_in_code
=head1 utilities
+=head2 is_iso2022jp_string($buf)
+
+$buf looks like Japanese or not ?
+
=cut
@@ -251,6 +299,18 @@ sub _look_not_iso2022jp_string
=head1 BACKWARD COMPATIBILITY
+=head2 STR2EUC($str)
+
+convert $str to japanese EUC code.
+
+=head2 STR2JIS($str)
+
+convert $str to japanese JIS code.
+
+=head2 STR2SJIS($str)
+
+convert $str to japanese SJIS code.
+
=cut
@@ -292,6 +352,11 @@ sub STR2JIS
=head1 MIME ENCODE
+=head2 encode_mime_string($str, $encode, $out_code, $in_code)
+
+encode string $str to encoding system $encode with output code $out_code.
+$in_code is used as a hint.
+
=cut
@@ -340,6 +405,19 @@ sub encode_mime_string
}
+=head2 base64($str, $out_code, $in_code)
+
+encode $str by base64 with out code out_code.
+$in_code is use as a hint.
+
+=head2 qp($str, $out_code, $in_code)
+
+encode $str by quoted-printable with out code out_code.
+$in_code is use as a hint.
+
+=cut
+
+
# Descriptions: encode $str by base64
# Arguments: OBJ($self) STR($str) STR($out_code) STR($in_code)
# Side Effects: none
@@ -400,6 +478,9 @@ sub decode_mime_string
}
+#
+# debug
+#
if ($0 eq __FILE__) {
$| = 1;
@@ -453,10 +534,6 @@ if ($0 eq __FILE__) {
See C<http://www.fml.org/software/FNF/> on fml coding style guide.
-=head1 CODING STYLE
-
-See C<http://www.fml.org/software/FNF/> on fml coding style guide.
-
=head1 AUTHOR
Ken'ichi Fukamachi
diff --git a/fml/lib/Mail/Message/Language/Japanese/Subject.pm b/fml/lib/Mail/Message/Language/Japanese/Subject.pm
index a684a412..644b94e0 100644
--- a/fml/lib/Mail/Message/Language/Japanese/Subject.pm
+++ b/fml/lib/Mail/Message/Language/Japanese/Subject.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: Subject.pm,v 1.9 2002/09/11 23:18:28 fukachan Exp $
+# $FML: Subject.pm,v 1.10 2002/09/22 14:57:05 fukachan Exp $
#
@@ -36,8 +36,8 @@ in the subject.
=cut
-# XXX we should it in proper way in the future.
-# XXX but we import it anyway for further rewriting.
+# XXX-TODO: we should it in proper way in the future.
+# XXX-TODO: but we import it anyway for further rewriting.
my $CUT_OFF_RERERE_PATTERN = '';
my $CUT_OFF_RERERE_HOOK = '';
@@ -71,7 +71,9 @@ For example, it is like this:
sub is_reply
{
my ($self, $x) = @_;
+
return 0 unless $x;
+
&Jcode::convert(\$x, 'euc');
return ($x =~ /^((\s|(กก))*($pattern)\s*)+/ ? 1 : 0);
}
@@ -111,6 +113,8 @@ sub cut_off_reply_tag
my ($subject) = @_;
my ($y, $limit);
+ # XXX-TODO: method-ify ?
+
Jcode::convert(\$subject, 'euc');
if ($CUT_OFF_RERERE_PATTERN) {