Skip to content

Commit

Permalink
identify non-Glade .ui files as 'XML (Qt/GTK)', #857
Browse files Browse the repository at this point in the history
instead of 'Qt'
  • Loading branch information
AlDanial committed Oct 10, 2024
1 parent 9c96340 commit 2580c5a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 20 deletions.
20 changes: 10 additions & 10 deletions Unix/cloc
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ my %Extension_Collision = (
'Perl/Prolog' => [ 'pl', 'PL' ] ,
'PHP/Pascal/Fortran/Pawn' => [ 'inc' ] ,
'Raku/Prolog' => [ 'p6', 'P6' ] ,
'Qt/Glade' => [ 'ui' ] ,
'XML-Qt-GTK/Glade' => [ 'ui' ] ,
'TypeScript/Qt Linguist' => [ 'ts' ] ,
'Verilog-SystemVerilog/Coq' => [ 'v' ] ,
'Visual Basic/TeX/Apex Class' => [ 'cls' ] ,
Expand Down Expand Up @@ -5249,9 +5249,9 @@ sub print_language_info { # {{{1
delete $extensions{'TypeScript/Qt Linguist'};
}
if (!$language or $language =~ /^(Qt|Glade)$/) {
push @{$extensions{'Glade'}} , "ui";
push @{$extensions{'Qt'}} , "ui";
delete $extensions{'Qt/Glade'};
push @{$extensions{'Glade'}} , "ui";
push @{$extensions{'XML-Qt-GTK'}} , "ui";
delete $extensions{'XML-Qt-GTK/Glade'};
}
if (!$language or $language =~ /^(C#|Smalltalk)$/) {
push @{$extensions{'C#'}} , "cs";
Expand Down Expand Up @@ -5455,7 +5455,7 @@ sub replace_git_hash_with_tarfile { # {{{1
my @left_files = ();
my @right_files = ();
if ($opt_git_diff_rel) {
# Strategy 1: Union files are what git consinders have changed
# Strategy 1: Union files are what git considers have changed
# between the two commits.
my $git_list_cmd = "git -c \"safe.directory=*\" diff-tree -r --no-commit-id --name-only $Left $Right";
# print "$git_list_cmd\n" if $opt_v;
Expand Down Expand Up @@ -6604,7 +6604,7 @@ sub classify_file { # {{{1
}
} elsif ($Language_by_Extension{$extension} eq 'TypeScript/Qt Linguist') {
return TypeScript_or_QtLinguist( $full_file, $rh_Err, $raa_errors);
} elsif ($Language_by_Extension{$extension} eq 'Qt/Glade') {
} elsif ($Language_by_Extension{$extension} eq 'XML-Qt-GTK/Glade') {
return Qt_or_Glade( $full_file, $rh_Err, $raa_errors);
} elsif ($Language_by_Extension{$extension} eq 'C#/Smalltalk') {
my $L = Csharp_or_Smalltalk( $full_file, $rh_Err, $raa_errors);
Expand Down Expand Up @@ -9247,7 +9247,7 @@ sub set_constants { # {{{1
'twig' => 'Twig' ,
'typ' => 'Typst' ,
'um' => 'Umka' ,
'ui' => 'Qt/Glade' ,
'ui' => 'XML-Qt-GTK/Glade' ,
'glade' => 'Glade' ,
'vala' => 'Vala' ,
'vapi' => 'Vala Header' ,
Expand Down Expand Up @@ -10608,7 +10608,7 @@ sub set_constants { # {{{1
[ 'call_regexp_common' , 'C++' ],
[ 'remove_inline' , '//.*$' ],
],
'Qt' => [
'XML (Qt/GTK)' => [
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
],
Expand Down Expand Up @@ -11642,7 +11642,7 @@ sub set_constants { # {{{1
'Puppet' => 2.00,
'PureScript' => 2.00,
'QML' => 1.25,
'Qt' => 2.00,
'XML (Qt/GTK)' => 2.00,
'Qt Linguist' => 1.00,
'Qt Project' => 1.00,
'R' => 3.00,
Expand Down Expand Up @@ -12605,7 +12605,7 @@ sub Qt_or_Glade { # {{{1
if ($glade_points > $qt_points) {
$lang = "Glade";
} else {
$lang = "Qt";
$lang = "XML (Qt/GTK)";
}
print "<- Qt_or_Glade\n" if $opt_v > 2;
return $lang;
Expand Down
5 changes: 5 additions & 0 deletions Unix/t/00_C.t
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,11 @@ my @Tests = (
'ref' => '../tests/outputs/XML.xml.yaml',
'args' => '../tests/inputs/XML.xml',
},
{
'name' => 'XML (Qt/GTK)',
'ref' => '../tests/outputs/BoxWidget.ui.yaml',
'args' => '../tests/inputs/BoxWidget.ui',
},
{
'name' => 'XQuery',
'ref' => '../tests/outputs/pop_by_country.xq.yaml',
Expand Down
20 changes: 10 additions & 10 deletions cloc
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ my %Extension_Collision = (
'Perl/Prolog' => [ 'pl', 'PL' ] ,
'PHP/Pascal/Fortran/Pawn' => [ 'inc' ] ,
'Raku/Prolog' => [ 'p6', 'P6' ] ,
'Qt/Glade' => [ 'ui' ] ,
'XML-Qt-GTK/Glade' => [ 'ui' ] ,
'TypeScript/Qt Linguist' => [ 'ts' ] ,
'Verilog-SystemVerilog/Coq' => [ 'v' ] ,
'Visual Basic/TeX/Apex Class' => [ 'cls' ] ,
Expand Down Expand Up @@ -5239,9 +5239,9 @@ sub print_language_info { # {{{1
delete $extensions{'TypeScript/Qt Linguist'};
}
if (!$language or $language =~ /^(Qt|Glade)$/) {
push @{$extensions{'Glade'}} , "ui";
push @{$extensions{'Qt'}} , "ui";
delete $extensions{'Qt/Glade'};
push @{$extensions{'Glade'}} , "ui";
push @{$extensions{'XML-Qt-GTK'}} , "ui";
delete $extensions{'XML-Qt-GTK/Glade'};
}
if (!$language or $language =~ /^(C#|Smalltalk)$/) {
push @{$extensions{'C#'}} , "cs";
Expand Down Expand Up @@ -5445,7 +5445,7 @@ sub replace_git_hash_with_tarfile { # {{{1
my @left_files = ();
my @right_files = ();
if ($opt_git_diff_rel) {
# Strategy 1: Union files are what git consinders have changed
# Strategy 1: Union files are what git considers have changed
# between the two commits.
my $git_list_cmd = "git -c \"safe.directory=*\" diff-tree -r --no-commit-id --name-only $Left $Right";
# print "$git_list_cmd\n" if $opt_v;
Expand Down Expand Up @@ -6594,7 +6594,7 @@ sub classify_file { # {{{1
}
} elsif ($Language_by_Extension{$extension} eq 'TypeScript/Qt Linguist') {
return TypeScript_or_QtLinguist( $full_file, $rh_Err, $raa_errors);
} elsif ($Language_by_Extension{$extension} eq 'Qt/Glade') {
} elsif ($Language_by_Extension{$extension} eq 'XML-Qt-GTK/Glade') {
return Qt_or_Glade( $full_file, $rh_Err, $raa_errors);
} elsif ($Language_by_Extension{$extension} eq 'C#/Smalltalk') {
my $L = Csharp_or_Smalltalk( $full_file, $rh_Err, $raa_errors);
Expand Down Expand Up @@ -9237,7 +9237,7 @@ sub set_constants { # {{{1
'twig' => 'Twig' ,
'typ' => 'Typst' ,
'um' => 'Umka' ,
'ui' => 'Qt/Glade' ,
'ui' => 'XML-Qt-GTK/Glade' ,
'glade' => 'Glade' ,
'vala' => 'Vala' ,
'vapi' => 'Vala Header' ,
Expand Down Expand Up @@ -10598,7 +10598,7 @@ sub set_constants { # {{{1
[ 'call_regexp_common' , 'C++' ],
[ 'remove_inline' , '//.*$' ],
],
'Qt' => [
'XML (Qt/GTK)' => [
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
],
Expand Down Expand Up @@ -11632,7 +11632,7 @@ sub set_constants { # {{{1
'Puppet' => 2.00,
'PureScript' => 2.00,
'QML' => 1.25,
'Qt' => 2.00,
'XML (Qt/GTK)' => 2.00,
'Qt Linguist' => 1.00,
'Qt Project' => 1.00,
'R' => 3.00,
Expand Down Expand Up @@ -12595,7 +12595,7 @@ sub Qt_or_Glade { # {{{1
if ($glade_points > $qt_points) {
$lang = "Glade";
} else {
$lang = "Qt";
$lang = "XML (Qt/GTK)";
}
print "<- Qt_or_Glade\n" if $opt_v > 2;
return $lang;
Expand Down
7 changes: 7 additions & 0 deletions tests/inputs/BoxWidget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="AtbBoxWidget" parent="GtkBox">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
</template>
</interface>
21 changes: 21 additions & 0 deletions tests/outputs/BoxWidget.ui.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.00384879112243652
n_files : 1
n_lines : 7
files_per_second : 259.821842284582
lines_per_second : 1818.75289599207
report_file : ../outputs/BoxWidget.ui.yaml
'XML (Qt/GTK)' :
nFiles: 1
blank: 0
comment: 0
code: 7
SUM:
blank: 0
comment: 0
code: 7
nFiles: 1

0 comments on commit 2580c5a

Please sign in to comment.