forked from manicki/psi-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vera++2cppcheck.pl
executable file
·55 lines (41 loc) · 1.1 KB
/
vera++2cppcheck.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl
use utf8;
# Simple script for converting vera++ output into cppcheck output format (so that
# vera++ can used with Jenkins).
print_intro();
while (my $line=<STDIN>) {
chomp $line;
if (my ($file_path, $line_number, $error_code, $comment) =
($line =~ m{ ^ \./ ([^:]+)
: (\d+)
: \s* \( ([^\)]+) \)
\s+ (.*) $}x)) {
generate($file_path, $line_number, $error_code, $comment);
} else {
generate('vera++2cppcheck.pl', 1, 'X000', 'vera++2cppcheck.pl failed');
}
}
print_outro();
sub generate {
my ($file_path, $line_number, $error_code, $comment) = @_;
$comment = quote($comment);
print qq{<error file="$file_path" line="$line_number" id="$error_code" severity="style" msg="$comment"/>\n};
}
sub quote {
my ($t) = @_;
$t =~ s/\&/\&/g;
$t =~ s/</\</g;
$t =~ s/"/\&qt;/g;
return $t;
}
sub print_intro {
print <<'END_OF_INTRO';
<?xml version="1.0" encoding="UTF-8"?>
<results>
END_OF_INTRO
}
sub print_outro {
print << 'END_OF_OUTRO';
</results>
END_OF_OUTRO
}