$section
Top
Next
Prev
End
|
EndLeft
1;
}
#---------------------------------------------------------------------
# Right field is the log entry.
sub startentry
{
print <<"StartRight";
StartRight
1;
}
sub endentry
{
print <<"EndRight";
|
EndRight
1;
}
# -------------------------------------------------------------------------
# Read file in chunks.
sub getchunk
{
my $fh = shift;
my %result = ();
# No more records.
return (%result) if eof($fh);
# Skip leading blank lines.
my $pat = '^\s*$';
while (<$fh>) {
last unless /$pat/;
}
# We've found a complete timestamp, or at least part of the
# associated comment. A chunk can be either a paragraph
# from the comment, or a complete piece of preformatted text.
if (/^BEGIN/) {
$result{'type'} = 'begin';
if (/BEGINNING OF LOG FOR (.*) ==+/) {
$result{'str'} = $1;
} else {
$result{'str'} = $_;
}
$pat = '^\s*$';
}
elsif (/^\s+--+S$/) {
$result{'type'} = 'pre';
$result{'str'} = ''; # don't keep this string.
$pat = '^\s+--+E$';
}
elsif (/^\s/) {
$result{'type'} = 'entry';
$result{'str'} = $_;
$pat = '^\s*$';
}
else {
$result{'type'} = 'section';
$result{'str'} = $_;
$pat = '^\s*$';
}
# Store strings until terminating pattern found.
# Special strings like "root#" and "me%" indicate commands
# where the entire line should be in bold.
# Preformatted output can drop some leading spaces.
while (<$fh>) {
last if /$pat/;
$_ = prep ($_);
if (/\sroot#|\sme\%|\sme\$|^\s+\$ /) {
chomp;
s!^!