RELEASE/1.2debug-cidebug-ci-sanitisersfaster-cavernloglog-selectstereowalls-datawalls-data-hanging-as-warningwarn-only-for-hanging-survey
Last change
on this file since 486c619 was
f4c18a9,
checked in by Olly Betts <olly@…>, 11 years ago
|
lib/checkshortcut.pl: Fix shortcut checking to allow for non-ASCII
shortcuts.
|
-
Property mode set to
100755
|
File size:
1.4 KB
|
Rev | Line | |
---|
[46cb98f] | 1 | #!/usr/bin/perl -w |
---|
[be891ea] | 2 | require 5.008; |
---|
| 3 | use bytes; |
---|
[46cb98f] | 4 | use strict; |
---|
[be891ea] | 5 | |
---|
[46cb98f] | 6 | my %menu = (); |
---|
[aceb53e] | 7 | my $srcdir = $ENV{'srcdir'} || ''; |
---|
| 8 | $srcdir .= '/' if $srcdir; |
---|
[6deca30] | 9 | |
---|
| 10 | open I, "<$srcdir../src/mainfrm.cc" or die $!; |
---|
[46cb98f] | 11 | while (<I>) { |
---|
[2b65003] | 12 | m!(\w+)->Append[A-Za-z]*\(.*\(/\*.*?\*/(\d+)! && push @{$menu{$1}}, $2; |
---|
[46cb98f] | 13 | } |
---|
| 14 | close I; |
---|
| 15 | |
---|
[2b65003] | 16 | #for (sort keys %menu) { print "$_:".join("|", @{$menu{$_}})."\n" } |
---|
| 17 | |
---|
[6deca30] | 18 | my $exitcode = 0; |
---|
[46cb98f] | 19 | for my $lang (@ARGV) { |
---|
[6deca30] | 20 | $lang =~ s/\.msg$//; # allow en or en.msg |
---|
| 21 | my $hdr = "Lang $lang:\n"; |
---|
| 22 | # .msg files could be in srcdir or build directory when building outside |
---|
| 23 | # the source tree |
---|
| 24 | open L, "<$srcdir$lang.msg" or open L, "<$lang.msg" or die $!; |
---|
[46cb98f] | 25 | my $buf; |
---|
| 26 | read L, $buf, 20; |
---|
| 27 | read L, $buf, 999999; |
---|
| 28 | close L; |
---|
| 29 | my @msg = split /\0/, $buf; |
---|
| 30 | for my $menu (sort keys %menu) { |
---|
| 31 | my %sc = (); |
---|
| 32 | my $bad = 0; |
---|
| 33 | for (@{$menu{$menu}}) { |
---|
[f4c18a9] | 34 | my ($acc) = ($msg[$_] =~ /\&([\x00-\x7f]|[\xc2-\xdf].|[\xe0-\xef]..|[\xf0-\xf4]...)/); |
---|
[206c976] | 35 | if (!defined $acc) { |
---|
| 36 | print "Lang $lang : message $_ '$msg[$_]' has no shortcut\n"; |
---|
[46cb98f] | 37 | } else { |
---|
[206c976] | 38 | $acc = lc $acc; |
---|
| 39 | if (exists $sc{$acc}) { |
---|
| 40 | if (defined $hdr) { |
---|
| 41 | print $hdr; |
---|
| 42 | $hdr = undef; |
---|
| 43 | } |
---|
| 44 | print "Menu $menu : '$msg[$sc{$acc}]' and '$msg[$_]' both use shortcut '$acc'\n"; |
---|
| 45 | $bad = 1; |
---|
| 46 | } else { |
---|
| 47 | $sc{$acc} = $_; |
---|
| 48 | } |
---|
[46cb98f] | 49 | } |
---|
| 50 | } |
---|
| 51 | if ($bad) { |
---|
| 52 | print "Unused letters: ", grep {!exists $sc{$_}} ('a' .. 'z'), "\n"; |
---|
[6deca30] | 53 | $exitcode = 1; |
---|
[46cb98f] | 54 | } |
---|
| 55 | } |
---|
[6deca30] | 56 | print "\n" unless defined $hdr; |
---|
[46cb98f] | 57 | } |
---|
[6deca30] | 58 | exit $exitcode; |
---|
Note: See
TracBrowser
for help on using the repository browser.