Merge conflicts.
Declare function prototypes to shut up run-time warnings. Whitespace cleanup.
This commit is contained in:
parent
70cace3e6c
commit
9f073d3c62
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/www/; revision=7845
1 changed files with 165 additions and 131 deletions
|
@ -42,8 +42,8 @@
|
|||
# SUCH DAMAGE.
|
||||
#
|
||||
# $zId: cvsweb.cgi,v 1.93 2000/07/27 17:42:28 hzeller Exp $
|
||||
# $Id: cvsweb.cgi,v 1.46 2000-08-14 04:55:19 knu Exp $
|
||||
# $FreeBSD$
|
||||
# $Id: cvsweb.cgi,v 1.47 2000-08-15 08:47:40 knu Exp $
|
||||
# $FreeBSD: www/en/cgi/cvsweb.cgi,v 1.46 2000/08/14 04:55:19 knu Exp $
|
||||
#
|
||||
###
|
||||
|
||||
|
@ -80,6 +80,44 @@ use vars qw (
|
|||
$use_moddate
|
||||
);
|
||||
|
||||
sub printDiffSelect($);
|
||||
sub findLastModifiedSubdirs(@);
|
||||
sub htmlify($;$);
|
||||
sub spacedHtmlText($);
|
||||
sub link($$);
|
||||
sub revcmp($$);
|
||||
sub fatal($$);
|
||||
sub redirect($);
|
||||
sub safeglob($);
|
||||
sub getMimeTypeFromSuffix($);
|
||||
sub doAnnotate($$);
|
||||
sub doCheckout($$);
|
||||
sub cvswebMarkup($$$);
|
||||
sub viewable($);
|
||||
sub doDiff($$$$$$);
|
||||
sub getDirLogs($$@);
|
||||
sub readLog($;$);
|
||||
sub printLog($;$);
|
||||
sub doLog($);
|
||||
sub flush_diff_rows($$$$);
|
||||
sub human_readable_diff($);
|
||||
sub navigateHeader($$$$$);
|
||||
sub plural_write($$);
|
||||
sub readableTime($$);
|
||||
sub clickablePath($$);
|
||||
sub chooseCVSRoot();
|
||||
sub chooseMirror();
|
||||
sub fileSortCmp();
|
||||
sub download_url($$;$);
|
||||
sub download_link($$$;$);
|
||||
sub toggleQuery($$);
|
||||
sub urlencode($);
|
||||
sub http_header(;$);
|
||||
sub html_header($);
|
||||
sub html_footer();
|
||||
sub link_tags($);
|
||||
sub forbidden_module($);
|
||||
|
||||
##### Start of Configuration Area ########
|
||||
use Cwd;
|
||||
|
||||
|
@ -87,8 +125,11 @@ use Cwd;
|
|||
# User configuration is stored in
|
||||
$config = undef;
|
||||
|
||||
for ($ENV{CVSWEB_CONFIG}, '/usr/local/etc/cvsweb.conf', getcwd . '/cvsweb.conf') {
|
||||
$config = $_ if -r $_;
|
||||
for ($ENV{CVSWEB_CONFIG},
|
||||
# '/home/knu/etc/cvsweb.conf',
|
||||
'/usr/local/etc/cvsweb.conf',
|
||||
getcwd . '/cvsweb.conf') {
|
||||
$config = $_ if defined($_) && -r $_;
|
||||
}
|
||||
|
||||
# == Configuration defaults ==
|
||||
|
@ -146,7 +187,7 @@ $is_mod_perl = defined($ENV{MOD_PERL});
|
|||
# in lynx, it it very annoying to have two links
|
||||
# per file, so disable the link at the icon
|
||||
# in this case:
|
||||
$Browser = $ENV{HTTP_USER_AGENT} || '';
|
||||
$Browser = $ENV{HTTP_USER_AGENT};
|
||||
$is_lynx = ($Browser =~ m`^Lynx/`i);
|
||||
$is_w3m = ($Browser =~ m`^w3m/`i);
|
||||
$is_msie = ($Browser =~ m`MSIE`);
|
||||
|
@ -166,10 +207,10 @@ $nofilelinks = $is_textbased;
|
|||
# Turn off gzip if running under mod_perl. piping does
|
||||
# not work as expected inside the server. One can probably
|
||||
# achieve the same result using Apache::GZIPFilter.
|
||||
$maycompress =(($ENV{HTTP_ACCEPT_ENCODING} =~ m`gzip`
|
||||
|| $is_mozilla3)
|
||||
&& !$is_msie
|
||||
&& !$is_mod_perl);
|
||||
$maycompress = (($ENV{HTTP_ACCEPT_ENCODING} =~ m`gzip`
|
||||
|| $is_mozilla3)
|
||||
&& !$is_msie
|
||||
&& !$is_mod_perl);
|
||||
|
||||
# put here the variables we need in order
|
||||
# to hold our state - they will be added (with
|
||||
|
@ -191,7 +232,7 @@ else {
|
|||
undef %input;
|
||||
$query = $ENV{QUERY_STRING};
|
||||
|
||||
if ($query ne '') {
|
||||
if (defined($query) && $query ne '') {
|
||||
foreach (split(/&/, $query)) {
|
||||
s/%(..)/sprintf("%c", hex($1))/ge; # unquote %-quoted
|
||||
if (/(\S+)=(.*)/) {
|
||||
|
@ -686,7 +727,7 @@ elsif (-d $fullname) {
|
|||
print "<OPTION VALUE=\"\">All tags / default branch\n";
|
||||
foreach my $tag (reverse sort { lc $a cmp lc $b } keys %tags) {
|
||||
print "<OPTION",defined($input{only_with_tag}) &&
|
||||
$input{only_with_tag} eq $tag ? " SELECTED":"",
|
||||
$input{only_with_tag} eq $tag ? " SELECTED" : "",
|
||||
">$tag\n";
|
||||
}
|
||||
print "</SELECT>\n";
|
||||
|
@ -719,10 +760,10 @@ elsif (-d $fullname) {
|
|||
print "<OPTION VALUE=rev",$logsort eq "rev" ? " SELECTED" : "", ">Revision";
|
||||
print "</SELECT></td></tr>";
|
||||
print "<tr><td>Diff format: ";
|
||||
printDiffSelect();
|
||||
printDiffSelect(0);
|
||||
print "</td>";
|
||||
print "<td>Show Attic files: ";
|
||||
print "<INPUT NAME=hideattic TYPE=CHECKBOX", $input{'hideattic'}?" CHECKED":"",
|
||||
print "<INPUT NAME=hideattic TYPE=CHECKBOX", $input{'hideattic'} ? " CHECKED" : "",
|
||||
"></td></tr>\n";
|
||||
print "<tr><td align=center colspan=2><input type=submit value=\"Change Options\">";
|
||||
print "</td></tr></table></center></FORM>\n";
|
||||
|
@ -803,9 +844,8 @@ elsif (-d $fullname) {
|
|||
}
|
||||
## End MAIN
|
||||
|
||||
sub printDiffSelect {
|
||||
sub printDiffSelect($) {
|
||||
my ($use_java_script) = @_;
|
||||
$use_java_script = 0 if (!defined($use_java_script));
|
||||
my ($f) = $input{'f'};
|
||||
print "<SELECT NAME=\"f\"";
|
||||
print " onchange=\"submit()\"" if ($use_java_script);
|
||||
|
@ -818,7 +858,7 @@ sub printDiffSelect {
|
|||
print "</SELECT>";
|
||||
}
|
||||
|
||||
sub findLastModifiedSubdirs {
|
||||
sub findLastModifiedSubdirs(@) {
|
||||
my (@dirs) = @_;
|
||||
my ($dirname, @files);
|
||||
|
||||
|
@ -852,7 +892,7 @@ sub findLastModifiedSubdirs {
|
|||
return @files;
|
||||
}
|
||||
|
||||
sub htmlify {
|
||||
sub htmlify($;$) {
|
||||
my($string, $pr) = @_;
|
||||
|
||||
# Special Characters; RFC 1866
|
||||
|
@ -875,46 +915,46 @@ sub htmlify {
|
|||
return $string;
|
||||
}
|
||||
|
||||
sub spacedHtmlText {
|
||||
my($string, $pr) = @_;
|
||||
sub spacedHtmlText($) {
|
||||
local $_ = $_[0];
|
||||
|
||||
# Cut trailing spaces
|
||||
s/\s+$//;
|
||||
s/\s+\n$//;
|
||||
|
||||
# Expand tabs
|
||||
$string =~ s/\t+/' ' x (length($&) * $tabstop - length($`) % $tabstop)/e
|
||||
s/\t+/' ' x (length($&) * $tabstop - length($`) % $tabstop)/e
|
||||
if (defined($tabstop));
|
||||
|
||||
# replace <tab> and <space> (\001 is to protect us from htmlify)
|
||||
# gzip can make excellent use of this repeating pattern :-)
|
||||
$string =~ s/\001/\001%/g; #protect our & substitute
|
||||
s/\001/\001%/g; #protect our & substitute
|
||||
if ($hr_breakable) {
|
||||
# make every other space 'breakable'
|
||||
$string =~ s/ / \001nbsp; \001nbsp; \001nbsp; \001nbsp;/g; # <tab>
|
||||
$string =~ s/ / \001nbsp;/g; # 2 * <space>
|
||||
s/ / \001nbsp; \001nbsp; \001nbsp; \001nbsp;/g; # <tab>
|
||||
s/ / \001nbsp;/g; # 2 * <space>
|
||||
# leave single space as it is
|
||||
}
|
||||
else {
|
||||
$string =~ s/ /\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;/g;
|
||||
$string =~ s/ /\001nbsp;/g;
|
||||
s/ /\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;/g;
|
||||
s/ /\001nbsp;/g;
|
||||
}
|
||||
|
||||
$string = htmlify($string);
|
||||
$_ = htmlify($_);
|
||||
|
||||
# unescape
|
||||
$string =~ s/\001([^%])/&$1/g;
|
||||
$string =~ s/\001%/\001/g;
|
||||
s/\001([^%])/&$1/g;
|
||||
s/\001%/\001/g;
|
||||
|
||||
return $string;
|
||||
return $_;
|
||||
}
|
||||
|
||||
sub link {
|
||||
sub link($$) {
|
||||
my($name, $where) = @_;
|
||||
|
||||
return "<A HREF=\"$where\">$name</A>\n";
|
||||
}
|
||||
|
||||
sub revcmp {
|
||||
sub revcmp($$) {
|
||||
my($rev1, $rev2) = @_;
|
||||
my(@r1) = split(/\./, $rev1);
|
||||
my(@r2) = split(/\./, $rev2);
|
||||
|
@ -930,7 +970,7 @@ sub revcmp {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub fatal {
|
||||
sub fatal($$) {
|
||||
my($errcode, $errmsg) = @_;
|
||||
if ($is_mod_perl) {
|
||||
Apache->request->status((split(/ /, $errcode))[0]);
|
||||
|
@ -944,7 +984,7 @@ sub fatal {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
sub redirect {
|
||||
sub redirect($) {
|
||||
my($url) = @_;
|
||||
if ($is_mod_perl) {
|
||||
Apache->request->status(301);
|
||||
|
@ -960,7 +1000,7 @@ sub redirect {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
sub safeglob {
|
||||
sub safeglob($) {
|
||||
my ($filename) = @_;
|
||||
my ($dirname);
|
||||
my (@results);
|
||||
|
@ -989,7 +1029,7 @@ sub safeglob {
|
|||
@results;
|
||||
}
|
||||
|
||||
sub getMimeTypeFromSuffix {
|
||||
sub getMimeTypeFromSuffix($) {
|
||||
my ($fullname) = @_;
|
||||
my ($mimetype, $suffix);
|
||||
my $fh = do {local(*FH);};
|
||||
|
@ -1021,7 +1061,7 @@ sub getMimeTypeFromSuffix {
|
|||
###############################
|
||||
# show Annotation
|
||||
###############################
|
||||
sub doAnnotate ($$) {
|
||||
sub doAnnotate($$) {
|
||||
my ($rev) = @_;
|
||||
my ($pid);
|
||||
my ($pathname, $filename);
|
||||
|
@ -1040,7 +1080,7 @@ sub doAnnotate ($$) {
|
|||
|
||||
http_header();
|
||||
|
||||
navigateHeader ($scriptwhere,$pathname,$filename,$rev, "annotate");
|
||||
navigateHeader($scriptwhere,$pathname,$filename,$rev, "annotate");
|
||||
print "<h3 align=center>Annotation of $pathname$filename, Revision $rev</h3>\n";
|
||||
|
||||
# this seems to be necessary
|
||||
|
@ -1176,7 +1216,7 @@ sub doAnnotate ($$) {
|
|||
###############################
|
||||
# make Checkout
|
||||
###############################
|
||||
sub doCheckout {
|
||||
sub doCheckout($$) {
|
||||
my ($fullname, $rev) = @_;
|
||||
my ($mimetype,$revopt);
|
||||
my $fh = do {local(*FH);};
|
||||
|
@ -1259,7 +1299,7 @@ sub doCheckout {
|
|||
close($fh);
|
||||
}
|
||||
|
||||
sub cvswebMarkup {
|
||||
sub cvswebMarkup($$$) {
|
||||
my ($filehandle,$fullname,$revision) = @_;
|
||||
my ($pathname, $filename);
|
||||
|
||||
|
@ -1269,7 +1309,7 @@ sub cvswebMarkup {
|
|||
|
||||
http_header();
|
||||
|
||||
navigateHeader ($scriptwhere, $pathname, $filename, $revision, "view");
|
||||
navigateHeader($scriptwhere, $pathname, $filename, $revision, "view");
|
||||
print "<HR noshade>";
|
||||
print "<table width=\"100%\"><tr><td bgcolor=\"$markupLogColor\">";
|
||||
print "File: ", &clickablePath($where, 1);
|
||||
|
@ -1309,15 +1349,13 @@ sub cvswebMarkup {
|
|||
sub viewable($) {
|
||||
my ($mimetype) = @_;
|
||||
|
||||
$mimetype =~ m%^text/% ||
|
||||
$mimetype =~ m%^image/% ||
|
||||
0;
|
||||
$mimetype =~ m%^(text|image)/%;
|
||||
}
|
||||
|
||||
###############################
|
||||
# Show Colored Diff
|
||||
###############################
|
||||
sub doDiff {
|
||||
sub doDiff($$$$$$) {
|
||||
my($fullname, $r1, $tr1, $r2, $tr2, $f) = @_;
|
||||
my $fh = do {local(*FH);};
|
||||
my ($rev1, $rev2, $sym1, $sym2, @difftype, $diffname, $f1, $f2);
|
||||
|
@ -1461,7 +1499,7 @@ sub doDiff {
|
|||
###############################
|
||||
# Show Logs ..
|
||||
###############################
|
||||
sub getDirLogs {
|
||||
sub getDirLogs($$@) {
|
||||
my ($cvsroot,$dirname,@otherFiles) = @_;
|
||||
my ($state,$otherFiles,$tag, $file, $date, $branchpoint, $branch, $log);
|
||||
my ($rev, $revision, $revwanted, $filename, $head, $author);
|
||||
|
@ -1628,7 +1666,7 @@ again:
|
|||
close($fh);
|
||||
}
|
||||
|
||||
sub readLog {
|
||||
sub readLog($;$) {
|
||||
my($fullname,$revision) = @_;
|
||||
my ($symnames, $head, $rev, $br, $brp, $branch, $branchrev);
|
||||
my $fh = do {local(*FH);};
|
||||
|
@ -2032,7 +2070,7 @@ sub printLog($;$) {
|
|||
print "</PRE>\n";
|
||||
}
|
||||
|
||||
sub doLog {
|
||||
sub doLog($) {
|
||||
my($fullname) = @_;
|
||||
my ($diffrev, $upwhere, $filename, $backurl);
|
||||
|
||||
|
@ -2096,7 +2134,7 @@ EOF
|
|||
$diffrev = $input{"r2"} if (defined($input{"r2"}));
|
||||
print "<INPUT TYPE=\"TEXT\" SIZE=\"$inputTextSize\" NAME=\"tr2\" VALUE=\"$diffrev\" onChange='docuement.diff_select.r2.selectedIndex=0'>\n";
|
||||
print "<BR>Type of Diff should be a ";
|
||||
printDiffSelect();
|
||||
printDiffSelect(0);
|
||||
print "<INPUT TYPE=SUBMIT VALUE=\" Get Diffs \">\n";
|
||||
print "</FORM>\n";
|
||||
print "<HR noshade>\n";
|
||||
|
@ -2151,8 +2189,7 @@ EOF
|
|||
print "</BODY></HTML>\n";
|
||||
}
|
||||
|
||||
sub flush_diff_rows ($$$$)
|
||||
{
|
||||
sub flush_diff_rows($$$$) {
|
||||
my $j;
|
||||
my ($leftColRef,$rightColRef,$leftRow,$rightRow) = @_;
|
||||
if ($state eq "PreChangeRemove") { # we just got remove-lines before
|
||||
|
@ -2197,7 +2234,7 @@ sub human_readable_diff($){
|
|||
($pathname = $where_nd) =~ s/(Attic\/)?[^\/]*$//;
|
||||
($scriptwhere_nd = $scriptwhere) =~ s/.diff$//;
|
||||
|
||||
navigateHeader ($scriptwhere_nd, $pathname, $filename, $rev, "diff");
|
||||
navigateHeader($scriptwhere_nd, $pathname, $filename, $rev, "diff");
|
||||
|
||||
# Read header to pick up read revision and date, if possible
|
||||
while (<$fh>) {
|
||||
|
@ -2337,13 +2374,13 @@ sub human_readable_diff($){
|
|||
print "</tr></table>";
|
||||
}
|
||||
|
||||
sub navigateHeader ($$$$$) {
|
||||
sub navigateHeader($$$$$) {
|
||||
my ($swhere,$path,$filename,$rev,$title) = @_;
|
||||
$swhere = "" if ($swhere eq $scriptwhere);
|
||||
$swhere = urlencode($filename) if ($swhere eq "");
|
||||
print "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
|
||||
print "<HTML>\n<HEAD>\n";
|
||||
print '<!-- CVSweb $zRevision: 1.93 $ $Revision: 1.46 $ -->';
|
||||
print '<!-- CVSweb $zRevision: 1.93 $ $Revision: 1.47 $ -->';
|
||||
print "\n<TITLE>$path$filename - $title - $rev</TITLE></HEAD>\n";
|
||||
print "<BODY BGCOLOR=\"$backcolor\">\n";
|
||||
print "<table width=\"100%\" border=0 cellspacing=0 cellpadding=1 bgcolor=\"$navigationHeaderColor\">";
|
||||
|
@ -2356,8 +2393,7 @@ sub navigateHeader ($$$$$) {
|
|||
print "</tr></table>";
|
||||
}
|
||||
|
||||
sub plural_write ($$)
|
||||
{
|
||||
sub plural_write($$) {
|
||||
my ($num,$text) = @_;
|
||||
if ($num != 1) {
|
||||
$text = $text . "s";
|
||||
|
@ -2375,8 +2411,7 @@ sub plural_write ($$)
|
|||
# '..time ago'
|
||||
# H. Zeller <zeller@think.de>
|
||||
##
|
||||
sub readableTime ($$)
|
||||
{
|
||||
sub readableTime($$) {
|
||||
my ($i, $break, $retval);
|
||||
my ($secs,$long) = @_;
|
||||
|
||||
|
@ -2513,7 +2548,7 @@ sub chooseMirror() {
|
|||
}
|
||||
}
|
||||
|
||||
sub fileSortCmp {
|
||||
sub fileSortCmp() {
|
||||
my ($comp) = 0;
|
||||
my ($c,$d,$af,$bf);
|
||||
|
||||
|
@ -2544,7 +2579,7 @@ sub fileSortCmp {
|
|||
}
|
||||
|
||||
# make A url for downloading
|
||||
sub download_url {
|
||||
sub download_url($$;$) {
|
||||
my ($url,$revision,$mimetype) = @_;
|
||||
|
||||
$revision =~ s/\b0\.//;
|
||||
|
@ -2563,7 +2598,7 @@ sub download_url {
|
|||
|
||||
# Presents a link to download the
|
||||
# selected revision
|
||||
sub download_link {
|
||||
sub download_link($$$;$) {
|
||||
my ($url,$revision,$textlink,$mimetype) = @_;
|
||||
my ($fullurl) = download_url($url,$revision,$mimetype);
|
||||
my ($paren) = $textlink =~ /^\(/;
|
||||
|
@ -2635,14 +2670,14 @@ sub toggleQuery($$) {
|
|||
return "";
|
||||
}
|
||||
|
||||
sub urlencode {
|
||||
sub urlencode($) {
|
||||
my ($in) = @_;
|
||||
my ($out);
|
||||
($out = $in) =~ s/([\000-+{-\377])/sprintf("%%%02x", ord($1))/ge;
|
||||
return $out;
|
||||
}
|
||||
|
||||
sub http_header {
|
||||
sub http_header(;$) {
|
||||
my $content_type = shift || "text/html";
|
||||
if (defined($moddate)) {
|
||||
if ($is_mod_perl) {
|
||||
|
@ -2697,7 +2732,7 @@ sub http_header {
|
|||
|
||||
sub html_header($) {
|
||||
my ($title) = @_;
|
||||
my $version = '$zRevision: 1.93 $ $Revision: 1.46 $';
|
||||
my $version = '$zRevision: 1.93 $ $Revision: 1.47 $'; #'
|
||||
http_header();
|
||||
|
||||
(my $header = &cgi_style::html_header) =~ s/^.*\n\n//; # remove HTTP response header
|
||||
|
@ -2710,12 +2745,11 @@ $header
|
|||
EOH
|
||||
}
|
||||
|
||||
sub html_footer {
|
||||
sub html_footer() {
|
||||
return &cgi_style::html_footer;
|
||||
}
|
||||
|
||||
sub link_tags
|
||||
{
|
||||
sub link_tags($) {
|
||||
my ($tags) = @_;
|
||||
my ($ret) = "";
|
||||
my ($fileurl,$filename);
|
||||
|
@ -2734,7 +2768,7 @@ sub link_tags
|
|||
#
|
||||
# See if a module is listed in the config file's @HideModule list.
|
||||
#
|
||||
sub forbidden_module {
|
||||
sub forbidden_module($) {
|
||||
my($module) = @_;
|
||||
|
||||
for (my $i=0; $i < @HideModules; $i++) {
|
||||
|
|
Loading…
Reference in a new issue