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.
This commit is contained in:
acli 2004-02-24 14:20:46 +00:00
parent e4cc939d48
commit f6fa24c75d
2 changed files with 11 additions and 4 deletions

View file

@ -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 <MODULE>/POTFILES.in
for my $input (@in_files) {

View file

@ -291,10 +291,11 @@ if (defined $files_from) {
open(INPUT, "<$files_from") || die "$files_from: $!\n";
while (<INPUT>) {
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;