Skip to content

Commit

Permalink
remove Regexp::Common call to HTML for Vuejs #876
Browse files Browse the repository at this point in the history
and add detail to -v 5 filter stages
  • Loading branch information
AlDanial committed Dec 10, 2024
1 parent 50b715f commit 0774046
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 15 deletions.
20 changes: 13 additions & 7 deletions Unix/cloc
Original file line number Diff line number Diff line change
Expand Up @@ -7535,7 +7535,7 @@ sub remove_matches { # {{{1
$pattern , # in Perl regular expression (case insensitive)
) = @_;
print "-> remove_matches(pattern=$pattern)\n" if $opt_v > 2;
print "[", join("]\n[", @{$ra_lines}), "]\n" if $opt_v > 4;
print "in: [", join("]\nin: [", @{$ra_lines}), "]\n" if $opt_v > 4;

my @save_lines = ();
foreach (@{$ra_lines}) {
Expand All @@ -7547,7 +7547,7 @@ sub remove_matches { # {{{1
push @save_lines, $_;
}

print "[", join("]\n[", @{$ra_lines}), "]\n" if $opt_v > 4;
print "out: [", join("]\nout: [", @{$ra_lines}), "]\n" if $opt_v > 4;
print "<- remove_matches\n" if $opt_v > 2;
#print "remove_matches returning\n ", join("\n ", @save_lines), "\n";
return @save_lines;
Expand All @@ -7558,7 +7558,7 @@ sub remove_matches_2re { # {{{1
$pattern2, # in Perl regex 2 (case insensitive) to not match prev line
) = @_;
print "-> remove_matches_2re(pattern=$pattern1,$pattern2)\n" if $opt_v > 2;
print "[", join("]\n[", @{$ra_lines}), "]\n" if $opt_v > 4;
print "[", join("]\nin: [", @{$ra_lines}), "]\n" if $opt_v > 4;

my @save_lines = ();
for (my $i = 0; $i < scalar @{$ra_lines}; $i++) {
Expand All @@ -7575,7 +7575,7 @@ sub remove_matches_2re { # {{{1
push @save_lines, $ra_lines->[$i];
}

print "[", join("]\n[", @{$ra_lines}), "]\n" if $opt_v > 4;
print "[", join("]\nout: [", @{$ra_lines}), "]\n" if $opt_v > 4;
print "<- remove_matches_2re\n" if $opt_v > 2;
#print "remove_matches_2re returning\n ", join("\n ", @save_lines), "\n";
return @save_lines;
Expand Down Expand Up @@ -11160,7 +11160,7 @@ sub set_constants { # {{{1
],
'Vuejs Component' => [
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
# [ 'call_regexp_common' , 'HTML' ], # problematic, ref #876
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
Expand Down Expand Up @@ -11993,6 +11993,11 @@ sub call_regexp_common { # {{{1
$all_lines = join("" , @{$ra_lines});
}

{
my @ra_lines = split("\n", $all_lines);
print "in: [", join("]\nin: [", @ra_lines), "]\n" if $opt_v > 4;
}

no strict 'vars';
# otherwise get:
# Global symbol "%RE" requires explicit package name at cloc line xx.
Expand All @@ -12009,9 +12014,10 @@ sub call_regexp_common { # {{{1
# a bogus use of %RE to avoid:
# Name "main::RE" used only once: possible typo at cloc line xx.
print scalar keys %RE if $opt_v < -20;
print "[", join("]\n[", @{$ra_lines}), "]\n" if $opt_v > 4;
my @out = split("\n", $all_lines);
print "out: [", join("]\nout: [", @out), "]\n" if $opt_v > 4;
print "<- call_regexp_common\n" if $opt_v > 2;
return split("\n", $all_lines);
return @out;
} # 1}}}
sub plural_form { # {{{1
# For getting the right plural form on some English nouns.
Expand Down
10 changes: 9 additions & 1 deletion Unix/t/00_C.t
Original file line number Diff line number Diff line change
Expand Up @@ -1309,11 +1309,19 @@ my @Tests = (
'ref' => '../tests/outputs/vs_solution.sln.yaml',
'args' => '../tests/inputs/vs_solution.sln',
},

{
'name' => 'Vuejs Component',
'name' => 'Vuejs Component 1',
'ref' => '../tests/outputs/ItemView.vue.yaml',
'args' => '../tests/inputs/ItemView.vue',
},

{
'name' => 'Vuejs Component 2',
'ref' => '../tests/outputs/issue_876.vue.yaml',
'args' => '../tests/inputs/issue_876.vue',
},

{
'name' => 'Vyper',
'ref' => '../tests/outputs/vyper.vy.yaml',
Expand Down
20 changes: 13 additions & 7 deletions cloc
Original file line number Diff line number Diff line change
Expand Up @@ -7525,7 +7525,7 @@ sub remove_matches { # {{{1
$pattern , # in Perl regular expression (case insensitive)
) = @_;
print "-> remove_matches(pattern=$pattern)\n" if $opt_v > 2;
print "[", join("]\n[", @{$ra_lines}), "]\n" if $opt_v > 4;
print "in: [", join("]\nin: [", @{$ra_lines}), "]\n" if $opt_v > 4;

my @save_lines = ();
foreach (@{$ra_lines}) {
Expand All @@ -7537,7 +7537,7 @@ sub remove_matches { # {{{1
push @save_lines, $_;
}

print "[", join("]\n[", @{$ra_lines}), "]\n" if $opt_v > 4;
print "out: [", join("]\nout: [", @{$ra_lines}), "]\n" if $opt_v > 4;
print "<- remove_matches\n" if $opt_v > 2;
#print "remove_matches returning\n ", join("\n ", @save_lines), "\n";
return @save_lines;
Expand All @@ -7548,7 +7548,7 @@ sub remove_matches_2re { # {{{1
$pattern2, # in Perl regex 2 (case insensitive) to not match prev line
) = @_;
print "-> remove_matches_2re(pattern=$pattern1,$pattern2)\n" if $opt_v > 2;
print "[", join("]\n[", @{$ra_lines}), "]\n" if $opt_v > 4;
print "[", join("]\nin: [", @{$ra_lines}), "]\n" if $opt_v > 4;

my @save_lines = ();
for (my $i = 0; $i < scalar @{$ra_lines}; $i++) {
Expand All @@ -7565,7 +7565,7 @@ sub remove_matches_2re { # {{{1
push @save_lines, $ra_lines->[$i];
}

print "[", join("]\n[", @{$ra_lines}), "]\n" if $opt_v > 4;
print "[", join("]\nout: [", @{$ra_lines}), "]\n" if $opt_v > 4;
print "<- remove_matches_2re\n" if $opt_v > 2;
#print "remove_matches_2re returning\n ", join("\n ", @save_lines), "\n";
return @save_lines;
Expand Down Expand Up @@ -11150,7 +11150,7 @@ sub set_constants { # {{{1
],
'Vuejs Component' => [
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
# [ 'call_regexp_common' , 'HTML' ], # problematic, ref #876
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
Expand Down Expand Up @@ -11983,6 +11983,11 @@ sub call_regexp_common { # {{{1
$all_lines = join("" , @{$ra_lines});
}

{
my @ra_lines = split("\n", $all_lines);
print "in: [", join("]\nin: [", @ra_lines), "]\n" if $opt_v > 4;
}

no strict 'vars';
# otherwise get:
# Global symbol "%RE" requires explicit package name at cloc line xx.
Expand All @@ -11999,9 +12004,10 @@ sub call_regexp_common { # {{{1
# a bogus use of %RE to avoid:
# Name "main::RE" used only once: possible typo at cloc line xx.
print scalar keys %RE if $opt_v < -20;
print "[", join("]\n[", @{$ra_lines}), "]\n" if $opt_v > 4;
my @out = split("\n", $all_lines);
print "out: [", join("]\nout: [", @out), "]\n" if $opt_v > 4;
print "<- call_regexp_common\n" if $opt_v > 2;
return split("\n", $all_lines);
return @out;
} # 1}}}
sub plural_form { # {{{1
# For getting the right plural form on some English nouns.
Expand Down
16 changes: 16 additions & 0 deletions tests/inputs/issue_876.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<div v-loading="loading">
<div>aaa</div>
</div>
</template>
<script>
import(menCommonConstant } from '@/utils/menConstant'
// test
export detault,
name: 'SpecProgramClientNotice',
components: {
vxeTable, //table
menClientInout
}
</script>
<style lang="scss" scoped></style>
21 changes: 21 additions & 0 deletions tests/outputs/issue_876.vue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.03
elapsed_seconds : 0.00376987457275391
n_files : 1
n_lines : 16
files_per_second : 265.260814571212
lines_per_second : 4244.17303313939
report_file : ../tests/outputs/issue_876.vue.yaml
'Vuejs Component' :
nFiles: 1
blank: 0
comment: 1
code: 15
SUM:
blank: 0
comment: 1
code: 15
nFiles: 1

0 comments on commit 0774046

Please sign in to comment.