diff --git a/po/perl/check-accelerator-conflicts.pl b/po/perl/check-accelerator-conflicts.pl index 069a2f41f..e617cda9d 100755 --- a/po/perl/check-accelerator-conflicts.pl +++ b/po/perl/check-accelerator-conflicts.pl @@ -7,7 +7,7 @@ use Locale::PO qw(); use Getopt::Long qw(GetOptions :config bundling gnu_compat); use autouse 'Pod::Usage' => qw(pod2usage); -my $VERSION = "1.0"; +my $VERSION = "1.1"; sub show_version { @@ -16,7 +16,9 @@ sub show_version -exitval => 0}); } -sub check_po_file +my $Accelerator_tag; + +sub check_po_file ($) { my($po_file_name) = @_; my %contexts; @@ -32,7 +34,7 @@ sub check_po_file next if $po->fuzzy(); my $msgstr = $po->msgstr() or next; - my($accelerator) = ($msgstr =~ /~(.)/) + my($accelerator) = ($msgstr =~ /\Q$Accelerator_tag\E(.)/s) or next; $accelerator = uc($accelerator); my $automatic = $po->automatic() @@ -56,10 +58,20 @@ sub check_po_file return $warnings ? 1 : 0; } -GetOptions("help" => sub { pod2usage({-verbose => 1, -exitval => 0}) }, +GetOptions("accelerator-tag=s" => sub { + my($option, $value) = @_; + die "Cannot use multiple --accelerator-tag options\n" + if defined($Accelerator_tag); + die "--accelerator-tag requires a single-character argument\n" + if length($value) != 1; + $Accelerator_tag = $value; + }, + "help" => sub { pod2usage({-verbose => 1, -exitval => 0}) }, "version" => \&show_version) or exit 2; +$Accelerator_tag = "~" unless defined $Accelerator_tag; print(STDERR "$0: missing file operand\n"), exit 2 unless @ARGV; + my $max_error = 0; foreach my $po_file_name (@ARGV) { my $error = check_po_file($po_file_name); @@ -76,19 +88,7 @@ accelerator keys. =head1 SYNOPSIS -B F.po> [...] - -=head1 ARGUMENTS - -=over - -=item F.po> [...] - -The PO files to be scanned for conflicts. These files must include the -"accelerator_context" comments added by B. -If the special comments are missing, no conflicts will be found. - -=back +B [I