Skip to content

Commit 36b9113

Browse files
committed
improve Perl language filter for POD, #929
1 parent 3ef72d5 commit 36b9113

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

Unix/cloc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10899,7 +10899,7 @@ sub set_constants { # {{{1
1089910899
],
1090010900
'Perl' => [ [ 'remove_below' , '^__(END|DATA)__'],
1090110901
[ 'remove_matches' , '^\s*#' ],
10902-
[ 'remove_below_above' , '^=head1', '^=cut' ],
10902+
[ 'remove_below_above' , '^=(?:pod|over|head\d+)', '^=cut' ],
1090310903
[ 'remove_inline' , '#.*$' ],
1090410904
],
1090510905
'PEG' => [

Unix/t/00_C.t

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,11 @@ my @Tests = (
964964
'ref' => '../tests/outputs/pek_example.pek.yaml',
965965
'args' => '../tests/inputs/pek_example.pek',
966966
},
967+
{
968+
'name' => 'Perl',
969+
'ref' => '../tests/outputs/with_pod.pl.yaml',
970+
'args' => '../tests/inputs/with_pod.pl',
971+
},
967972
{
968973
'name' => 'Pest',
969974
'ref' => '../tests/outputs/toml.pest.yaml',

cloc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10891,7 +10891,7 @@ sub set_constants { # {{{1
1089110891
],
1089210892
'Perl' => [ [ 'remove_below' , '^__(END|DATA)__'],
1089310893
[ 'remove_matches' , '^\s*#' ],
10894-
[ 'remove_below_above' , '^=head1', '^=cut' ],
10894+
[ 'remove_below_above' , '^=(?:pod|over|head\d+)', '^=cut' ],
1089510895
[ 'remove_inline' , '#.*$' ],
1089610896
],
1089710897
'PEG' => [

tests/inputs/with_pod.pl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env perl
2+
use warnings;
3+
use strict;
4+
5+
my $a = 43;
6+
=over
7+
this is not code
8+
=cut
9+
print $a, "\n";
10+
11+
my $b = 44;
12+
=pod
13+
also not code
14+
=cut
15+
print $b, "\n";
16+
17+
my $c = 45;
18+
=head3
19+
more docs
20+
=cut
21+
print $c, "\n";
22+
23+
__DATA__
24+
25+
This is yet more non-code

tests/outputs/with_pod.pl.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# github.com/AlDanial/cloc
3+
header :
4+
cloc_url : github.com/AlDanial/cloc
5+
cloc_version : 2.07
6+
elapsed_seconds : 0.00382208824157715
7+
n_files : 1
8+
n_lines : 25
9+
files_per_second : 261.637078161063
10+
lines_per_second : 6540.92695402657
11+
report_file : ../outputs/with_pod.pl.yaml
12+
'Perl' :
13+
nFiles: 1
14+
blank: 5
15+
comment: 11
16+
code: 9
17+
SUM:
18+
blank: 5
19+
comment: 11
20+
code: 9
21+
nFiles: 1

0 commit comments

Comments
 (0)