From f6fa24c75d3033ec442ec33309aaa8c7377b5e70 Mon Sep 17 00:00:00 2001 From: acli Date: Tue, 24 Feb 2004 14:20:46 +0000 Subject: [PATCH] tmpl_process3.pl did not know how to handle absolute pathnames in -i. (Actually, xgettext.pl did not know how to handle them in the files listed in the list of files.) If the po file is empty (corrupted), $href->{'""'} will be undefined. We just blindly dereferenced this null value without checking. --- misc/translator/tmpl_process3.pl | 8 +++++++- misc/translator/xgettext.pl | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl index 788757781b..6942351081 100755 --- a/misc/translator/tmpl_process3.pl +++ b/misc/translator/tmpl_process3.pl @@ -221,6 +221,8 @@ $href = Locale::PO->load_file_ashash($str_file); # guess the charsets. HTML::Templates defaults to iso-8859-1 if (defined $href) { + die "$str_file: PO file is corrupted, or not a PO file\n" + unless defined $href->{'""'}; $charset_out = TmplTokenizer::charset_canon $2 if $href->{'""'}->msgstr =~ /\bcharset=(["']?)([^;\s"'\\]+)\1/; for my $msgid (keys %$href) { @@ -241,7 +243,11 @@ my $xgettext = './xgettext.pl'; # actual text extractor script if ($action eq 'create') { # updates the list. As the list is empty, every entry will be added - die "$str_file: Output file already exists" if -f $str_file; + if (!-s $str_file) { + warn "Removing empty file $str_file\n"; + unlink $str_file || die "$str_file: $!\n"; + } + die "$str_file: Output file already exists\n" if -f $str_file; my($tmph, $tmpfile) = tmpnam(); # Generate the temporary file that acts as /POTFILES.in for my $input (@in_files) { diff --git a/misc/translator/xgettext.pl b/misc/translator/xgettext.pl index 1599591477..18d75e84b3 100755 --- a/misc/translator/xgettext.pl +++ b/misc/translator/xgettext.pl @@ -291,10 +291,11 @@ if (defined $files_from) { open(INPUT, "<$files_from") || die "$files_from: $!\n"; while () { chomp; - my $h = TmplTokenizer->new( "$directory/$_" ); + my $input = /^\//? $_: "$directory/$_"; + my $h = TmplTokenizer->new( $input ); $h->set_allow_cformat( 1 ); - VerboseWarnings::set_input_file_name "$directory/$_"; - print STDERR "$0: Processing file \"$directory/$_\"\n" if $verbose_p; + VerboseWarnings::set_input_file_name $input; + print STDERR "$0: Processing file \"$input\"\n" if $verbose_p; text_extract( $h ); } close INPUT; -- 2.39.5