From c294f1f62393b0ece94f1e6cad0ac3273ade3018 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 5 Apr 2011 22:13:48 +0000 Subject: [PATCH] Use strict and warnings. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38264 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/pocheck.pl | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/po/pocheck.pl b/po/pocheck.pl index 0b2c0eda3c..1c826e1752 100755 --- a/po/pocheck.pl +++ b/po/pocheck.pl @@ -18,23 +18,30 @@ # Invocation: # pocheck.pl po_file po_file ... -foreach $pofilename ( @ARGV ) +use strict; +use warnings; + +my %trans; + +foreach my $pofilename ( @ARGV ) { print "Processing po file '$pofilename'...\n"; open( INPUT, "<$pofilename" ) || die "Cannot read po file '$pofilename'"; - @pofile = ; + my @pofile = ; close( INPUT ); undef( %trans ); keys( %trans ) = 10000; - $noOfLines = $#pofile; + my $noOfLines = $#pofile; + + my $warn = 0; - $warn = 0; + my $i = 0; + my ($msgid, $msgstr, $more); - $i = 0; while ($i <= $noOfLines) { ( $msgid ) = ( $pofile[$i] =~ m/^msgid "(.*)"/ ); $i++; @@ -61,16 +68,16 @@ foreach $pofilename ( @ARGV ) next if ($msgid eq "" or $msgstr eq ""); # Check for matching %1$s, etc. - @argstrs = ( $msgid =~ m/%(\d)\$s/g ); + my @argstrs = ( $msgid =~ m/%(\d)\$s/g ); if (@argstrs) { - $num = 0; - foreach $arg (@argstrs) { $num = $arg if $arg > $num; } - if ($num <= 0) { + my $n = 0; + foreach my $arg (@argstrs) { $n = $arg if $arg > $n; } + if ($n <= 0) { print "Problem finding arguments in:\n $msgid!\n"; $warn++; } else { - foreach $i (1..$num) { - $arg = "%$i\\\$s"; + foreach my $i (1..$n) { + my $arg = "%$i\\\$s"; if ( $msgstr !~ m/$arg/ ) { print "Missing argument `$arg'\n '$msgid' ==> '$msgstr'\n"; $warn++; @@ -117,8 +124,8 @@ foreach $pofilename ( @ARGV ) # we now collect these translations in a hash. # this will allow us to check below if we have translated # anything more than one way. - $msgid_clean = lc($msgid); - $msgstr_clean = lc($msgstr); + my $msgid_clean = lc($msgid); + my $msgstr_clean = lc($msgstr); $msgid_clean =~ s/(.*)\|.*?$/$1/; # strip menu shortcuts $msgstr_clean =~ s/(.*)\|.*?$/$1/; @@ -134,9 +141,9 @@ foreach $pofilename ( @ARGV ) foreach $msgid ( keys %trans ) { # so $ref is a reference to the inner hash. - $ref = $trans{$msgid}; + my $ref = $trans{$msgid}; # @msgstrkeys is an array of the keys of that inner hash. - @msgstrkeys = keys %$ref; + my @msgstrkeys = keys %$ref; # do we have more than one such key? if ( $#msgstrkeys > 0 ) { -- 2.39.2