--- theme.ph.orig Sat Feb 10 16:11:43 2001 +++ theme.ph Wed Feb 14 20:42:14 2001 @@ -137,8 +137,7 @@ &getFileList($diaryDir . "/" . $year); foreach $file (reverse @filelist) { - &readHnf($file); - &getNew(@hnfs); + &getNew($file); last LOOP if (scalar keys %NEW) >= 28; } @@ -179,11 +178,11 @@ sub readHnf ($) { my $hnf = $_[0]; - @hnfs = undef; my $ok = 0; my $err = 0; + @hnfs = (); - $hnf_ = $filedir{$hnf} . "/" . $hnf; + my $hnf_ = $filedir{$hnf} . "/" . $hnf; if ($NKF_USE) { open (HNF, "$NKF -emXZ1 $hnf_ |") || die "can't open hnf: $!"; while () { @@ -231,14 +230,41 @@ } -sub getNew (@) { - my @hnfs = @_; - my ($i, %TITLE, $linkHi, $link, $date); +sub getNew ($) { + my ($hnf) = @_; + my $hnf_ = $filedir{$hnf} . "/" . $hnf; + my ($i, %TITLE, $linkHi, $link, $date, $year, $cache, $hnf_lm); + local (*CACHE); - $date = $link = $linkHi = $file; + $year = $date = $link = $linkHi = $hnf; $link =~ s/d(\d{8}).hnf/$1/; $date =~ s/d(\d.*)(\d\d)(\d\d).hnf/$1$2$3/; + $year =~ s/d(\d.*)\d\d\d\d.hnf/$1/; $linkHi = $1 . $2 . $3; + $cache = sprintf("%s/%d/%s.side", $HNS::System::CacheDir, $year, $date); + + @{$NEW{$date}} = (); + + # cache checking + if ($HNS::System::Caching) { + # caching on + my $cache_lm = (stat($cache))[9]; + $hnf_lm = (stat($hnf_))[9]; + if (-e $cache && $hnf_lm == $cache_lm) { + open(CACHE, $cache); + while () { + chomp; + next if /^\s*$/; + push(@{$NEW{$date}}, $_); + } + close(CACHE); + return; + } else { + unlink $cache; + } + } + + &readHnf($hnf); $i = 0; # NEW counter $j = 0; # SUB counter @@ -357,6 +383,17 @@ # qq($new\n)) qq($new\n)) if $new; + + # write cache + if ($HNS::System::Caching) { + open(CACHE, ">$cache"); + for (@{$NEW{$date}}) { + print CACHE "$_"; + } + close(CACHE); + utime($hnf_lm, $hnf_lm, $cache); + } + } sub getTime () {