diff --git a/webtools/tinderbox/showlog.cgi b/webtools/tinderbox/showlog.cgi index 37b61e03962e..62131f490271 100755 --- a/webtools/tinderbox/showlog.cgi +++ b/webtools/tinderbox/showlog.cgi @@ -39,17 +39,13 @@ $error_file_ref = ''; $error_line = 0; $error_guess = 0; -$next_err = 0; -@log_errors = (); -$log_line = 0; - ############################################################# # CGI inputs if (defined($args = $form{log}) or defined($args = $form{exerpt})) { ($full_logfile, $linenum) = split /:/, $args; - ($tree, $logfile) = split /\//, $full_logfile; + ($tree, $logfile) = split /\//, $full_logfile; my $br = tb_find_build_record($tree, $logfile); $errorparser = $br->{errorparser}; @@ -67,24 +63,24 @@ if (defined($args = $form{log}) or defined($args = $form{exerpt})) { } $fulltext = $form{fulltext}; -$enc_buildname = &url_encode($buildname); +$enc_buildname = url_encode($buildname); die "the \"tree\" parameter must be provided\n" unless $tree; require "$tree/treedata.pl"; -$time_str = print_time( $buildtime ); +$time_str = print_time($buildtime); $|=1; if ($linenum) { - &print_fragment; + print_fragment(); exit; } -&print_header; -&print_notes; +print_header(); +print_notes(); # Dynamically load the error parser # @@ -93,8 +89,8 @@ require "ep_${errorparser}.pl"; if ($fulltext) { - &print_summary; - &print_log; + my $errors = print_summary(); + print_log($errors); } else { @@ -102,15 +98,15 @@ else $brief_filename =~ s/.gz$/.brief.html/; if (-T "$tree/$brief_filename" and -M _ > -M $tree/$logfile) { - open (BRIEFFILE, "<$tree/$brief_filename"); + open(BRIEFFILE, "<$tree/$brief_filename"); print while () } else { - open (BRIEFFILE, ">$tree/$brief_filename"); + open(BRIEFFILE, ">$tree/$brief_filename"); - &print_summary; - &print_log; + my $errors = print_summary(); + print_log($errors); } } @@ -136,7 +132,7 @@ sub print_fragment { my $last_line = $linenum + ($numlines/2); print "
.
.
.
"; - while() { + while () { next if $. < $first_line; last if $. > $last_line; print "" if $. == $linenum; @@ -150,7 +146,7 @@ sub print_fragment { sub print_header { print "Content-type: text/html\n\n"; - if( $fulltext ){ + if ($fulltext) { $s = 'Show Brief Log'; $s1 = ''; $s2 = 'Full'; @@ -186,18 +182,18 @@ sub print_notes { $found_note = 0; open(NOTES,"<$tree/notes.txt") or print "

warning: Couldn't open $tree/notes.txt

\n"; -print "$buildtime, $buildname
\n"; - while(){ + print "$buildtime, $buildname
\n"; + while () { chop; ($nbuildtime,$nbuildname,$nwho,$nnow,$nenc_note) = split(/\|/); #print "$_
\n"; - if( $nbuildtime == $buildtime && $nbuildname eq $buildname ){ - if( !$found_note ){ + if ($nbuildtime == $buildtime and $nbuildname eq $buildname) { + if (not $found_note) { print "

Build Comments

\n"; $found_note = 1; } - $now_str = &print_time($nnow); - $note = &url_decode($nenc_note); + $now_str = print_time($nnow); + $note = url_decode($nenc_note); print "
\n[$nwho - $now_str]\n$note\n
"; } } @@ -210,15 +206,25 @@ sub print_summary { # logprint('

Build Error Summary

');
 
-  $log_line = 0;
-  open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
-  while( $line =  ){
-    &output_summary_line( $line );
+  @log_errors = ();
+
+  my $line_num = 0;
+  my $error_num = 0;
+  open(BUILD_IN, "$gzip -d -c $tree/$logfile|");
+  while ($line = ) {
+    $line_has_error = output_summary_line($line, $error_num);
+    
+    if ($line_has_error) {
+      push @log_errors, $line_num;        
+      $error_num++;
+    }
+    $line_num++;
   }
-  close( BUILD_IN );
-  push @log_errors, 9999999;        
+  close(BUILD_IN);
 
   logprint('
'); + + return \@log_errors; } sub print_log_section { @@ -254,107 +260,121 @@ sub print_log_section { } sub print_log { - # - # reset the error counter - # - $next_err = 0; - + my ($errors) = $_[0]; + logprint('

Build Error Log

');
 
-  $log_line = 0;
-  open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
-  while( $line =  ){
-    &output_log_line( $line );
+  $line_num = 0;
+  open(BUILD_IN, "$gzip -d -c $tree/$logfile|");
+  while ($line = ) {
+    output_log_line($line, $line_num, $errors);
+    $line_num++;
   }
-  close( BUILD_IN );
+  close(BUILD_IN);
 
   logprint('

' - ."No More Errors" + ."No More Errors" .'


'); } -sub output_summary_line { - my( $line ) = $_[0]; - my( $has_error ); +BEGIN { + my $last_was_error = 0; - $has_error = &has_error( $line ); - - $line =~ s/&/&/g; - $line =~ s/$line"); - $next_err++; - } - $last_was_error = 1; + sub output_summary_line { + my ($line, $error_id) = @_; + + if (has_error($line)) { + $line =~ s/&/&/g; + $line =~ s/$line"); + } else { + logprint("$line"); + } + $last_was_error = 1; + } else { + $last_was_error = 0; } - else { - $last_was_error = 0; - } - - $log_line++; + return $last_was_error; + } } +BEGIN { + my $next_error = 0; -sub output_log_line { - my $line = $_[0]; + sub output_log_line { + my ($line, $line_num, $errors) = @_; + + my $has_error = $line_num == $errors->[$next_error]; + my $has_warning = has_warning($line); + + $line =~ s/&/&/g; + $line =~ s/]*>(?:<\/a>)?$/i or + $line =~ /^<\/a>$/i; - my $has_error = &has_error($line); - my $has_warning = &has_warning($line); + my $logline = ''; + + my %out = (); - $line =~ s/&/&/g; - $line =~ s/]*>(?:<\/a>)?$/i or - $line =~ /^<\/a>$/i; - - my $logline = ''; - - my %out = (); - - if (($has_error or $has_warning) and &has_errorline($line, \%out)) { - $q = quotemeta( $out{error_file} ); - $goto_line = $out{error_line} > 10 ? $out{error_line} - 10 : 1; - $cvsblame = $out{error_guess} ? "cvsguess.cgi" : "cvsblame.cgi"; - $line =~ s@$q@$out{error_file}@ - } - - if ($has_error) { - unless ($last_was_error) { - $logline .= ""; - $next_err++; - $logline .= "NEXT "; + if (($has_error or $has_warning) and has_errorline($line, \%out)) { + $q = quotemeta($out{error_file}); + $goto_line = $out{error_line} > 10 ? $out{error_line} - 10 : 1; + $cvsblame = $out{error_guess} ? "cvsguess.cgi" : "cvsblame.cgi"; + $line =~ s@$q@$out{error_file}@ } - $logline .= "$line"; - - $last_was_error = 1; - } - elsif ($has_warning) { - $logline = "$line"; - } - else { - $logline = $line; - $last_was_error = 0; - } - &push_log_line($logline); + if ($has_error) { + $next_error++; + + unless ($last_was_error) { + $logline .= ""; + + # 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; + } + $ii++; + } + if ($have_more_errors) { + $logline .= "NEXT ERROR "; + } + } + $logline .= "$line"; + + $last_was_error = 1; + } + elsif ($has_warning) { + $logline = "$line"; + } + else { + $logline = $line; + $last_was_error = 0; + } + + push_log_line($logline, $errors); + } } sub push_log_line { - my( $line ) = $_[0]; - if( $fulltext ){ + my ($line, $log_errors) = @_; + if ($fulltext) { logprint($line); return; } - if( $log_line > $log_errors[$cur_error] ){ + if ($log_line > $log_errors->[$cur_error] + $LINES_AFTER_ERROR) { $cur_error++; } - if( $log_line >= $log_errors[$cur_error] - $LINES_BEFORE_ERROR ){ - if( $log_skip != 0 ){ + if ($log_line >= $log_errors->[$cur_error] - $LINES_BEFORE_ERROR) { + if ($log_skip != 0) { logprint("\n Skipping $log_skip Lines...\n\n"); $log_skip = 0; }