line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
########################################### |
2
|
|
|
|
|
|
|
# File::Comments::Plugin::C |
3
|
|
|
|
|
|
|
# 2005, Mike Schilli |
4
|
|
|
|
|
|
|
########################################### |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
########################################### |
7
|
|
|
|
|
|
|
package File::Comments::Plugin::C; |
8
|
|
|
|
|
|
|
########################################### |
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
47
|
use strict; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
301
|
|
11
|
9
|
|
|
9
|
|
47
|
use warnings; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
219
|
|
12
|
9
|
|
|
9
|
|
52
|
use File::Comments::Plugin; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
212
|
|
13
|
9
|
|
|
9
|
|
56
|
use Log::Log4perl qw(:easy); |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
98
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
16
|
|
|
|
|
|
|
our @ISA = qw(File::Comments::Plugin); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
########################################### |
19
|
|
|
|
|
|
|
sub init { |
20
|
|
|
|
|
|
|
########################################### |
21
|
11
|
|
|
11
|
0
|
27
|
my($self) = @_; |
22
|
|
|
|
|
|
|
|
23
|
11
|
|
|
|
|
85
|
$self->register_suffix(".c"); |
24
|
11
|
|
|
|
|
45
|
$self->register_suffix(".cpp"); |
25
|
11
|
|
|
|
|
45
|
$self->register_suffix(".cc"); |
26
|
11
|
|
|
|
|
45
|
$self->register_suffix(".CC"); |
27
|
11
|
|
|
|
|
42
|
$self->register_suffix(".C"); |
28
|
11
|
|
|
|
|
44
|
$self->register_suffix(".h"); |
29
|
11
|
|
|
|
|
41
|
$self->register_suffix(".H"); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
########################################### |
33
|
|
|
|
|
|
|
sub type { |
34
|
|
|
|
|
|
|
########################################### |
35
|
0
|
|
|
0
|
0
|
0
|
my($self, $target) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
return "c"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
########################################### |
41
|
|
|
|
|
|
|
sub comments { |
42
|
|
|
|
|
|
|
########################################### |
43
|
2
|
|
|
2
|
0
|
16
|
my($self, $target) = @_; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
45
|
return $self->extract_c_comments($target); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
########################################### |
49
|
|
|
|
|
|
|
sub stripped { |
50
|
|
|
|
|
|
|
########################################### |
51
|
1
|
|
|
1
|
0
|
3
|
my($self, $target) = @_; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
5
|
return $self->strip_c_comments($target); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
########################################### |
57
|
|
|
|
|
|
|
sub extract_c_comments { |
58
|
|
|
|
|
|
|
########################################### |
59
|
4
|
|
|
4
|
0
|
12
|
my($self, $target) = @_; |
60
|
|
|
|
|
|
|
|
61
|
4
|
|
|
|
|
9
|
my @comments = (); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# This will get confused with c strings containing things |
64
|
|
|
|
|
|
|
# like "/*", but good enough for now until we can hook in a full |
65
|
|
|
|
|
|
|
# C parser/preprocessor. |
66
|
4
|
|
|
|
|
54
|
while($target->{content} =~ |
67
|
|
|
|
|
|
|
m#/\*(.*?)\*/| |
68
|
|
|
|
|
|
|
//(.*?)$ |
69
|
|
|
|
|
|
|
#mxsg) { |
70
|
17
|
100
|
|
|
|
122
|
push @comments, defined $1 ? $1 : $2; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
4
|
|
|
|
|
48
|
return \@comments; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
########################################### |
77
|
|
|
|
|
|
|
sub strip_c_comments { |
78
|
|
|
|
|
|
|
########################################### |
79
|
1
|
|
|
1
|
0
|
2
|
my($self, $target) = @_; |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
4
|
my @comments = (); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# This will get confused with c strings containing things |
84
|
|
|
|
|
|
|
# like "/*", but good enough for now until we can hook in a full |
85
|
|
|
|
|
|
|
# C parser/preprocessor. |
86
|
1
|
|
|
|
|
3
|
my $stripped = $target->{content}; |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
20
|
$stripped =~ |
89
|
|
|
|
|
|
|
s#^\s*/\*.*?\*/(\s*\n)?| |
90
|
|
|
|
|
|
|
/\*.*?\*/| |
91
|
|
|
|
|
|
|
^\s*//.*?\n| |
92
|
|
|
|
|
|
|
\s*//.*?$ |
93
|
|
|
|
|
|
|
##mxsg; |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
6
|
return $stripped; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |