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';
chomp;
s/BEGINNING OF LOG FOR//;
s/==*$//;
$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'} = 'time';
$result{'str'} = $_;
$pat = '^\s*$';
}
# Store strings until terminating pattern found.
# Special strings like "root#", "you%", and "me%" indicate
# commands where the entire line should be in bold.
# Preformatted output can drop some leading spaces.
my $emailhdr = 0; # Are we in a mail header?
while (<$fh>) {
last if /$pat/;
if (length() > $maxpre) {
warn "line $. too long:\n";
warn " [$_]\n";
}
$_ = prep($_);
# Emphasize typed commands.
if (/root#|you\%|me\%|me\$|^\s*\$ /) {
chomp;
s!^!