diff options
Diffstat (limited to 'find-lang.pl')
-rwxr-xr-x | find-lang.pl | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/find-lang.pl b/find-lang.pl index e1f0f47..571ab1c 100755 --- a/find-lang.pl +++ b/find-lang.pl @@ -21,7 +21,7 @@ GetOptions( my ($buildroot, @searchname) = @ARGV; $buildroot or die "No buildroot given\n"; -$buildroot =~ s:/+$::; # removing trailing / +$buildroot =~ s!/+$!!; # removing trailing / my ($pkgname) = @searchname or die "Main name to find missing\n"; sub debug { @@ -37,52 +37,51 @@ File::Find::find( my $file = substr($File::Find::name, length($buildroot)); -f $File::Find::name or -l $File::Find::name or return; debug("next file is %s", $file); - my $langfile = $file; - if ($file =~ m:^((.*/share/locale)/([^/@]+)[^/]*).*/([^/]+)\.mo:) { + if ($file =~ m!^((.*/share/locale)/([^/@]+)[^/]*).*/([^/]+)\.mo!) { if ($withoutmo) { return; } - my ($pkg, $lang, $parent, $langfile) = ($4, $3, $2, $1); + my ($pkg, $lang) = ($4, $3); if (pkg_match($pkg)) { own_file($file, $lang); } - } elsif ($file =~ m:^((.*/gnome/help)/([^/]+)/([^/]+)).*:) { + } elsif ($file =~ m!^((.*/gnome/help)/([^/]+)/([^/]+))!) { if (!$withgnome) { return; } - my ($pkg, $lang, $parent, $langfile) = ($3, $4, $2, $1); + my ($pkg, $lang, $langfile) = ($3, $4, $1); if (pkg_match($pkg)) { parent_to_own($langfile, $file, $lang); } - } elsif ($file =~ m:^((.*/share/help)/([^/]+)/([^/]+))/([^/]+).*:) { + } elsif ($file =~ m!^((.*/share/help)/([^/]+)/([^/]+))/([^/]+)!) { if (!$withhelp) { return; } - my ($pkg, $lang, $parent, $langfile) = ($4, $3, $2, $1); + my ($pkg, $lang, $langfile) = ($4, $3, $1); if (pkg_match($pkg)) { parent_to_own($langfile, $file, $lang); } - } elsif ($file =~ m:^((.*/doc/kde)/HTML/([^/@]+)[^/]*)/([^/]+)/.*:) { + } elsif ($file =~ m!^((.*/doc/kde)/HTML/([^/@]+)[^/]*)/([^/]+)/!) { if (!$withkde) { return; } - my ($pkg, $lang, $parent, $langfile) = ($4, $3, $2, $1); + my ($pkg, $lang, $langfile) = ($4, $3, $1); if (pkg_match($pkg)) { parent_to_own($langfile, $file, $lang); } - } elsif ($file =~ m:^((.*/doc)/HTML/([^/@]+)[^/]*)/([^/_]+).*:) { + } elsif ($file =~ m!^((.*/doc)/HTML/([^/@]+)[^/]*)/([^/_]+)!) { if (!$withhtml) { return; } - my ($pkg, $lang, $parent, $langfile) = ($4, $3, $2, $1); + my ($pkg, $lang, $langfile) = ($4, $3, $1); if (pkg_match($pkg)) { parent_to_own($langfile, $file, $lang); } - } elsif ($file =~ m:^((/+usr/share/man)/([^/@\.]+)[^/]*)/man[^/]+/([^/.]+)\.\d[^/]*:) { + } elsif ($file =~ m!^((/+usr/share/man)/([^/@.]+)[^/]*)/man[^/]+/([^/.]+)\.\d[^/]*!) { if (!$withman) { return; } - my ($pkg, $lang, $parent, $langfile) = ($4, $3, undef, $1); + my ($pkg, $lang, $langfile) = ($4, $3, $1); $file =~ s/\.[^\.]+$//; $file .= '.*'; if (pkg_match($pkg)) { @@ -98,9 +97,9 @@ File::Find::find( open(my $hlang, '>', "$pkgname.lang") or die "cannot open $pkgname.lang\n"; foreach my $f (sort keys %finallist) { - my ($lang, @otherlang) = keys %{ $finallist{$f}{'lang'} || {}}; + my ($lang, @otherlang) = keys %{ $finallist{$f}{lang} || {} }; my $l = sprintf("%s%s%s", - $finallist{$f}{'dir'} ? '%dir ' : '', + $finallist{$f}{dir} ? '%dir ' : '', @otherlang == 0 && $lang && $lang ne 'C' ? "%lang($lang) " : '', # skip if multiple lang, 'C' or dir @@ -117,7 +116,7 @@ exit(0); sub pkg_match { my ($pkg) = @_; - if ($allname) { return 1 }; + return 1 if $allname; if (grep { $_ eq $pkg } @searchname) { return 1; } @@ -126,7 +125,7 @@ sub pkg_match { sub own_file { my ($file, $lang) = @_; - $finallist{$file}{'lang'}{$lang} = 1; + $finallist{$file}{lang}{$lang} = 1; } sub parent_to_own { @@ -135,18 +134,18 @@ sub parent_to_own { if ($allname) { #my @subdir = grep { $_ } split('/', substr($file, length($parent))); #$parent .= '/' . shift(@subdir); - $finallist{$parent}{'lang'}{$lang} = 1; + $finallist{$parent}{lang}{$lang} = 1; debug("Parent %s will be %s", $parent, $lang); } else { my @subdir = grep { $_ } split('/', substr($file, length($parent))); pop(@subdir); $finallist{$parent}{dir} = 1; - $finallist{$parent}{'lang'}{$lang} = 1; + $finallist{$parent}{lang}{$lang} = 1; debug("Parent %s will be %s", $parent, $lang); while (my $part = shift(@subdir)) { $parent .= "/$part"; $finallist{$parent}{dir} = 1; - $finallist{$parent}{'lang'}{$lang} = 1; + $finallist{$parent}{lang}{$lang} = 1; debug("Parent %s will be %s", $parent, $lang); } own_file($file, $lang); |