Add line numbers to error messages.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38266 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2011-04-05 22:36:30 +00:00
parent 89bb06a23e
commit ff6680a99d

View File

@ -67,6 +67,7 @@ foreach my $pofilename ( @ARGV )
my ($msgid, $msgstr, $more); my ($msgid, $msgstr, $more);
while ($i <= $noOfLines) { while ($i <= $noOfLines) {
my $linenum = $i;
( $msgid ) = ( $pofile[$i] =~ m/^msgid "(.*)"/ ); ( $msgid ) = ( $pofile[$i] =~ m/^msgid "(.*)"/ );
$i++; $i++;
next unless $msgid; next unless $msgid;
@ -98,13 +99,13 @@ foreach my $pofilename ( @ARGV )
my $n = 0; my $n = 0;
foreach my $arg (@argstrs) { $n = $arg if $arg > $n; } foreach my $arg (@argstrs) { $n = $arg if $arg > $n; }
if ($n <= 0) { if ($n <= 0) {
print "Problem finding arguments in:\n $msgid!\n"; print "Problem finding arguments in:\n $msgid!\non line $linenum.\n";
$warn++; $warn++;
} else { } else {
foreach my $i (1..$n) { foreach my $i (1..$n) {
my $arg = "%$i\\\$s"; my $arg = "%$i\\\$s";
if ( $msgstr !~ m/$arg/ ) { if ( $msgstr !~ m/$arg/ ) {
print "Missing argument `$arg'\n '$msgid' ==> '$msgstr'\n"; print "Line $linenum: Missing argument `$arg'\n '$msgid' ==> '$msgstr'\n";
$warn++; $warn++;
} }
} }
@ -115,7 +116,7 @@ foreach my $pofilename ( @ARGV )
if ($check_colons) { if ($check_colons) {
# Check colon at the end of a message # Check colon at the end of a message
if ( ( $msgid =~ m/: *(\|.*)?$/ ) != ( $msgstr =~ m/: *(\|.*)?$/ ) ) { if ( ( $msgid =~ m/: *(\|.*)?$/ ) != ( $msgstr =~ m/: *(\|.*)?$/ ) ) {
print( "Missing or unexpected colon:\n" ); print( "Line $linenum: Missing or unexpected colon:\n" );
print( " '$msgid' => '$msgstr'\n" ); print( " '$msgid' => '$msgstr'\n" );
$warn++; $warn++;
} }
@ -124,7 +125,7 @@ foreach my $pofilename ( @ARGV )
if ($check_periods) { if ($check_periods) {
# Check period at the end of a message; uncomment code if you are paranoid # Check period at the end of a message; uncomment code if you are paranoid
if ( ( $msgid =~ m/\. *(\|.*)?$/ ) != ( $msgstr =~ m/\. *(\|.*)?$/ ) ) { if ( ( $msgid =~ m/\. *(\|.*)?$/ ) != ( $msgstr =~ m/\. *(\|.*)?$/ ) ) {
print( "Missing or unexpected period:\n" ); print( "Line $linenum: Missing or unexpected period:\n" );
print( " '$msgid' => '$msgstr'\n" ); print( " '$msgid' => '$msgstr'\n" );
$warn++; $warn++;
} }
@ -133,7 +134,7 @@ foreach my $pofilename ( @ARGV )
if ($check_spaces) { if ($check_spaces) {
# Check space at the end of a message # Check space at the end of a message
if ( ( $msgid =~ m/ *?(\|.*)?$/ ) != ( $msgstr =~ m/ *?(\|.*)?$/ ) ) { if ( ( $msgid =~ m/ *?(\|.*)?$/ ) != ( $msgstr =~ m/ *?(\|.*)?$/ ) ) {
print( "Missing or unexpected space:\n" ); print( "Line $linenum: Missing or unexpected space:\n" );
print( " '$msgid' => '$msgstr'\n" ); print( " '$msgid' => '$msgstr'\n" );
$warn++; $warn++;
} }
@ -142,7 +143,7 @@ foreach my $pofilename ( @ARGV )
if ($check_qt) { if ($check_qt) {
# Check for "&" shortcuts # Check for "&" shortcuts
if ( ( $msgid =~ m/&[^ ]/ ) != ( $msgstr =~ m/&[^ ]/ ) ) { if ( ( $msgid =~ m/&[^ ]/ ) != ( $msgstr =~ m/&[^ ]/ ) ) {
print( "Missing or unexpected Qt shortcut:\n" ); print( "Line $linenum: Missing or unexpected Qt shortcut:\n" );
print( " '$msgid' => '$msgstr'\n" ); print( " '$msgid' => '$msgstr'\n" );
$warn++; $warn++;
} }
@ -151,7 +152,7 @@ foreach my $pofilename ( @ARGV )
if ($check_menu) { if ($check_menu) {
# Check for "|..." shortcuts # Check for "|..." shortcuts
if ( ( $msgid =~ m/\|[^ ]/ ) != ( $msgstr =~ m/\|[^ ]/ ) ) { if ( ( $msgid =~ m/\|[^ ]/ ) != ( $msgstr =~ m/\|[^ ]/ ) ) {
print( "Missing or unexpected menu shortcut:\n" ); print( "Line $linenum: Missing or unexpected menu shortcut:\n" );
print( " '$msgid' => '$msgstr'\n" ); print( " '$msgid' => '$msgstr'\n" );
$warn++; $warn++;
} }