1 package ChangeLogReader
;
3 #use vars qw(@ISA @EXPORT $VERSION $OLD_CODE);
6 #@EXPORT = qw(store_changelog store_entry store_entry2 debug_print);
13 for (keys %param) { $self->{lc($_)} = $param{$_} }
14 return bless $self, $class;
19 foreach my $ymd (reverse sort keys %{$self->{all
}}) {
20 my $ent = $self->{all
}->{$ymd};
22 print "ENTRY ID: $ymd\n";
23 print "message-top:",$ent->{'message-top'},"\n"
24 if (defined $ent->{'message-top'});
25 print "message-bottom:",$ent->{'message-bottom'},"\n"
26 if (defined $ent->{'message-bottom'});
27 for (my $i = $ent->{curid
}; $i >= 1; $i--) {
29 print "ITEM ID: $ymd-$i\n";
30 print "ITEM HEADER:>>>>",$ent->{$i}->{ho
},"<<<<\n";
31 print "ITEM CATEGORY:",join(",",@
{$ent->{$i}->{cat
}}),"\n"
32 if (defined $ent->{$i}->{cat
});
33 print "ITEM AUTHOR:>>>>",$ent->{$i}->{a
},"<<<<\n";
34 print "ITEM CONTENT:>>>>",$ent->{$i}->{co
},"<<<<\n";
40 sub store_changelog_file
{
41 my ($self, $fname) = @_;
43 open(F
, $fname) || die "file open error $fname : $!";
47 if (/^(\d{4}-\d\d-\d\d)/) {
48 $self->store_entry(\
@entlines) if (@entlines > 0);
50 } elsif (/^\t?__DATA__.*$/) {
52 } elsif (/^\s*Local Variables:/) { # emacs stuff at the end
57 $self->store_entry(\
@entlines) if (@entlines > 0);
63 my ($self, $linesp) = @_;
65 # Processing entry header
66 my $eh = shift @
$linesp;
68 return unless ($eh =~ /^\d{4}-\d\d-\d\d/);
70 my ($ymd, $y, $m, $d, $user)
71 = ($eh =~ /^((\d\d\d\d)-(\d\d)-(\d\d))(?:.*?\s\s)(.+)?/);
73 $self->{all
}->{$ymd}->{eh
} = $ymd;
74 my $entp = $self->{all
}->{$ymd};
78 # print "($ymd, $y, $m, $d, $user) \n";
79 # print "<<<<<$eh>>>>>>>\n";
81 # Processing each item
85 if (s/^( {8}| {0,7}\t|)\* //) {
86 push @items, [@ilines] if (@ilines > 0 and $ilines[0] !~ /^\s*$/);
91 push @items, [@ilines] if (@ilines > 0 and $ilines[0] !~ /^\s*$/);
93 foreach (reverse @items) {
94 $self->store_item($entp, $_, $ymd, $user);
97 if ($entp->{curid
} == 0) {
98 # If the entry doesn't have any item, delete it.
99 # It will be happend when all items in the entry are private items.
100 # Notice: pragma items are ignored.
101 delete $self->{all
}->{$ymd};
105 my $ent = $self->{all
}->{$ymd};
106 for (my $i = $ent->{curid
}; $i >= 1; $i--) {
107 if (defined $ent->{$i}->{cat
}) {
108 map {$self->{CAT
}->{$_}++} @
{$ent->{$i}->{cat
}};
112 $self->{STAT
}->{ym
}{$y."-".$m}++; # for month_page_list
113 $self->{STAT
}->{md
}{$m."-".$d}{$y} = 1; # for SameDateJump
114 # {"ym"} : ³Æǯ·î¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ëÆüÉÕ¥¨¥ó¥È¥ê¿ô
115 # {"md"} : Ʊ¤¸·îÆü¤ò»ý¤Äǯ for same date jump
117 if ($self->{stop_date
} != 0) {
118 my $cdate = $y * 10000 + $m * 100 + $d;
119 if ($self->{stop_date
} > $cdate) {
120 delete $self->{all
}->{$ymd};
126 # ʸ»ú¥³¡¼¥É¤ò euc ¤Ë¤·¤Æ¤ª¤¯???????
128 my ($self, $entp, $linesp, $ymd, $user) = @_;
129 # $entp = $self->{all}->{$ymd};
131 my $ih = shift @
$linesp;
132 # item header - case 1: "* AAA: \n"
133 # item header - case 2: "* AAA:\n"
134 # item header - case 3: "* AAA: BBB\n"
135 # item header - case 4: "* AAA\n"
136 my ($rest) = ($ih =~ s/:(\s.*)$/:/s) ?
$1 : ""; # for case 1,2,3
138 my $cont = $rest.join("", @
$linesp);
139 if ($ih =~ /^p:/) { # Ignoring private items
141 } elsif ($ih =~ /^(message-top|message-bottom):/) { # pragma items
142 $entp->{$1} = $rest.$cont;
146 # item ID : Y in XXXX-XX-XX-Y
149 # Processing item header
150 # # If 1st line doesn't have ": ", it will become item header.
152 # $ih =~ s/(:|\s+)$//g;
153 $ih =~ s/(:|\s*)$//sg; # Triming trailing spaces and ":"
154 # print "[[[[$ih]]]\n";
155 if ($ih =~ s/\s*\[(.+)\]$//) { # category
156 @cat = split(/\s*\]\s*\[\s*/, $1);
159 # Processing item content
160 $cont =~ s/^( {8}| {0,7}\t)//gsm;
161 $cont =~ s/\s+$/\n/g; # Triming trailing spaces and CR
164 # Storing item information in hash
165 $entp->{$entp->{curid
}}{ho
} = $ih;
166 $entp->{$entp->{curid
}}{co
} = $cont;
167 $entp->{$entp->{curid
}}{a
} = $user if (defined $user);
168 @
{$entp->{$entp->{curid
}}{cat
}} = @cat if (@cat > 0);
170 # print "<<<<<$ih>>>>>>>\n";