# HG changeset patch # User kono # Date 1043476029 -32400 # Node ID 99bbcf06aac0738ba021f876247cb6ca74858cad # Parent d3e2e1d1a16c3fa16777b93aa09f38a9bb827aa0 *** empty log message *** diff -r d3e2e1d1a16c -r 99bbcf06aac0 Calcon.pm --- a/Calcon.pm Sat Jan 25 14:19:32 2003 +0900 +++ b/Calcon.pm Sat Jan 25 15:27:09 2003 +0900 @@ -67,13 +67,15 @@ bless $self, $class; # 入出力ファイル名 $self->{'-file'} = $file if ($file); -# $self->initialize(); + $self->initialize(); # this calls sub class' initializer. $self->option($opts); return $self; } -# 下位クラスから呼び出される初期化。ここでは何もしない。しかし、 -# 呼び出されるのだから用意しておく必要がある。 +# 下位クラスから呼び出される初期化。ここでは何もしない。 +# new で呼ばれたinitilize は、段階的に SUPER::initilalize を呼び出す。 +# 最終的に、基底クラスである Calcon::Basic (Calcon そのものであるべき?) +# の initialize を呼び出す。呼び出されるのだから用意しておく必要がある。 sub initialize { my ($self) = @_; @@ -708,7 +710,8 @@ return if ($self->{'-count'} == 0); $self->{'-count'} --; $date = $date->date(); - my $memo = $items->{'memo'}; + my $memo =''; + $memo = $items->{'memo'} if (defined($items->{'memo'})); $memo =~ s/\n+$//; if ($self->{'-tomorrow'}) { print nkf('-e',"$date:\t$memo\n"); @@ -1700,30 +1703,35 @@ my($self,$id,$vid,$phone,$record) = @_; my ($street , $zip , $state , $country , $city); + $street = $zip = $state = $country = $city = ''; my $address = RunAppleScript("${tell}properties of ${phone} $vid of person $id\nend tell\n"); # {zip:missing value, label:"住所", state:missing value, street:"那覇市久茂地3-21-1", country code:missing value, country:missing value, id:"AFBD61FE-FB17-11D6-A84E-0003936AC938", city:missing value, class:address} - $address =~ s/^\"//; $address =~ s/\"$//; $address =~ s/\001.*$//; + $address =~ s/^\"//; $address =~ s/\"$//; + $address =~ s/\001.*$//; + $address =~ s/\002.*?"/"/; $address = nkf('-eS',$address); # my ($street , $zip , $state , $country , $city); $address =~ /street:"([^"]*)"/ && ($street = $1); - $zip =~ /zip:"([^"]*)"/ && ($zip = $1); - $state =~ /state:"([^"]*)"/ && ($state = $1); - $city =~ /city:"([^"]*)"/ && ($city = $1); - $country =~ /country:"([^"]*)"/ && ($country = $1); + $address =~ /zip:"([^"]*)"/ && ($zip = $1); + $address =~ /state:"([^"]*)"/ && ($state = $1); + $address =~ /city:"([^"]*)"/ && ($city = $1); + $address =~ /country:"([^"]*)"/ && ($country = $1); my ($label) = ($address =~ /label:"(.*?)"/); if (! defined($self->{'-labels'}->{$phone.$label})) { print "## $phone$label not defined\n"; - } - $record->{$self->{'-labels'}->{$phone.$label}} = "$state $city $street $country" - if ($state||$city||$street||$country); - if ($zip && $self->{'-labels'}->{$phone.$label} =~ /home/) { - $record->{'home-zip'} = $zip; } else { - $record->{'zip'} = $zip if ($zip); + $record->{$self->{'-labels'}->{$phone.$label}} = + "$state $city $street $country" + if ($state||$city||$street||$country); + if ($zip && $self->{'-labels'}->{$phone.$label} =~ /home/) { + $record->{'home-zip'} = $zip; + } else { + $record->{'zip'} = $zip if ($zip); + } } } @@ -1735,8 +1743,9 @@ my ($value,$label) = ($result =~ /value:"(.*?)".*label:"(.*?)"/); if (! defined($self->{'-labels'}->{$phone.$label})) { print "## $phone$label not defined\n"; + } else { + $record->{$self->{'-labels'}->{$phone.$label}} = $value; } - $record->{$self->{'-labels'}->{$phone.$label}} = $value; } @@ -2597,7 +2606,7 @@ s/^[^\s]*\s*//; } } - if ($record->{'type'} =~ /Allday/i) { + if (defined($record->{'type'}) && $record->{'type'} =~ /Allday/i) { undef $record->{'end-date'}; @$keys = grep(!/^end-date/,@$keys); } @@ -2637,7 +2646,6 @@ my ($self) = @_; my $count = $self->{'-date-max'}; - # open(CAL,"|nkf --utf8 >datebook.xml") or croak($!); open(CAL,">datebook.xml") or croak($!); $self->print ( "\n"); $self->print ( "\n"); @@ -2784,7 +2792,7 @@ sub print { my ($self,@data) = @_; - print CAL nkf("--utf8 -Z3",@data); + print CAL nkf("-w -Z3",@data); } #######################################################################/ @@ -2870,7 +2878,8 @@ $record{'date'}=$record{'date'}->add($self->{'-time-for-allday'}); } my $dtstart = "\nDTSTART;TZID=$timezone:".$self->date($record{'date'}); - my ($dtend,$dtstamp); + my $dtend = ''; + my $dtstamp = ''; if (! defined( $record{'end-date'}) || $record{'end-date'} == $record{'date'} ) { # $dtend = "\nDURATION:PT2H"; this is useless for iCal @@ -2884,8 +2893,8 @@ $dtstamp = "\nDTSTAMP;TZID=$timezone:".$self->date($record{'modify-date'}); } - my $summary; - my $description; + my $summary = ''; + my $description = ''; if (defined($record{'memo'})) { $summary = $record{'memo'}; $summary =~ s/[\r\n].*$//; $description = $&; @@ -2920,10 +2929,10 @@ sub date { my ($self,$date) = @_; - my ($year,$month,$day,$hour,$min,$sec) = $self->localtime($date); + my ($year,$month,$day,$hour,$min) = $self->localtime($date); $date = sprintf("%04d%02d%02dT%02d%02d%02d", - $year,$month,$day,$hour,$min,$sec); + $year,$month,$day,$hour,$min,0); return $date; } diff -r d3e2e1d1a16c -r 99bbcf06aac0 Changes --- a/Changes Sat Jan 25 14:19:32 2003 +0900 +++ b/Changes Sat Jan 25 15:27:09 2003 +0900 @@ -1,5 +1,12 @@ Revision history for Perl extension Calcon. +Sat Jan 25 15:25:12 JST 2003 + +warning はうるさい。でも、結構落したけど。実行時にしか捕まえられない +warning はいやだなぁ。 + +なんと、基底クラスのinitialize を落していた。こまったものだ。 + 0.01 Fri Jan 24 13:35:34 2003 - original version; created by h2xs 1.22 with options -AX -n Calcon