Attached Files | 0001-BUG-Overhaul-configure-warning-extraction-algorithm.patch [^] (3,630 bytes) 2013-11-11 12:30 [Show Content] [Hide Content]From 1bfac3523d705a2d9c7b505706bc8ac808d6d549 Mon Sep 17 00:00:00 2001
From: Igor Murzov <e-mail@date.by>
Date: Fri, 1 Nov 2013 18:22:42 +0400
Subject: [PATCH] BUG: Overhaul configure warning extraction algorithm
This fixes warnings duplication and makes extraction actually work
(even with autotools projects).
Reviewed-by: Nils Gladitz <nilsgladitz@gmail.com>
---
models/buildconfigure.php | 82 +++++++++++++++++------------------------------
1 file changed, 30 insertions(+), 52 deletions(-)
diff --git a/models/buildconfigure.php b/models/buildconfigure.php
index dfdd714..fd906eb 100644
--- a/models/buildconfigure.php
+++ b/models/buildconfigure.php
@@ -156,65 +156,43 @@ class BuildConfigure
} // end insert
- /** Extract the position of the next warning from $log */
- function GetNextConfigureWarningPosition($log, $position)
- {
- // Use input $position as starting point:
- //
- $pos1 = strpos($log, 'CMake Warning', $position);
-
- $pos2 = strpos($log, 'Warning:', $position);
-
- // Return the smaller of the values as new $position value.
- // (Or 'false' if both are false...)
- //
- if($pos1 !== false)
- {
- if($pos2 !== false)
- {
- $position = min($pos1, $pos2);
- }
- else
- {
- $position = $pos1;
- }
- }
- else
- {
- $position = $pos2;
- }
-
- return $position;
- }
-
/** Compute the warnings from the log. In the future we might want to add errors */
function ComputeErrors()
{
- $nwarnings = 0;
- // Add the warnings in the configurewarningtable
- $position = $this->GetNextConfigureWarningPosition($this->Log, 0);
+ $nwarnings = 0;
+ $log_lines = explode("\n",$this->Log);
+ $numlines = count($log_lines);
- while($position !== false)
+ for($l = 0; $l < $numlines; $l++)
{
- $warning = "";
- $endline = strpos($this->Log,'\n',$position);
-
- if($endline !== false)
- {
- $warning = substr($this->Log,$position,$endline-$position);
- }
- else
+ if(($pos = stripos($log_lines[$l], 'warning')) !== false &&
+ strpos($log_lines[$l], ':', $pos + 7) !== false)
{
- $warning = substr($this->Log,$position);
+ $precontext = "";
+ $postcontext = "";
+
+ // Get 2 lines of precontext
+ $pre_start = max($l-2, 0);
+ for($j = $pre_start; $j < $l; $j++)
+ {
+ $precontext .= $log_lines[$j]."\n";
+ }
+
+ // Get 5 lines of postcontext
+ $post_end = min($l+6, $numlines);
+ for($j = $l+1; $j < $post_end; $j++)
+ {
+ $postcontext .= $log_lines[$j]."\n";
+ }
+
+ // Add the warnings in the configureerror table
+ $warning = pdo_real_escape_string($precontext. $log_lines[$l]."\n" .$postcontext);
+
+ pdo_query("INSERT INTO configureerror (buildid,type,text)
+ VALUES ('$this->BuildId','1','$warning')");
+ add_last_sql_error("BuildConfigure ComputeErrors",0,$this->BuildId);
+ $nwarnings++;
}
-
- $warning = pdo_real_escape_string($warning);
-
- pdo_query("INSERT INTO configureerror (buildid,type,text)
- VALUES ('$this->BuildId','1','$warning')");
- add_last_sql_error("BuildConfigure ComputeErrors",0,$this->BuildId);
- $nwarnings++;
- $position = $this->GetNextConfigureWarningPosition($this->Log, $position+1);
}
pdo_query("UPDATE configure SET warnings=".qnum($nwarnings)." WHERE buildid=".qnum($this->BuildId));
--
1.8.4
|