Reduce the number of global variables. Only give 'NEXT ERROR' link if there is another one. Group consecutive errors into one error.

This commit is contained in:
slamm%netscape.com 2000-02-12 00:39:50 +00:00
Родитель da92793dad
Коммит 16721942fc
1 изменённых файлов: 122 добавлений и 102 удалений

Просмотреть файл

@ -39,10 +39,6 @@ $error_file_ref = '';
$error_line = 0; $error_line = 0;
$error_guess = 0; $error_guess = 0;
$next_err = 0;
@log_errors = ();
$log_line = 0;
############################################################# #############################################################
# CGI inputs # CGI inputs
@ -67,24 +63,24 @@ if (defined($args = $form{log}) or defined($args = $form{exerpt})) {
} }
$fulltext = $form{fulltext}; $fulltext = $form{fulltext};
$enc_buildname = &url_encode($buildname); $enc_buildname = url_encode($buildname);
die "the \"tree\" parameter must be provided\n" unless $tree; die "the \"tree\" parameter must be provided\n" unless $tree;
require "$tree/treedata.pl"; require "$tree/treedata.pl";
$time_str = print_time( $buildtime ); $time_str = print_time($buildtime);
$|=1; $|=1;
if ($linenum) { if ($linenum) {
&print_fragment; print_fragment();
exit; exit;
} }
&print_header; print_header();
&print_notes; print_notes();
# Dynamically load the error parser # Dynamically load the error parser
# #
@ -93,8 +89,8 @@ require "ep_${errorparser}.pl";
if ($fulltext) if ($fulltext)
{ {
&print_summary; my $errors = print_summary();
&print_log; print_log($errors);
} }
else else
{ {
@ -102,15 +98,15 @@ else
$brief_filename =~ s/.gz$/.brief.html/; $brief_filename =~ s/.gz$/.brief.html/;
if (-T "$tree/$brief_filename" and -M _ > -M $tree/$logfile) if (-T "$tree/$brief_filename" and -M _ > -M $tree/$logfile)
{ {
open (BRIEFFILE, "<$tree/$brief_filename"); open(BRIEFFILE, "<$tree/$brief_filename");
print while (<BRIEFFILE>) print while (<BRIEFFILE>)
} }
else else
{ {
open (BRIEFFILE, ">$tree/$brief_filename"); open(BRIEFFILE, ">$tree/$brief_filename");
&print_summary; my $errors = print_summary();
&print_log; print_log($errors);
} }
} }
@ -136,7 +132,7 @@ sub print_fragment {
my $last_line = $linenum + ($numlines/2); my $last_line = $linenum + ($numlines/2);
print "<pre><b>.<br>.<br>.<br></b>"; print "<pre><b>.<br>.<br>.<br></b>";
while(<BUILD_IN>) { while (<BUILD_IN>) {
next if $. < $first_line; next if $. < $first_line;
last if $. > $last_line; last if $. > $last_line;
print "<b><font color='red'>" if $. == $linenum; print "<b><font color='red'>" if $. == $linenum;
@ -150,7 +146,7 @@ sub print_fragment {
sub print_header { sub print_header {
print "Content-type: text/html\n\n"; print "Content-type: text/html\n\n";
if( $fulltext ){ if ($fulltext) {
$s = 'Show <b>Brief</b> Log'; $s = 'Show <b>Brief</b> Log';
$s1 = ''; $s1 = '';
$s2 = 'Full'; $s2 = 'Full';
@ -186,18 +182,18 @@ sub print_notes {
$found_note = 0; $found_note = 0;
open(NOTES,"<$tree/notes.txt") open(NOTES,"<$tree/notes.txt")
or print "<h2>warning: Couldn't open $tree/notes.txt </h2>\n"; or print "<h2>warning: Couldn't open $tree/notes.txt </h2>\n";
print "$buildtime, $buildname<br>\n"; print "$buildtime, $buildname<br>\n";
while(<NOTES>){ while (<NOTES>) {
chop; chop;
($nbuildtime,$nbuildname,$nwho,$nnow,$nenc_note) = split(/\|/); ($nbuildtime,$nbuildname,$nwho,$nnow,$nenc_note) = split(/\|/);
#print "$_<br>\n"; #print "$_<br>\n";
if( $nbuildtime == $buildtime && $nbuildname eq $buildname ){ if ($nbuildtime == $buildtime and $nbuildname eq $buildname) {
if( !$found_note ){ if (not $found_note) {
print "<H2>Build Comments</H2>\n"; print "<H2>Build Comments</H2>\n";
$found_note = 1; $found_note = 1;
} }
$now_str = &print_time($nnow); $now_str = print_time($nnow);
$note = &url_decode($nenc_note); $note = url_decode($nenc_note);
print "<pre>\n[<b><a href=mailto:$nwho>$nwho</a> - $now_str</b>]\n$note\n</pre>"; print "<pre>\n[<b><a href=mailto:$nwho>$nwho</a> - $now_str</b>]\n$note\n</pre>";
} }
} }
@ -210,15 +206,25 @@ sub print_summary {
# #
logprint('<H2>Build Error Summary</H2><PRE>'); logprint('<H2>Build Error Summary</H2><PRE>');
$log_line = 0; @log_errors = ();
open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
while( $line = <BUILD_IN> ){ my $line_num = 0;
&output_summary_line( $line ); my $error_num = 0;
open(BUILD_IN, "$gzip -d -c $tree/$logfile|");
while ($line = <BUILD_IN>) {
$line_has_error = output_summary_line($line, $error_num);
if ($line_has_error) {
push @log_errors, $line_num;
$error_num++;
} }
close( BUILD_IN ); $line_num++;
push @log_errors, 9999999; }
close(BUILD_IN);
logprint('</PRE>'); logprint('</PRE>');
return \@log_errors;
} }
sub print_log_section { sub print_log_section {
@ -254,56 +260,55 @@ sub print_log_section {
} }
sub print_log { sub print_log {
# my ($errors) = $_[0];
# reset the error counter
#
$next_err = 0;
logprint('<H2>Build Error Log</H2><pre>'); logprint('<H2>Build Error Log</H2><pre>');
$log_line = 0; $line_num = 0;
open( BUILD_IN, "$gzip -d -c $tree/$logfile|" ); open(BUILD_IN, "$gzip -d -c $tree/$logfile|");
while( $line = <BUILD_IN> ){ while ($line = <BUILD_IN>) {
&output_log_line( $line ); output_log_line($line, $line_num, $errors);
$line_num++;
} }
close( BUILD_IN ); close(BUILD_IN);
logprint('</PRE><p>' logprint('</PRE><p>'
."<font size=+1><a name=\"err$next_err\">No More Errors</a></font>" ."<font size=+1>No More Errors</a></font>"
.'<br><br><br>'); .'<br><br><br>');
} }
sub output_summary_line { BEGIN {
my( $line ) = $_[0]; my $last_was_error = 0;
my( $has_error );
$has_error = &has_error( $line ); sub output_summary_line {
my ($line, $error_id) = @_;
if (has_error($line)) {
$line =~ s/&/&amp;/g; $line =~ s/&/&amp;/g;
$line =~ s/</&lt;/g; $line =~ s/</&lt;/g;
if( $has_error ){ if (not $last_was_error) {
push @log_errors, $log_line + $LINES_AFTER_ERROR; logprint("<a href=\"#err$error_id\">$line</a>");
if( ! $last_was_error ) { } else {
logprint("<a href=\"#err$next_err\">$line</a>"); logprint("$line");
$next_err++;
} }
$last_was_error = 1; $last_was_error = 1;
} } else {
else {
$last_was_error = 0; $last_was_error = 0;
} }
return $last_was_error;
$log_line++; }
} }
BEGIN {
my $next_error = 0;
sub output_log_line { sub output_log_line {
my $line = $_[0]; my ($line, $line_num, $errors) = @_;
my $has_error = &has_error($line); my $has_error = $line_num == $errors->[$next_error];
my $has_warning = &has_warning($line); my $has_warning = has_warning($line);
$line =~ s/&/&amp;/g; $line =~ s/&/&amp;/g;
$line =~ s/</&lt;/g unless $line =~ /^<a name=[^>]*>(?:<\/a>)?$/i or $line =~ s/</&lt;/g unless $line =~ /^<a name=[^>]*>(?:<\/a>)?$/i or
@ -313,48 +318,63 @@ sub output_log_line {
my %out = (); my %out = ();
if (($has_error or $has_warning) and &has_errorline($line, \%out)) { if (($has_error or $has_warning) and has_errorline($line, \%out)) {
$q = quotemeta( $out{error_file} ); $q = quotemeta($out{error_file});
$goto_line = $out{error_line} > 10 ? $out{error_line} - 10 : 1; $goto_line = $out{error_line} > 10 ? $out{error_line} - 10 : 1;
$cvsblame = $out{error_guess} ? "cvsguess.cgi" : "cvsblame.cgi"; $cvsblame = $out{error_guess} ? "cvsguess.cgi" : "cvsblame.cgi";
$line =~ s@$q@<a href=../bonsai/$cvsblame?file=$out{error_file_ref}&rev=$cvs_branch&mark=$out{error_line}#$goto_line>$out{error_file}</a>@ $line =~ s@$q@<a href=../bonsai/$cvsblame?file=$out{error_file_ref}&rev=$cvs_branch&mark=$out{error_line}#$goto_line>$out{error_file}</a>@
} }
if ($has_error) { if ($has_error) {
$next_error++;
unless ($last_was_error) { unless ($last_was_error) {
$logline .= "<a name=\"err$next_err\"></a>"; $logline .= "<a name='err".($next_error - 1)."'></a>";
$next_err++;
$logline .= "<a href=\"#err$next_err\">NEXT</a> "; # Only print "NEXT ERROR" link if there is another error to jump to
$have_more_errors = 0;
my $ii = $next_error;
while ($ii < $#{$errors} - 1) {
if ($errors->[$ii] != $errors->[$ii + 1] - 1) {
$have_more_errors = 1;
last;
} }
$logline .= "<font color=\"000080\">$line</font>"; $ii++;
}
if ($have_more_errors) {
$logline .= "<a href='#err$next_error'>NEXT ERROR</a> ";
}
}
$logline .= "<font color='000080'>$line</font>";
$last_was_error = 1; $last_was_error = 1;
} }
elsif ($has_warning) { elsif ($has_warning) {
$logline = "<font color=000080>$line</font>"; $logline = "<font color='000080'>$line</font>";
} }
else { else {
$logline = $line; $logline = $line;
$last_was_error = 0; $last_was_error = 0;
} }
&push_log_line($logline); push_log_line($logline, $errors);
}
} }
sub push_log_line { sub push_log_line {
my( $line ) = $_[0]; my ($line, $log_errors) = @_;
if( $fulltext ){ if ($fulltext) {
logprint($line); logprint($line);
return; return;
} }
if( $log_line > $log_errors[$cur_error] ){ if ($log_line > $log_errors->[$cur_error] + $LINES_AFTER_ERROR) {
$cur_error++; $cur_error++;
} }
if( $log_line >= $log_errors[$cur_error] - $LINES_BEFORE_ERROR ){ if ($log_line >= $log_errors->[$cur_error] - $LINES_BEFORE_ERROR) {
if( $log_skip != 0 ){ if ($log_skip != 0) {
logprint("\n<i><font size=+1> Skipping $log_skip Lines...</i></font>\n\n"); logprint("\n<i><font size=+1> Skipping $log_skip Lines...</i></font>\n\n");
$log_skip = 0; $log_skip = 0;
} }