1999-10-19 02:55:01 +04:00
|
|
|
#!/usr/bonsaitools/bin/perl -w
|
1998-06-17 01:43:24 +04:00
|
|
|
# cvsblame.cgi -- cvsblame with logs as popups and allowing html in comments.
|
|
|
|
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# The contents of this file are subject to the Netscape Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/NPL/
|
1998-06-17 01:43:24 +04:00
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
1998-06-17 01:43:24 +04:00
|
|
|
#
|
|
|
|
# The Original Code is the Bonsai CVS tool.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
1999-11-02 02:33:56 +03:00
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s):
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
|
|
|
|
# Created: Steve Lamm <slamm@netscape.com>, 12-Sep-97.
|
|
|
|
# Modified: Marc Byrd <byrd@netscape.com> , 19971030.
|
|
|
|
#
|
|
|
|
# Arguments (passed via GET or POST):
|
|
|
|
# file - path to file name (e.g. ns/cmd/xfe/Makefile)
|
|
|
|
# root - cvs root (e.g. /warp/webroot)
|
|
|
|
# - default includes /m/src/ and /h/rodan/cvs/repository/1.0
|
|
|
|
# rev - revision (default is the latest version)
|
|
|
|
# line_nums - boolean for line numbers on/off (use 1,0).
|
|
|
|
# (1,on by default)
|
|
|
|
# use_html - boolean for html comments on/off (use 1,0).
|
|
|
|
# (0,off by default)
|
|
|
|
# sanitize - path to sanitization dictionary
|
|
|
|
# (e.g. /warp2/webdoc/projects/bonsai/dictionary/sanitization.db)
|
|
|
|
# mark - highlight a line
|
|
|
|
#
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
use diagnostics;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
# Shut up misguided -w warnings about "used only once". "use vars" just
|
|
|
|
# doesn't work for me.
|
|
|
|
|
|
|
|
sub sillyness {
|
|
|
|
my $zz;
|
|
|
|
$zz = $::progname;
|
|
|
|
$zz = $::revision_ctime;
|
|
|
|
$zz = $::revision_log;
|
|
|
|
}
|
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
require 'CGI.pl';
|
1998-06-17 01:43:24 +04:00
|
|
|
require 'cvsblame.pl';
|
|
|
|
use SourceChecker;
|
|
|
|
|
|
|
|
# Cope with the cookie and print the header, first thing. That way, if
|
|
|
|
# any errors result, they will show up for the user.
|
|
|
|
|
|
|
|
print "Content-Type:text/html\n";
|
1999-11-04 02:37:44 +03:00
|
|
|
if ($ENV{REQUEST_METHOD} eq 'POST' and defined $::FORM{set_line}) {
|
1998-06-17 01:43:24 +04:00
|
|
|
# Expire the cookie 5 months from now
|
1999-11-04 02:37:44 +03:00
|
|
|
print "Set-Cookie: line_nums=$::FORM{set_line}; expires="
|
1998-06-17 01:43:24 +04:00
|
|
|
. toGMTString(time + 86400 * 152) . "; path=/\n";
|
1999-11-04 02:37:44 +03:00
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
print "\n";
|
|
|
|
|
|
|
|
|
|
|
|
# Some Globals
|
|
|
|
#
|
1999-10-19 02:55:01 +04:00
|
|
|
my $Head = 'CVS Blame';
|
|
|
|
my $SubHead = '';
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my @src_roots = getRepositoryList();
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Init sanitiazation source checker
|
|
|
|
#
|
1999-11-04 02:37:44 +03:00
|
|
|
my $sanitization_dictionary = $::FORM{sanitize};
|
1999-10-19 02:55:01 +04:00
|
|
|
my $opt_sanitize = defined $sanitization_dictionary;
|
1998-06-17 01:43:24 +04:00
|
|
|
if ( $opt_sanitize )
|
|
|
|
{
|
|
|
|
dbmopen %SourceChecker::token_dictionary, "$sanitization_dictionary", 0664;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Init byrd's 'feature' to allow html in comments
|
|
|
|
#
|
1999-10-19 02:55:01 +04:00
|
|
|
my $opt_html_comments = &html_comments_init();
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
|
|
|
|
# Handle the "file" argument
|
|
|
|
#
|
1999-10-19 02:55:01 +04:00
|
|
|
my $filename = '';
|
1999-11-04 02:37:44 +03:00
|
|
|
$filename = $::FORM{file} if defined $::FORM{file};
|
1998-06-17 01:43:24 +04:00
|
|
|
if ($filename eq '')
|
|
|
|
{
|
|
|
|
&print_usage;
|
|
|
|
exit;
|
|
|
|
}
|
1999-10-19 02:55:01 +04:00
|
|
|
my ($file_head, $file_tail) = $filename =~ m@(.*/)?(.+)@;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Handle the "rev" argument
|
|
|
|
#
|
1999-10-19 02:55:01 +04:00
|
|
|
$::opt_rev = '';
|
1999-11-04 02:37:44 +03:00
|
|
|
$::opt_rev = $::FORM{rev} if defined $::FORM{rev} and $::FORM{rev} ne 'HEAD';
|
|
|
|
my $browse_revtag = 'HEAD';
|
1999-10-19 02:55:01 +04:00
|
|
|
$browse_revtag = $::opt_rev if ($::opt_rev =~ /[A-Za-z]/);
|
|
|
|
my $revision = '';
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Handle the "root" argument
|
|
|
|
#
|
1999-11-04 02:37:44 +03:00
|
|
|
my $root = $::FORM{root};
|
|
|
|
if (defined $root and $root ne '') {
|
1998-06-17 01:43:24 +04:00
|
|
|
$root =~ s|/$||;
|
|
|
|
validateRepository($root);
|
|
|
|
if (-d $root) {
|
|
|
|
unshift(@src_roots, $root);
|
|
|
|
} else {
|
|
|
|
&print_top;
|
|
|
|
print "Error: Root, $root, is not a directory.<BR><BR>\n";
|
|
|
|
print "</BODY></HTML>\n";
|
|
|
|
&print_bottom;
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Find the rcs file
|
|
|
|
#
|
1999-10-19 02:55:01 +04:00
|
|
|
my $rcs_filename;
|
1999-11-04 02:37:44 +03:00
|
|
|
my $found_rcs_file = 0;
|
1998-06-17 01:43:24 +04:00
|
|
|
foreach (@src_roots) {
|
|
|
|
$root = $_;
|
|
|
|
$rcs_filename = "$root/$filename,v";
|
1999-07-23 22:39:31 +04:00
|
|
|
$rcs_filename = Fix_BonsaiLink($rcs_filename);
|
1999-11-04 02:37:44 +03:00
|
|
|
$found_rcs_file = 1, last if -r $rcs_filename;
|
1998-06-17 01:43:24 +04:00
|
|
|
$rcs_filename = "$root/${file_head}Attic/$file_tail,v";
|
1999-11-04 02:37:44 +03:00
|
|
|
$found_rcs_file = 1, last if -r $rcs_filename;
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
1999-11-04 02:37:44 +03:00
|
|
|
unless ($found_rcs_file) {
|
|
|
|
&print_top;
|
|
|
|
print "Rcs file, $filename, doeHs not exist.<pre>rcs_filename => '$rcs_filename'\nroot => '$root'</pre><BR><BR>\n";
|
|
|
|
print "</BODY></HTML>\n";
|
|
|
|
&print_bottom;
|
|
|
|
exit;
|
|
|
|
}
|
1998-06-18 20:47:00 +04:00
|
|
|
|
1999-11-04 02:37:44 +03:00
|
|
|
my $rcs_path;
|
|
|
|
($rcs_path) = $rcs_filename =~ m@$root/(.*)/.+?,v@;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1998-06-18 20:47:00 +04:00
|
|
|
CheckHidden($rcs_filename);
|
|
|
|
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
# Parse the rcs file ($::opt_rev is passed as a global)
|
1998-06-17 01:43:24 +04:00
|
|
|
#
|
|
|
|
$revision = &parse_cvs_file($rcs_filename);
|
1999-10-19 02:55:01 +04:00
|
|
|
my $file_rev = $revision;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-11-04 02:37:44 +03:00
|
|
|
my @text = &extract_revision($revision);
|
|
|
|
die "$::progname: Internal consistency error" if $#text != $#::revision_map;
|
|
|
|
|
|
|
|
|
|
|
|
# Raw data opt (so other scripts can parse and play with the data)
|
|
|
|
&print_raw_data, exit if defined $::FORM{data};
|
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
# Handle the "line_nums" argument
|
|
|
|
#
|
1999-10-19 02:55:01 +04:00
|
|
|
my $opt_line_nums = 1;
|
1999-11-04 02:37:44 +03:00
|
|
|
if (defined $::COOKIE{line_nums}) {
|
|
|
|
$opt_line_nums = 1 if $::COOKIE{line_nums} eq 'on';
|
1999-07-23 22:39:31 +04:00
|
|
|
}
|
1999-11-04 02:37:44 +03:00
|
|
|
if (defined $::FORM{line_nums}) {
|
|
|
|
$opt_line_nums = 0 if $::FORM{line_nums} =~ /off|no|0/i;
|
|
|
|
$opt_line_nums = 1 if $::FORM{line_nums} =~ /on|yes|1/i;
|
1999-07-23 22:39:31 +04:00
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Option to make links to included files
|
1999-10-19 02:55:01 +04:00
|
|
|
my $opt_includes = 0;
|
1999-11-04 02:37:44 +03:00
|
|
|
$opt_includes = 1 if defined $::FORM{includes} and
|
|
|
|
$::FORM{includes} =~ /on|yes|1/i;
|
|
|
|
$opt_includes = 1 if $opt_includes and $file_tail =~ /(.c|.h|.cpp)$/;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my $use_html = 0;
|
1999-11-04 02:37:44 +03:00
|
|
|
$use_html = 1 if defined $::FORM{use_html} and $::FORM{use_html} eq '1';
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Handle the "mark" argument
|
|
|
|
#
|
1999-10-19 02:55:01 +04:00
|
|
|
my %mark_line;
|
|
|
|
my $mark_arg = '';
|
1999-11-04 02:37:44 +03:00
|
|
|
$mark_arg = $::FORM{mark} if defined $::FORM{mark};
|
|
|
|
foreach my $mark (split ',', $mark_arg) {
|
1999-10-19 02:55:01 +04:00
|
|
|
my ($begin, $end);
|
1998-06-17 01:43:24 +04:00
|
|
|
if (($begin, $end) = $mark =~ /(\d*)\-(\d*)/) {
|
|
|
|
$begin = 1 if $begin eq '';
|
1999-11-04 02:37:44 +03:00
|
|
|
$end = $#text + 1 if $end eq '' or $end > $#text + 1;
|
1998-06-17 01:43:24 +04:00
|
|
|
next if $begin >= $end;
|
|
|
|
$mark_line{$begin} = 'begin';
|
1999-11-04 02:37:44 +03:00
|
|
|
$mark_line{$end} = 'end';
|
1998-06-17 01:43:24 +04:00
|
|
|
} else {
|
|
|
|
$mark_line{$mark} = 'single';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Start printing out the page
|
|
|
|
#
|
|
|
|
&print_top;
|
1999-07-23 22:39:31 +04:00
|
|
|
print Param('bannerhtml', 1);
|
1999-03-22 23:15:27 +03:00
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
# Print link at top for directory browsing
|
|
|
|
#
|
1999-03-20 04:30:16 +03:00
|
|
|
print q(
|
|
|
|
<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=0 WIDTH="100%">
|
|
|
|
<TR>
|
|
|
|
<TD ALIGN=LEFT VALIGN=CENTER>
|
|
|
|
<NOBR><FONT SIZE="+2"><B>
|
1999-03-22 23:15:27 +03:00
|
|
|
CVS Blame
|
1999-03-20 04:30:16 +03:00
|
|
|
</B></FONT></NOBR>
|
|
|
|
<BR><B>
|
|
|
|
);
|
|
|
|
|
2000-01-31 06:52:09 +03:00
|
|
|
my $link_path = "";
|
1999-10-19 02:55:01 +04:00
|
|
|
foreach my $path (split('/',$rcs_path)) {
|
1999-04-30 22:38:50 +04:00
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
# Customize this translation
|
1999-07-23 22:39:31 +04:00
|
|
|
$link_path .= url_encode2($path).'/';
|
1999-10-19 02:55:01 +04:00
|
|
|
my $lxr_path = Fix_LxrLink($link_path);
|
1999-07-23 22:39:31 +04:00
|
|
|
print "<A HREF='$lxr_path'>$path</a>/ ";
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
2000-01-31 06:52:09 +03:00
|
|
|
my $lxr_path = Fix_LxrLink("$link_path$file_tail");
|
|
|
|
print "<A HREF='$lxr_path'>$file_tail</a> ";
|
1999-03-20 04:30:16 +03:00
|
|
|
|
2002-02-01 17:32:55 +03:00
|
|
|
my $graph_cell = Param('cvsgraph') ? <<"--endquote--" : "";
|
|
|
|
</TR><TR>
|
|
|
|
<TD NOWRAP>
|
|
|
|
<A HREF="cvsgraph.cgi?file=$filename">Revision Graph</A>
|
|
|
|
</TD>
|
|
|
|
--endquote--
|
|
|
|
|
1999-03-20 04:30:16 +03:00
|
|
|
print " (<A HREF='cvsblame.cgi?file=$filename&rev=$revision&root=$root'";
|
2002-02-13 17:19:07 +03:00
|
|
|
print " onmouseover='return log(event,\"$::prev_revision{$revision}\",\"$revision\");'" if $::use_layers;
|
|
|
|
print " onmouseover=\"showMessage('$revision','top')\" id=\"line_top\"" if $::use_dom;
|
1999-03-20 04:30:16 +03:00
|
|
|
print ">";
|
|
|
|
print "$browse_revtag:" unless $browse_revtag eq 'HEAD';
|
|
|
|
print $revision if $revision;
|
|
|
|
print "</A>)";
|
|
|
|
|
|
|
|
print qq(
|
|
|
|
</B>
|
|
|
|
</TD>
|
|
|
|
<TD ALIGN=RIGHT VALIGN=TOP WIDTH="1%">
|
|
|
|
<TABLE BORDER CELLPADDING=10 CELLSPACING=0>
|
|
|
|
<TR>
|
|
|
|
<TD NOWRAP BGCOLOR="#FAFAFA">
|
1999-03-20 05:00:48 +03:00
|
|
|
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>
|
|
|
|
<TR>
|
1999-03-22 23:15:27 +03:00
|
|
|
<TD NOWRAP>
|
1999-07-23 22:39:31 +04:00
|
|
|
<A HREF="$lxr_path">LXR: Cross Reference</A>
|
1999-03-20 05:00:48 +03:00
|
|
|
</TD>
|
|
|
|
</TR><TR>
|
1999-03-22 23:15:27 +03:00
|
|
|
<TD NOWRAP>
|
|
|
|
<A HREF="cvslog.cgi?file=$filename">Full Change Log</A>
|
1999-03-20 05:00:48 +03:00
|
|
|
</TD>
|
2002-02-01 17:32:55 +03:00
|
|
|
$graph_cell
|
1999-03-20 05:00:48 +03:00
|
|
|
</TR>
|
|
|
|
</TABLE>
|
1999-03-20 04:30:16 +03:00
|
|
|
</TD>
|
|
|
|
</TR>
|
|
|
|
</TABLE>
|
|
|
|
</TD>
|
|
|
|
</TR>
|
|
|
|
</TABLE>
|
1999-03-22 23:15:27 +03:00
|
|
|
);
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my $open_table_tag =
|
|
|
|
'<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%">';
|
1999-03-25 03:22:22 +03:00
|
|
|
print "$open_table_tag<TR><TD colspan=3><PRE>";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Print each line of the revision, preceded by its annotation.
|
|
|
|
#
|
1999-10-19 02:55:01 +04:00
|
|
|
my $count = $#::revision_map;
|
1998-06-18 20:47:00 +04:00
|
|
|
if ($count == 0) {
|
|
|
|
$count = 1;
|
|
|
|
}
|
1999-10-19 02:55:01 +04:00
|
|
|
my $line_num_width = int(log($count)/log(10)) + 1;
|
|
|
|
my $revision_width = 3;
|
|
|
|
my $author_width = 5;
|
|
|
|
my $line = 0;
|
|
|
|
my %usedlog;
|
1998-06-17 01:43:24 +04:00
|
|
|
$usedlog{$revision} = 1;
|
1999-10-19 02:55:01 +04:00
|
|
|
my $old_revision = 0;
|
|
|
|
my $row_color = '';
|
|
|
|
my $lines_in_table = 0;
|
|
|
|
my $inMark = 0;
|
|
|
|
my $rev_count = 0;
|
|
|
|
foreach $revision (@::revision_map)
|
1998-06-17 01:43:24 +04:00
|
|
|
{
|
1999-10-19 02:55:01 +04:00
|
|
|
my $text = $text[$line++];
|
1998-06-17 01:43:24 +04:00
|
|
|
$usedlog{$revision} = 1;
|
1999-03-25 03:22:22 +03:00
|
|
|
$lines_in_table++;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
if ($opt_html_comments) {
|
|
|
|
# Don't escape HTML in C/C++ comments
|
|
|
|
$text = &leave_html_comments($text);
|
|
|
|
} elsif ( $opt_sanitize ){
|
|
|
|
# Mark filty words and Escape HTML meta-characters
|
|
|
|
$text = markup_line($text);
|
|
|
|
} else {
|
|
|
|
$text =~ s/&/&/g;
|
|
|
|
$text =~ s/</</g;
|
|
|
|
$text =~ s/>/>/g;
|
|
|
|
}
|
|
|
|
# Add a link to traverse to included files
|
|
|
|
$text = &link_includes($text) if $opt_includes;
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my $output = '';
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Highlight lines
|
1999-10-19 02:55:01 +04:00
|
|
|
my $mark_cmd;
|
1999-11-04 02:37:44 +03:00
|
|
|
if (defined($mark_cmd = $mark_line{$line}) and $mark_cmd ne 'end') {
|
1999-03-25 03:22:22 +03:00
|
|
|
$output .= '</TD></TR><TR><TD BGCOLOR=LIGHTGREEN WIDTH="100%"><PRE>';
|
1999-03-20 02:36:58 +03:00
|
|
|
$inMark = 1;
|
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-25 03:22:22 +03:00
|
|
|
if ($old_revision ne $revision and $line != 1) {
|
|
|
|
if ($row_color eq '') {
|
|
|
|
$row_color=' BGCOLOR="#e7e7e7"';
|
1999-03-20 02:36:58 +03:00
|
|
|
} else {
|
1999-03-25 03:22:22 +03:00
|
|
|
$row_color='';
|
|
|
|
}
|
|
|
|
if (not $inMark) {
|
|
|
|
if ($lines_in_table > 100) {
|
|
|
|
$output .= "</TD></TR></TABLE>$open_table_tag<TR><TD colspan=3$row_color><PRE>";
|
|
|
|
$lines_in_table=0;
|
|
|
|
} else {
|
|
|
|
$output .= "</TD></TR><TR><TD colspan=3$row_color><PRE>";
|
1999-03-22 23:24:44 +03:00
|
|
|
}
|
1999-03-20 02:36:58 +03:00
|
|
|
}
|
1999-03-25 03:22:22 +03:00
|
|
|
} elsif ($lines_in_table > 200 and not $inMark) {
|
|
|
|
$output .= "</TD></TR></TABLE>$open_table_tag<TR><TDcolspan=3$row_color><PRE>";
|
|
|
|
$lines_in_table=0;
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
1999-03-25 03:22:22 +03:00
|
|
|
$output .= "<A NAME=$line></A>";
|
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
$output .= sprintf("%${line_num_width}s ", $line) if $opt_line_nums;
|
|
|
|
|
1999-03-22 23:24:44 +03:00
|
|
|
if ($old_revision ne $revision or $rev_count > 20) {
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
$revision_width = max($revision_width,length($revision));
|
|
|
|
|
1999-03-26 22:20:36 +03:00
|
|
|
# $output .= "<A HREF=\"cvsblame.cgi?file=$filename&rev=$revision&root=$root\"";
|
1999-10-19 02:55:01 +04:00
|
|
|
if (defined $::prev_revision{$revision}) {
|
|
|
|
$output .= "<A HREF=\"cvsview2.cgi?diff_mode=context&whitespace_mode=show&root=$root&subdir=$rcs_path&command=DIFF_FRAMESET&file=$file_tail&rev2=$revision&rev1=$::prev_revision{$revision}\"";
|
1999-03-26 22:20:36 +03:00
|
|
|
} else {
|
|
|
|
$output .= "<A HREF=\"cvsview2.cgi?root=$root&subdir=$rcs_path&command=DIRECTORY&files=$file_tail\"";
|
1999-10-19 02:55:01 +04:00
|
|
|
$::prev_revision{$revision} = '';
|
1999-03-26 22:20:36 +03:00
|
|
|
}
|
2002-02-13 17:19:07 +03:00
|
|
|
$output .= " onmouseover='return log(event,\"$::prev_revision{$revision}\",\"$revision\");'" if $::use_layers;
|
|
|
|
$output .= " onmouseover=\"showMessage('$revision','$line')\" id=\"line_$line\"" if $::use_dom;
|
1999-03-20 03:27:42 +03:00
|
|
|
$output .= ">";
|
1999-10-19 02:55:01 +04:00
|
|
|
my $author = $::revision_author{$revision};
|
1999-03-20 02:36:58 +03:00
|
|
|
$author =~ s/%.*$//;
|
|
|
|
$author_width = max($author_width,length($author));
|
|
|
|
$output .= sprintf("%-${author_width}s ", $author);
|
|
|
|
$output .= "$revision</A> ";
|
1998-06-17 01:43:24 +04:00
|
|
|
$output .= ' ' x ($revision_width - length($revision));
|
|
|
|
|
|
|
|
$old_revision = $revision;
|
|
|
|
$rev_count = 0;
|
|
|
|
} else {
|
1999-03-22 23:24:44 +03:00
|
|
|
$output .= ' ' . ' ' x ($author_width + $revision_width);
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
$rev_count++;
|
|
|
|
|
|
|
|
$output .= "$text";
|
|
|
|
|
|
|
|
# Close the highlighted section
|
1999-11-04 02:37:44 +03:00
|
|
|
if (defined $mark_cmd and $mark_cmd ne 'begin') {
|
1998-06-17 01:43:24 +04:00
|
|
|
chop($output);
|
1999-03-25 03:22:22 +03:00
|
|
|
$output .= "</TD></TR><TR><TD colspan=3$row_color><PRE>";
|
1999-03-20 02:36:58 +03:00
|
|
|
$inMark = 0;
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
print $output;
|
|
|
|
}
|
1999-03-25 03:22:22 +03:00
|
|
|
print "</TD></TR></TABLE>\n";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
2002-02-13 17:19:07 +03:00
|
|
|
if ($::use_layers || $::use_dom) {
|
1999-03-20 03:27:42 +03:00
|
|
|
# Write out cvs log messages as a JS variables
|
2001-05-31 02:13:03 +04:00
|
|
|
# or hidden <div>'s
|
2002-02-13 17:19:07 +03:00
|
|
|
print qq|<SCRIPT $::script_type><!--\n| if $::use_layers;
|
1999-10-19 02:55:01 +04:00
|
|
|
while (my ($revision, $junk) = each %usedlog) {
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-20 03:27:42 +03:00
|
|
|
# Create a safe variable name for a revision log
|
1999-10-19 02:55:01 +04:00
|
|
|
my $revisionName = $revision;
|
1999-03-20 03:27:42 +03:00
|
|
|
$revisionName =~ tr/./_/;
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my $log = $::revision_log{$revision};
|
2002-02-21 00:17:04 +03:00
|
|
|
$log =~ s/([^\n\r]{80})([^\n\r]*)/$1\n$2/g if $::use_layers;
|
|
|
|
$log = html_quote($log);
|
1999-07-23 22:39:31 +04:00
|
|
|
$log = MarkUpText($log);
|
1999-03-20 03:27:42 +03:00
|
|
|
$log =~ s/\n|\r|\r\n/<BR>/g;
|
2002-02-13 17:19:07 +03:00
|
|
|
$log =~ s/"/\\"/g if $::use_layers;
|
1999-03-20 03:27:42 +03:00
|
|
|
|
|
|
|
# Write JavaScript variable for log entry (e.g. log1_1 = "New File")
|
1999-10-19 02:55:01 +04:00
|
|
|
my $author = $::revision_author{$revision};
|
1999-03-20 03:27:42 +03:00
|
|
|
$author =~ tr/%/@/;
|
1999-10-19 02:55:01 +04:00
|
|
|
my $author_email = EmailFromUsername($author);
|
2002-02-13 17:19:07 +03:00
|
|
|
print "<div id=\"rev_$revision\" class=\"log_msg\" style=\"display:none\">" if $::use_dom;
|
|
|
|
print "log$revisionName = \"" if $::use_layers;
|
2001-05-31 02:13:03 +04:00
|
|
|
print "<b>$revision</b> <<a href='mailto:$author_email'>$author</a>>"
|
1999-10-19 02:55:01 +04:00
|
|
|
." <b>$::revision_ctime{$revision}</b><BR>"
|
2001-05-31 02:13:03 +04:00
|
|
|
."<SPACER TYPE=VERTICAL SIZE=5>$log";
|
2002-02-13 17:19:07 +03:00
|
|
|
print "\";\n" if $::use_layers;
|
|
|
|
print "</div>\n" if $::use_dom;
|
1999-03-20 03:27:42 +03:00
|
|
|
}
|
2002-02-21 00:17:04 +03:00
|
|
|
print "//--></SCRIPT>" if $::use_layers;
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
&print_bottom;
|
|
|
|
|
|
|
|
if ( $opt_sanitize )
|
|
|
|
{
|
|
|
|
dbmclose %SourceChecker::token_dictionary;
|
|
|
|
}
|
|
|
|
|
|
|
|
## END of main script
|
|
|
|
|
|
|
|
sub max {
|
1999-03-20 04:30:16 +03:00
|
|
|
my ($a, $b) = @_;
|
1998-06-17 01:43:24 +04:00
|
|
|
return ($a > $b ? $a : $b);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub print_top {
|
1999-03-20 04:30:16 +03:00
|
|
|
my ($title_text) = "for $file_tail (";
|
1998-06-17 01:43:24 +04:00
|
|
|
$title_text .= "$browse_revtag:" unless $browse_revtag eq 'HEAD';
|
|
|
|
$title_text .= $revision if $revision;
|
|
|
|
$title_text .= ")";
|
|
|
|
$title_text =~ s/\(\)//;
|
|
|
|
|
1999-11-04 05:14:56 +03:00
|
|
|
$| = 1;
|
|
|
|
|
1999-03-20 03:27:42 +03:00
|
|
|
print "<HTML><HEAD><TITLE>CVS Blame $title_text</TITLE>";
|
|
|
|
|
2002-02-13 17:19:07 +03:00
|
|
|
print <<__TOP__ if $::use_layers;
|
|
|
|
<SCRIPT $::script_type><!--
|
1998-09-10 11:27:31 +04:00
|
|
|
var event = 0; // Nav3.0 compatibility
|
1998-06-17 01:43:24 +04:00
|
|
|
document.loaded = false;
|
|
|
|
|
|
|
|
function finishedLoad() {
|
1999-09-17 19:47:03 +04:00
|
|
|
if (parseInt(navigator.appVersion) < 4 ||
|
|
|
|
navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
|
1998-06-17 01:43:24 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
document.loaded = true;
|
|
|
|
document.layers['popup'].visibility='hide';
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
1999-03-20 03:27:42 +03:00
|
|
|
function revToName (rev) {
|
|
|
|
revName = rev + "";
|
|
|
|
revArray = revName.split(".");
|
|
|
|
return revArray.join("_");
|
|
|
|
}
|
|
|
|
|
1999-03-20 02:36:58 +03:00
|
|
|
function log(event, prev_rev, rev) {
|
1999-09-17 19:47:03 +04:00
|
|
|
if (parseInt(navigator.appVersion) < 4 ||
|
|
|
|
navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
|
1998-06-17 01:43:24 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
1999-03-20 04:30:16 +03:00
|
|
|
var l = document.layers['popup'];
|
1999-03-22 23:15:27 +03:00
|
|
|
var guide = document.layers['popup_guide'];
|
|
|
|
|
|
|
|
if (event.target.text.length > max_link_length) {
|
|
|
|
max_link_length = event.target.text.length;
|
|
|
|
|
|
|
|
guide.document.write("<PRE>" + event.target.text);
|
|
|
|
guide.document.close();
|
|
|
|
|
|
|
|
popup_offset = guide.clip.width;
|
|
|
|
}
|
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
if (document.loaded) {
|
1999-03-20 04:30:16 +03:00
|
|
|
l.document.write("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3><TR><TD BGCOLOR=#F0A000>");
|
|
|
|
l.document.write("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=6><TR><TD BGCOLOR=#FFFFFF><tt>");
|
1998-06-17 01:43:24 +04:00
|
|
|
l.document.write(eval("log" + revToName(rev)) + "</TD></TR></TABLE>");
|
1999-03-20 02:36:58 +03:00
|
|
|
l.document.write("</td></tr></table>");
|
1998-06-17 01:43:24 +04:00
|
|
|
l.document.close();
|
|
|
|
}
|
1998-06-26 23:00:22 +04:00
|
|
|
|
|
|
|
if(event.target.y > window.innerHeight + window.pageYOffset - l.clip.height) {
|
|
|
|
l.top = (window.innerHeight + window.pageYOffset - (l.clip.height + 15));
|
|
|
|
} else {
|
1999-03-20 04:30:16 +03:00
|
|
|
l.top = event.target.y - 9;
|
1998-06-26 23:00:22 +04:00
|
|
|
}
|
1999-03-22 23:15:27 +03:00
|
|
|
l.left = event.target.x + popup_offset;
|
1999-03-20 04:30:16 +03:00
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
l.visibility="show";
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
file_tail = "$file_tail";
|
1999-03-22 23:15:27 +03:00
|
|
|
popup_offset = 5;
|
|
|
|
max_link_length = 0;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-20 04:30:16 +03:00
|
|
|
initialLayer = "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3><TR><TD BGCOLOR=#F0A000><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=6><TR><TD BGCOLOR=#FFFFFF><B>Page loading...please wait.</B></TD></TR></TABLE></td></tr></table>";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
2001-10-11 22:44:14 +04:00
|
|
|
//--></SCRIPT>
|
1998-06-17 01:43:24 +04:00
|
|
|
</HEAD>
|
1999-03-20 04:30:16 +03:00
|
|
|
<BODY onLoad="finishedLoad();" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000EE" VLINK="#551A8B" ALINK="#F0A000">
|
1998-06-17 01:43:24 +04:00
|
|
|
<LAYER SRC="javascript:initialLayer" NAME='popup' onMouseOut="this.visibility='hide';" LEFT=0 TOP=0 BGCOLOR='#FFFFFF' VISIBILITY='hide'></LAYER>
|
1999-03-25 03:22:22 +03:00
|
|
|
<LAYER SRC="javascript:initialLayer" NAME='popup_guide' onMouseOut="this.visibility='hide';" LEFT=0 TOP=0 VISIBILITY='hide'></LAYER>
|
1998-06-17 01:43:24 +04:00
|
|
|
__TOP__
|
2002-02-13 17:19:07 +03:00
|
|
|
print <<__TOP__ if $::use_dom;
|
|
|
|
<script $::script_type><!--
|
2001-05-31 02:13:03 +04:00
|
|
|
var r
|
|
|
|
function showMessage(rev,line) {
|
|
|
|
if (r) {
|
|
|
|
r.style.display='none'
|
|
|
|
}
|
|
|
|
r = document.getElementById('rev_'+rev)
|
|
|
|
var l = document.getElementById('line_'+line)
|
|
|
|
var t = l.offsetTop
|
|
|
|
var p = l.offsetParent
|
|
|
|
while (p.tagName != 'BODY') {
|
|
|
|
t = t + p.offsetTop
|
|
|
|
p = p.offsetParent
|
|
|
|
}
|
|
|
|
r.style.top = t
|
|
|
|
r.style.left = l.offsetLeft + l.offsetWidth + 20
|
|
|
|
r.style.display=''
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideMessage() {
|
|
|
|
if (r) {
|
|
|
|
r.style.display='none'
|
|
|
|
}
|
|
|
|
}
|
2001-10-11 22:44:14 +04:00
|
|
|
//--></script>
|
2001-05-31 02:13:03 +04:00
|
|
|
|
|
|
|
<style type="text/css">
|
|
|
|
body {
|
|
|
|
background-color: white;
|
|
|
|
color: black;
|
|
|
|
}
|
|
|
|
|
|
|
|
a:link {
|
|
|
|
color: blue;
|
|
|
|
}
|
|
|
|
|
|
|
|
a:visited {
|
|
|
|
color: purple;
|
|
|
|
}
|
|
|
|
|
|
|
|
a:active {
|
|
|
|
color: orange;
|
|
|
|
}
|
|
|
|
|
|
|
|
.log_msg {
|
|
|
|
border-style: solid;
|
|
|
|
border-color: #F0A000;
|
|
|
|
background-color: #FFFFFF;
|
|
|
|
padding: 5;
|
|
|
|
position: absolute;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<body onclick="hideMessage()">
|
|
|
|
__TOP__
|
2002-02-13 17:19:07 +03:00
|
|
|
print '<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000EE" VLINK="#551A8B" ALINK="#F0A000">' if not ($::use_layers || $::use_dom);
|
1998-06-17 01:43:24 +04:00
|
|
|
} # print_top
|
|
|
|
|
|
|
|
sub print_usage {
|
1999-03-20 04:30:16 +03:00
|
|
|
my ($linenum_message) = '';
|
|
|
|
my ($new_linenum, $src_roots_list);
|
|
|
|
my ($title_text) = "Usage";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-11-04 02:37:44 +03:00
|
|
|
if ($ENV{REQUEST_METHOD} eq 'POST' and defined $::FORM{set_line}) {
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Expire the cookie 5 months from now
|
1999-11-04 02:37:44 +03:00
|
|
|
my $set_cookie = "Set-Cookie: line_nums=$::FORM{set_line}; expires="
|
1998-06-17 01:43:24 +04:00
|
|
|
.&toGMTString(time + 86400 * 152)."; path=/";
|
1999-10-19 02:55:01 +04:00
|
|
|
# XXX Hey, nothing is done with this handy cookie string! ### XXX
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
1999-11-04 02:37:44 +03:00
|
|
|
if ( not defined $::COOKIE{line_nums} and not defined $::FORM{set_line}) {
|
1998-06-17 01:43:24 +04:00
|
|
|
$new_linenum = 'on';
|
1999-11-04 02:37:44 +03:00
|
|
|
} elsif ($::COOKIE{line_nums} eq 'off' or $::FORM{set_line} eq 'off') {
|
1998-06-17 01:43:24 +04:00
|
|
|
$linenum_message = 'Line numbers are currently <b>off</b>.';
|
|
|
|
$new_linenum = 'on';
|
|
|
|
} else {
|
|
|
|
$linenum_message = 'Line numbers are currently <b>on</b>.';
|
|
|
|
$new_linenum = 'off';
|
|
|
|
}
|
|
|
|
$src_roots_list = join('<BR>', @src_roots);
|
|
|
|
|
|
|
|
print <<__USAGE__;
|
|
|
|
<HTML>
|
|
|
|
<HEAD>
|
|
|
|
<TITLE>CVS Blame $title_text</TITLE>
|
|
|
|
</HEAD><BODY>
|
|
|
|
<H2>CVS Blame Usage</H2>
|
|
|
|
Add parameters to the query string to view a file.
|
|
|
|
<P>
|
|
|
|
<TABLE BORDER CELLPADDING=3>
|
|
|
|
<TR ALIGN=LEFT>
|
|
|
|
<TH>Param</TH>
|
|
|
|
<TH>Default</TH>
|
|
|
|
<TH>Example</TH>
|
|
|
|
<TH>Description</TH>
|
|
|
|
</TR><TR>
|
|
|
|
<TD>file</TD>
|
|
|
|
<TD>--</TD>
|
|
|
|
<TD>ns/cmd/Makefile</TD>
|
|
|
|
<TD>path to file name</TD>
|
|
|
|
</TR><TR>
|
|
|
|
<TD>root</TD>
|
|
|
|
<TD>$src_roots_list</TD>
|
|
|
|
<TD>/warp/webroot</TD>
|
|
|
|
<TD>cvs root</TD>
|
|
|
|
</TR><TR>
|
|
|
|
<TD>rev</TD>
|
|
|
|
<TD>HEAD</TD>
|
|
|
|
<TD>1.3
|
|
|
|
<BR>ACTRA_branch</TD>
|
|
|
|
<TD>revision</TD>
|
|
|
|
</TR><TR>
|
|
|
|
<TD>line_nums</TD>
|
1999-03-22 23:15:27 +03:00
|
|
|
<TD>on *</TD>
|
1998-06-17 01:43:24 +04:00
|
|
|
<TD>on
|
|
|
|
<BR>off</TD>
|
|
|
|
<TD>line numbers</TD>
|
|
|
|
</TR><TR>
|
|
|
|
<TD>#<line_number></TD>
|
|
|
|
<TD>--</TD>
|
|
|
|
<TD>#111</TD>
|
|
|
|
<TD>jump to a line</TD>
|
|
|
|
</TR>
|
|
|
|
</TABLE>
|
|
|
|
|
|
|
|
<P>Examples:
|
|
|
|
<TABLE><TR><TD> </TD><TD>
|
|
|
|
<A HREF="cvsblame.cgi?file=ns/cmd/Makefile">
|
|
|
|
cvsblame.cgi?file=ns/cmd/Makefile</A>
|
|
|
|
</TD></TR><TR><TD> </TD><TD>
|
|
|
|
<A HREF="cvsblame.cgi?file=ns/cmd/xfe/mozilla.c&rev=Dogbert4xEscalation_BRANCH">
|
|
|
|
cvsblame.cgi?file=ns/cmd/xfe/mozilla.c&rev=Dogbert4xEscalation_BRANCH</A>
|
|
|
|
</TD></TR><TR><TD> </TD><TD>
|
|
|
|
<A HREF="cvsblame.cgi?file=projects/bonsai/cvsblame.cgi&root=/warp/webroot">
|
|
|
|
cvsblame.cgi?file=projects/bonsai/cvsblame.cgi&root=/warp/webroot</A>
|
|
|
|
</TD></TR><TR><TD> </TD><TD>
|
|
|
|
<A HREF="cvsblame.cgi?file=ns/config/config.mk&line_nums=on">
|
|
|
|
cvsblame.cgi?file=ns/config/config.mk&line_nums=on</A>
|
|
|
|
</TD></TR><TR><TD> </TD><TD>
|
|
|
|
<A HREF="cvsblame.cgi?file=ns/cmd/xfe/dialogs.c#2384">
|
|
|
|
cvsblame.cgi?file=ns/cmd/xfe/dialogs.c#2384</A>
|
|
|
|
</TD></TR></TABLE>
|
|
|
|
|
|
|
|
<P>
|
|
|
|
You may also begin a query with the <A HREF="cvsqueryform.cgi">CVS Query Form</A>.
|
|
|
|
<FORM METHOD='POST' ACTION='cvsblame.cgi'>
|
|
|
|
|
|
|
|
<TABLE CELLPADDING=0 CELLSPACING=0>
|
|
|
|
<TR>
|
|
|
|
<TD>*<SPACER TYPE=HORIZONTAL SIZE=6></TD>
|
|
|
|
<TD>Instead of the <i>line_nums</i> parameter, you can
|
|
|
|
<INPUT TYPE=submit value='set a cookie to turn $new_linenum'>
|
|
|
|
line numbers.</TD>
|
|
|
|
</TR><TR>
|
|
|
|
<TD></TD>
|
|
|
|
<TD>$linenum_message</TD>
|
|
|
|
</TR></TABLE>
|
|
|
|
|
|
|
|
<INPUT TYPE=hidden NAME='set_line' value='$new_linenum'>
|
|
|
|
</FORM>
|
|
|
|
__USAGE__
|
|
|
|
&print_bottom;
|
|
|
|
} # sub print_usage
|
|
|
|
|
|
|
|
sub print_bottom {
|
1999-07-23 22:39:31 +04:00
|
|
|
my $maintainer = Param('maintainer');
|
|
|
|
|
|
|
|
print <<__BOTTOM__;
|
1998-06-17 01:43:24 +04:00
|
|
|
<HR WIDTH="100%">
|
|
|
|
<FONT SIZE=-1>
|
|
|
|
<A HREF="cvsblame.cgi">Page configuration and help</A>.
|
1999-07-23 22:39:31 +04:00
|
|
|
Mail feedback to <A HREF="mailto:$maintainer?subject=About the cvsblame script"><$maintainer></A>.
|
1998-06-17 01:43:24 +04:00
|
|
|
</FONT></BODY>
|
|
|
|
</HTML>
|
|
|
|
__BOTTOM__
|
|
|
|
} # print_bottom
|
|
|
|
|
1999-11-04 02:37:44 +03:00
|
|
|
sub print_raw_data {
|
|
|
|
my %revs_seen = ();
|
1999-11-04 05:14:56 +03:00
|
|
|
my $prev_rev = $::revision_map[0];
|
|
|
|
my $count = 0;
|
1999-11-04 02:37:44 +03:00
|
|
|
for my $rev (@::revision_map) {
|
1999-11-04 05:14:56 +03:00
|
|
|
if ($prev_rev eq $rev) {
|
|
|
|
$count++;
|
|
|
|
} else {
|
|
|
|
print "$prev_rev:$count\n";
|
|
|
|
$count = 1;
|
|
|
|
$prev_rev = $rev;
|
|
|
|
$revs_seen{$rev} = 1;
|
|
|
|
}
|
1999-11-04 02:37:44 +03:00
|
|
|
}
|
1999-11-04 05:14:56 +03:00
|
|
|
print "$prev_rev:$count\n";
|
1999-11-04 02:37:44 +03:00
|
|
|
print "REVISION DETAILS\n";
|
|
|
|
for my $rev (sort keys %revs_seen) {
|
1999-11-04 05:14:56 +03:00
|
|
|
print "$rev|$::revision_ctime{$rev}|$::revision_author{$rev}|$::revision_log{$rev}.\n";
|
1999-11-04 02:37:44 +03:00
|
|
|
}
|
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
sub link_includes {
|
1999-03-20 04:30:16 +03:00
|
|
|
my ($text) = $_[0];
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
if ($text =~ /\#(\s*)include(\s*)"(.*?)"/) {
|
1999-10-19 02:55:01 +04:00
|
|
|
foreach my $trial_root (($rcs_path, 'ns/include',
|
1998-06-17 01:43:24 +04:00
|
|
|
"$rcs_path/Attic", "$rcs_path/..")) {
|
|
|
|
if (-r "$root/$trial_root/$3,v") {
|
|
|
|
$text = "$`#$1include$2\"<A HREF='cvsblame.cgi"
|
|
|
|
."?root=$root&file=$trial_root/$3&rev=".$browse_revtag
|
|
|
|
."&use_html=$use_html'>$3</A>\";$'";
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my $in_comments = 0;
|
|
|
|
my $open_delim;
|
|
|
|
my $close_delim;
|
|
|
|
my $expected_delim;
|
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
sub html_comments_init {
|
1999-10-19 02:55:01 +04:00
|
|
|
return 0 unless $use_html;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Initialization for C comment context switching
|
|
|
|
$in_comments = 0;
|
|
|
|
$open_delim = '\/\*';
|
|
|
|
$close_delim = '\*\/';
|
|
|
|
|
|
|
|
# Initialize the next expected delim
|
|
|
|
$expected_delim = $open_delim;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub leave_html_comments {
|
1999-03-20 04:30:16 +03:00
|
|
|
my ($text) = $_[0];
|
1998-06-17 01:43:24 +04:00
|
|
|
# Allow HTML in the comments.
|
|
|
|
#
|
1999-10-19 02:55:01 +04:00
|
|
|
my $newtext = "";
|
|
|
|
my $oldtext = $text;
|
1998-06-17 01:43:24 +04:00
|
|
|
while ($oldtext =~ /(.*$expected_delim)(.*\n)/) {
|
|
|
|
$a = $1;
|
|
|
|
$b = $2;
|
|
|
|
# pay no attention to C++ comments within C comment context
|
|
|
|
if ($in_comments == 0) {
|
|
|
|
$a =~ s/</</g;
|
|
|
|
$a =~ s/>/>/g;
|
|
|
|
$expected_delim = $close_delim;
|
|
|
|
$in_comments = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$expected_delim = $open_delim;
|
|
|
|
$in_comments = 0;
|
|
|
|
}
|
|
|
|
$newtext = $newtext . $a;
|
|
|
|
$oldtext = $b;
|
|
|
|
}
|
|
|
|
# Handle thre remainder
|
|
|
|
if ($in_comments == 0){
|
|
|
|
$oldtext =~ s/</</g;
|
|
|
|
$oldtext =~ s/>/>/g;
|
|
|
|
}
|
|
|
|
$text = $newtext . $oldtext;
|
|
|
|
|
|
|
|
# Now fix the breakage of <username> stuff on xfe. -byrd
|
|
|
|
if ($text =~ /(.*)<(.*@.*)>(.*\n)/) {
|
|
|
|
$text = $1 . "<A HREF=mailto:$2?subject=$filename>$2</A>" . $3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
}
|