Web: Group online demo report by line numbers
This commit is contained in:
parent
fdfa6444ea
commit
33edf63085
|
@ -39,7 +39,7 @@
|
||||||
* @param string $code Source code
|
* @param string $code Source code
|
||||||
* @return string Output lines
|
* @return string Output lines
|
||||||
*/
|
*/
|
||||||
function get_democlient_outout($code) {
|
function get_democlient_output($code) {
|
||||||
$postdata = http_build_query(
|
$postdata = http_build_query(
|
||||||
array(
|
array(
|
||||||
'code' => $code
|
'code' => $code
|
||||||
|
@ -59,6 +59,28 @@
|
||||||
return file('http://cppcheck.sourceforge.net/cgi-bin/democlient.cgi', false, $context);
|
return file('http://cppcheck.sourceforge.net/cgi-bin/democlient.cgi', false, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ...
|
||||||
|
* @param array $output Output lines
|
||||||
|
* @return array Parsed output
|
||||||
|
*/
|
||||||
|
function parse_democlient_output($output) {
|
||||||
|
$parsed = array();
|
||||||
|
foreach ($output as $line) { //for each output line...
|
||||||
|
$line = trim($line);
|
||||||
|
if (empty($line)) { //if empty line...
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
preg_match('/\[test.c:(\d+)\]: (.*)/', $line, $matches);
|
||||||
|
$lineNumber = $matches[1];
|
||||||
|
$result = $matches[2];
|
||||||
|
if (!empty($lineNumber) && !empty($result)) { //if complete result...
|
||||||
|
$parsed[$lineNumber][] = $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $parsed;
|
||||||
|
}
|
||||||
|
|
||||||
function cut_string($string, $length = 1024) {
|
function cut_string($string, $length = 1024) {
|
||||||
if (strlen($string) > $length) {
|
if (strlen($string) > $length) {
|
||||||
return substr($string, 0, $length);
|
return substr($string, 0, $length);
|
||||||
|
@ -82,14 +104,17 @@
|
||||||
|
|
||||||
echo "<h3>Output</h3>\n";
|
echo "<h3>Output</h3>\n";
|
||||||
|
|
||||||
$lines = get_democlient_outout($code);
|
$output = get_democlient_output($code);
|
||||||
foreach ($lines as $line) { //for each output line...
|
$report = parse_democlient_output($output);
|
||||||
$line = trim($line);
|
|
||||||
if (empty($line)) { //if empty line...
|
echo "<dl>\n";
|
||||||
continue;
|
foreach ($report as $lineNumber => $results) { //for each line results...
|
||||||
|
echo " <dt>Line $lineNumber:</dt>\n";
|
||||||
|
foreach ($results as $result) { //for each results...
|
||||||
|
echo " <dd>" . htmlspecialchars($result) . "</dd>\n";
|
||||||
}
|
}
|
||||||
echo "<p>" . htmlspecialchars($line) . "</p>\n";
|
|
||||||
}
|
}
|
||||||
|
echo "</dl>\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo "<p>Use the <a href=\"/demo/\">online demo</a> page to create the report.</p>\n";
|
echo "<p>Use the <a href=\"/demo/\">online demo</a> page to create the report.</p>\n";
|
||||||
|
|
|
@ -6,6 +6,10 @@ body {
|
||||||
background: #eee;
|
background: #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dt {
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
|
||||||
/* Default link style */
|
/* Default link style */
|
||||||
a:link { color:#036; text-decoration:underline; }
|
a:link { color:#036; text-decoration:underline; }
|
||||||
a:visited { color:#036; text-decoration:underline; }
|
a:visited { color:#036; text-decoration:underline; }
|
||||||
|
|
Loading…
Reference in New Issue