Skip to content

Commit 6040f51

Browse files
committed
new switch --unique to save file of unique files, #711
1 parent 5c43c23 commit 6040f51

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Unix/cloc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ my (
184184
$opt_timeout ,
185185
$opt_html ,
186186
$opt_ignored ,
187+
$opt_unique ,
187188
$opt_counted ,
188189
$opt_show_ext ,
189190
$opt_show_lang ,
@@ -297,6 +298,7 @@ my $getopt_success = GetOptions( # {{{1
297298
"timeout=i" => \$opt_timeout ,
298299
"html" => \$opt_html ,
299300
"ignored=s" => \$opt_ignored ,
301+
"unique=s" => \$opt_unique ,
300302
"quiet" => \$opt_quiet ,
301303
"force_lang_def|force-lang-def=s" => \$opt_force_lang_def ,
302304
"read_lang_def|read-lang-def=s" => \$opt_read_lang_def ,
@@ -402,6 +404,7 @@ load_from_config_file($config_file, # {{{2
402404
\$opt_timeout ,
403405
\$opt_html ,
404406
\$opt_ignored ,
407+
\$opt_unique ,
405408
\$opt_quiet ,
406409
\$opt_force_lang_def ,
407410
\$opt_read_lang_def ,
@@ -1359,6 +1362,8 @@ foreach my $FH (@fh) { # loop over each pair of file sets
13591362
$n_set,
13601363
plural_form(scalar keys %unique_source_file)
13611364
unless $opt_quiet;
1365+
my $suffix = $n_set == 1 ? "L" : "R";
1366+
write_file("${opt_unique}_${suffix}", {}, sort keys %unique_source_file) if $opt_unique;
13621367
}
13631368
# 1}}}
13641369
# Step 6: Count code, comments, blank lines. {{{1
@@ -1618,6 +1623,7 @@ if ($opt_exclude_content) {
16181623
printf "%8d unique file%s. \n",
16191624
plural_form(scalar keys %unique_source_file)
16201625
unless $opt_quiet;
1626+
write_file($opt_unique, {}, sort keys %unique_source_file) if $opt_unique;
16211627
# 1}}}
16221628
# Step 6: Count code, comments, blank lines. {{{1
16231629
#
@@ -14635,6 +14641,7 @@ sub load_from_config_file { # {{{1
1463514641
$rs_timeout ,
1463614642
$rs_html ,
1463714643
$rs_ignored ,
14644+
$rs_unique ,
1463814645
$rs_quiet ,
1463914646
$rs_force_lang_def ,
1464014647
$rs_read_lang_def ,
@@ -14746,6 +14753,7 @@ sub load_from_config_file { # {{{1
1474614753
} elsif (!defined ${$rs_timeout} and /^timeout(=|\s+)i/) { ${$rs_timeout} = $1;
1474714754
} elsif (!defined ${$rs_html} and /^html/) { ${$rs_html} = 1;
1474814755
} elsif (!defined ${$rs_ignored} and /^ignored(=|\s+)(.*?)$/) { ${$rs_ignored} = $2;
14756+
} elsif (!defined ${$rs_unique} and /^unique(=|\s+)(.*?)$/) { ${$rs_unique} = $2;
1474914757
} elsif (!defined ${$rs_quiet} and /^quiet/) { ${$rs_quiet} = 1;
1475014758
} elsif (!defined ${$rs_force_lang_def} and /^(?:force_lang_def|force-lang-def)(=|\s+)(.*?)$/) { ${$rs_force_lang_def} = $2;
1475114759
} elsif (!defined ${$rs_read_lang_def} and /^(?:read_lang_def|read-lang-def)(=|\s+)(.*?)$/) { ${$rs_read_lang_def} = $2;

cloc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ my (
185185
$opt_timeout ,
186186
$opt_html ,
187187
$opt_ignored ,
188+
$opt_unique ,
188189
$opt_counted ,
189190
$opt_show_ext ,
190191
$opt_show_lang ,
@@ -298,6 +299,7 @@ my $getopt_success = GetOptions( # {{{1
298299
"timeout=i" => \$opt_timeout ,
299300
"html" => \$opt_html ,
300301
"ignored=s" => \$opt_ignored ,
302+
"unique=s" => \$opt_unique ,
301303
"quiet" => \$opt_quiet ,
302304
"force_lang_def|force-lang-def=s" => \$opt_force_lang_def ,
303305
"read_lang_def|read-lang-def=s" => \$opt_read_lang_def ,
@@ -403,6 +405,7 @@ load_from_config_file($config_file, # {{{2
403405
\$opt_timeout ,
404406
\$opt_html ,
405407
\$opt_ignored ,
408+
\$opt_unique ,
406409
\$opt_quiet ,
407410
\$opt_force_lang_def ,
408411
\$opt_read_lang_def ,
@@ -1349,6 +1352,8 @@ foreach my $FH (@fh) { # loop over each pair of file sets
13491352
$n_set,
13501353
plural_form(scalar keys %unique_source_file)
13511354
unless $opt_quiet;
1355+
my $suffix = $n_set == 1 ? "L" : "R";
1356+
write_file("${opt_unique}_${suffix}", {}, sort keys %unique_source_file) if $opt_unique;
13521357
}
13531358
# 1}}}
13541359
# Step 6: Count code, comments, blank lines. {{{1
@@ -1608,6 +1613,7 @@ if ($opt_exclude_content) {
16081613
printf "%8d unique file%s. \n",
16091614
plural_form(scalar keys %unique_source_file)
16101615
unless $opt_quiet;
1616+
write_file($opt_unique, {}, sort keys %unique_source_file) if $opt_unique;
16111617
# 1}}}
16121618
# Step 6: Count code, comments, blank lines. {{{1
16131619
#
@@ -14625,6 +14631,7 @@ sub load_from_config_file { # {{{1
1462514631
$rs_timeout ,
1462614632
$rs_html ,
1462714633
$rs_ignored ,
14634+
$rs_unique ,
1462814635
$rs_quiet ,
1462914636
$rs_force_lang_def ,
1463014637
$rs_read_lang_def ,
@@ -14736,6 +14743,7 @@ sub load_from_config_file { # {{{1
1473614743
} elsif (!defined ${$rs_timeout} and /^timeout(=|\s+)i/) { ${$rs_timeout} = $1;
1473714744
} elsif (!defined ${$rs_html} and /^html/) { ${$rs_html} = 1;
1473814745
} elsif (!defined ${$rs_ignored} and /^ignored(=|\s+)(.*?)$/) { ${$rs_ignored} = $2;
14746+
} elsif (!defined ${$rs_unique} and /^unique(=|\s+)(.*?)$/) { ${$rs_unique} = $2;
1473914747
} elsif (!defined ${$rs_quiet} and /^quiet/) { ${$rs_quiet} = 1;
1474014748
} elsif (!defined ${$rs_force_lang_def} and /^(?:force_lang_def|force-lang-def)(=|\s+)(.*?)$/) { ${$rs_force_lang_def} = $2;
1474114749
} elsif (!defined ${$rs_read_lang_def} and /^(?:read_lang_def|read-lang-def)(=|\s+)(.*?)$/) { ${$rs_read_lang_def} = $2;

0 commit comments

Comments
 (0)