yangtse: curl-www/auto log.cgi,1.23,1.24
[email protected] Mon, 26 Feb 2007 13:10:37 +0000
Newsgroups
gmane.comp.web.curl.www.cvs
Message-ID
<[email protected] >
Update of /cvsroot/curl/curl-www/auto
In directory labb:/tmp/cvs-serv942/auto
Modified Files:
log.cgi
Log Message:
Code reorganization:
- use one single array, instead of two, to hold log file in memory,
cutting by half the memory usage, traversing only once each line.
- remove unused variables and retrieval of unused request parameters.
Index: log.cgi
===================================================================
RCS file: /cvsroot/curl/curl-www/auto/log.cgi,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- log.cgi 24 Feb 2007 19:19:46 -0000 1.23
+++ log.cgi 26 Feb 2007 13:10:35 -0000 1.24
@@ -9,18 +9,14 @@
my $req = new CGI;
-my $year=$req->param('year');
-my $month=$req->param('month');
-my $day=$req->param('day');
-my $inname=$req->param('name');
-my $indate=$req->param('date');
+my $year = "";
+my $month = "";
+my $day = "";
-my $id=$req->param('id');
+my $id = $req->param('id');
# Strip any unsafe log name characters
$id =~ s/[^-0-9_a-zA-Z]//g;
-my @out;
-
if($id =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)-(\d+)/) {
my ($bhour, $bmin, $bsec, $bpid);
($year, $month, $day, $bhour, $bmin, $bsec, $bpid)=
@@ -33,19 +29,8 @@
where("Autobuilds", "/auto", "Log From $year-$month-$day");
title("Log from $year-$month-$day");
-#print "year $year month $month day $day name $inname date $indate";
-
-my $date;
-my $name;
-my @present;
-
-my $show=0;
-my $thisid;
-
my $build = "inbox/build-$id.log";
-my $num;
-
# find out if log file is quoted-printable encoded
my $qpencoded = 0;
if(open(SCAN, "<$build")) {
@@ -53,73 +38,83 @@
my $mimecount;
while(<SCAN>) {
if($_ =~ /^testcurl: [A-Z]+ =3D/) {
- if($mimecount++ > 5) {
+ if($mimecount++ > 3) {
$qpencoded = 1;
last;
}
}
- last if($linecount++ > 30);
+ last if($linecount++ > 18);
}
close(SCAN);
}
-my $buffer = "";
-
-open(FILE, "<$build") || print "file not found!";
-
-&initwarn();
+my $date;
+my $timestamp;
+my $description;
-while(my $chunk = <FILE>) {
- my $line;
- # decode quoted-printable if encoded
- if($qpencoded) {
- $buffer .= MIME::QuotedPrint::decode_qp($chunk);
- if($buffer =~ /\n$/) {
- $line = $buffer;
- $buffer = "";
+if(open(FILE, "<$build")) {
+ #
+ &initwarn();
+ #
+ my @out;
+ my $num = 0;
+ my $state = 0;
+ my $buffer = "";
+ #
+ push @out, "\n<div class=\"mini\">\n";
+ #
+ while(my $chunk = <FILE>) {
+ my $line;
+ # decode quoted-printable if encoded
+ if($qpencoded) {
+ $buffer .= MIME::QuotedPrint::decode_qp($chunk);
+ if($buffer =~ /\n$/) {
+ $line = $buffer;
+ $buffer = "";
+ }
+ else {
+ next; # chunk
+ }
}
else {
- next; # chunk
+ $line = $chunk;
}
- }
- else {
- $line = $chunk;
- }
- if($line =~ /^testcurl: STARTING HERE/) {
- @present="";
- next;
- }
- elsif($line =~ /^(INPIPE: endsingle here|testcurl: ENDING HERE)/) {
- last;
- }
- if($line =~ /^testcurl: NAME = (.*)/) {
- $name = $1;
- }
- elsif($line =~ /^testcurl: date = (.*)/) {
- $date = $1;
- }
- push @present, $line;
-}
-
-push @out, "\n<div class=\"mini\">\n";
-for(@present) {
- chomp;
- if(checkwarn($_) || ($_ =~ /FAILED/) || ($_ =~ /MEMORY FAILURE/)) {
- $num++;
- push @out, "<a name=\"prob$num\"></a><div class=\"warning\">" . CGI::escapeHTML($_) . "</div>\n";
- }
- else {
- if($_ =~ /EMAIL/) {
- $_ =~ s:\@: /at/ :g;
+ chomp $line;
+ #
+ if($state) {
+ if($line =~ /^testcurl: ENDING HERE/) {
+ last;
+ }
+ elsif($line =~ /^testcurl: DESC = (.*)/) {
+ $description = $1;
+ }
+ elsif($line =~ /^testcurl: date = (.*)/) {
+ $date = $1;
+ }
+ elsif($line =~ /^testcurl: timestamp = (.*)/) {
+ $timestamp = $1;
+ }
+ elsif($line =~ /EMAIL/) {
+ $line =~ s:\@: /at/ :g;
+ }
+ #
+ if(checkwarn($line) || ($line =~ /FAILED/) || ($line =~ /MEMORY FAILURE/)) {
+ $num++;
+ push @out, "<a name=\"prob$num\"></a><div class=\"warning\">" . CGI::escapeHTML($line) . "</div>\n";
+ }
+ else {
+ push @out, CGI::escapeHTML($line) . "<br>\n";
+ }
+ }
+ elsif($line =~ /^testcurl: STARTING HERE/) {
+ $state = 1;
+ next;
}
- push @out, CGI::escapeHTML($_) . "<br>\n";
}
-}
-push @out, "</div>\n"; # end of mini-div
-
-close(FILE);
-
-if($out[0]) {
+ close(FILE);
+ #
+ push @out, "</div>\n"; # end of mini-div
+ #
if($num) {
print "jump down to ";
print "<a href=\"#prob1\">problem 1</a>\n";
@@ -127,9 +122,13 @@
print "<a href=\"#prob$num\">problem $num (last)</a>\n";
}
}
+ #
print @out;
+ #
+}
+else {
+ print "file not found!";
}
-
&catfile("foot.html");