#!/usr/bin/perl -w
#
# p4_desc_2_html for Safari
# Copyright (c) 1999 by Barrie Slaymaker, rbs@telerama.com
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the README file.
#
use strict ;
my $up_to_project = $ENV{SAF_UP_TO_PROJECT} ;
die "\$ENV{SAF_UP_TO_PROJECT} not defined"
unless defined( $up_to_project ) ;
# Read in title line
my $line = <> ;
die "input error" unless defined $line ;
my ( $title, $author, $time ) =
$line =~ m/^(\S+\s+\S+)\s+by\s+(\S+)\s+on\s+(\S+\s+\S+)/ ;
my $change = $title ;
$change =~ s/^\w+\s+//g ;
my $project = $ENV{SAF_PROJECT} ;
$title = "$project, $title" if defined( $project ) && length( $project ) ;
#
# This is a hack that ignores the 'Jobs fixed...' section and any
# others that sneak in.
#
my @description = read_section( qr/^Affected files/i ) ;
my $description = join( "\n", @description ) ;
my @affected_files = map{
s/^\.\.\.\s+// ;
s!^/(/[^#]*)#!<A HREF="$up_to_project\@$change/Default$1">/$1</A>#! ;
$_ ;
} read_section( qr/^Differences/i ) ;
unshift(
@affected_files,
qq([ <A HREF="$up_to_project\@$change/Default/">Browse from top of project</A> ]),
"",
) ;
my $affected_files = join( "\n", @affected_files ) ;
my @differences = read_section() ;
my $differences = join( "\n", @differences ) ;
print <<TOHERE ;
<HTML>
<HEAD>
<TITLE>$title</TITLE>
</HEAD>
<BODY>
<TABLE>
<TR><TD><B>Author:</B></TD><TD>$author</TD></TR>
<TR><TD><B>Time:</B></TD><TD>$time</TD></TR>
<TR><TD COLSPAN="2"><B>Description:</B><BR>
<PRE>$description</PRE></TD></TR>
<TR><TD COLSPAN="2"><B>Affected Files:</B><BR>
<PRE>$affected_files</PRE></TD></TR>
<TR><TD COLSPAN="2"><B>Differences:</B><BR>
<PRE>$differences</PRE></TD></TR>
</TABLE>
</BODY>
</HTML>
TOHERE
sub read_section {
my $end_re = shift ;
my @output ;
while (<>) {
last if defined( $end_re ) && $_ =~ $end_re ;
next if ! @output && /^\s*$/ ;
chomp ;
s/</</g ;
s/>/>/g ;
s/^\t// ;
push( @output, $_ ) ;
}
pop @output
while( @output && $output[ -1 ] =~ /^\s*$/ ) ;
return @output ;
}
0 ;