Changeset 5880
- Timestamp:
- 07/06/09 10:39:27 (3 years ago)
- Location:
- trunk/Locale-Msgfmt
- Files:
-
- 5 edited
-
Changes (modified) (1 diff)
-
lib/Locale/Msgfmt.pm (modified) (1 diff)
-
lib/Locale/Msgfmt/mo.pm (modified) (1 diff)
-
lib/Locale/Msgfmt/po.pm (modified) (2 diffs)
-
t/interface.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Locale-Msgfmt/Changes
r5866 r5880 1 1 Revision history for Locale-Msgfmt 2 3 - some code improvement in open() and opendir() and error handling (SZABGAB) 2 4 3 5 0.10 Jul 5, 2009 -
trunk/Locale-Msgfmt/lib/Locale/Msgfmt.pm
r5866 r5880 73 73 File::Path::mkpath( $hash->{out} ); 74 74 } 75 opendir D, $hash->{in};76 my @list = readdir D;77 closedir D;75 opendir my $D, $hash->{in} or die "Could not open ($hash->{in}) $!"; 76 my @list = readdir $D; 77 closedir $D; 78 78 my @removelist = (); 79 79 if ( $hash->{remove} ) { -
trunk/Locale-Msgfmt/lib/Locale/Msgfmt/mo.pm
r5866 r5880 38 38 my $self = shift; 39 39 my $file = shift; 40 open OUT, ">", $file;41 binmode OUT;42 print OUT Locale::Msgfmt::Utils::from_hex( $self->{magic} );43 print OUT Locale::Msgfmt::Utils::character( $self->{format} );44 print OUT Locale::Msgfmt::Utils::character( $self->{count} );45 print OUT Locale::Msgfmt::Utils::character(28);46 print OUT Locale::Msgfmt::Utils::character( 28 + $self->{count} * 8 );47 print OUT Locale::Msgfmt::Utils::character(0);48 print OUT Locale::Msgfmt::Utils::character(0);40 open my $OUT, ">", $file or die "Could not open ($file) $!"; 41 binmode $OUT; 42 print $OUT Locale::Msgfmt::Utils::from_hex( $self->{magic} ); 43 print $OUT Locale::Msgfmt::Utils::character( $self->{format} ); 44 print $OUT Locale::Msgfmt::Utils::character( $self->{count} ); 45 print $OUT Locale::Msgfmt::Utils::character(28); 46 print $OUT Locale::Msgfmt::Utils::character( 28 + $self->{count} * 8 ); 47 print $OUT Locale::Msgfmt::Utils::character(0); 48 print $OUT Locale::Msgfmt::Utils::character(0); 49 49 50 50 foreach ( @{ $self->{sorted} } ) { 51 51 my $length = length($_); 52 print OUT Locale::Msgfmt::Utils::character($length);53 print OUT Locale::Msgfmt::Utils::character( $self->{free_mem} );52 print $OUT Locale::Msgfmt::Utils::character($length); 53 print $OUT Locale::Msgfmt::Utils::character( $self->{free_mem} ); 54 54 $self->{free_mem} += $length + 1; 55 55 } 56 56 foreach ( @{ $self->{translations} } ) { 57 57 my $length = length($_); 58 print OUT Locale::Msgfmt::Utils::character($length);59 print OUT Locale::Msgfmt::Utils::character( $self->{free_mem} );58 print $OUT Locale::Msgfmt::Utils::character($length); 59 print $OUT Locale::Msgfmt::Utils::character( $self->{free_mem} ); 60 60 $self->{free_mem} += $length + 1; 61 61 } 62 62 foreach ( @{ $self->{sorted} } ) { 63 print OUT Locale::Msgfmt::Utils::null_terminate($_);63 print $OUT Locale::Msgfmt::Utils::null_terminate($_); 64 64 } 65 65 foreach ( @{ $self->{translations} } ) { 66 print OUT Locale::Msgfmt::Utils::null_terminate($_);66 print $OUT Locale::Msgfmt::Utils::null_terminate($_); 67 67 } 68 close OUT;68 close $OUT; 69 69 } 70 70 -
trunk/Locale-Msgfmt/lib/Locale/Msgfmt/po.pm
r5866 r5880 51 51 my $pofile = shift; 52 52 my $mo = $self->{mo}; 53 open F, $pofile;53 open my $F, '<', $pofile or die "Could not open ($pofile) $!"; 54 54 my %h = (); 55 55 my $type; 56 while (< F>) {56 while (<$F>) { 57 57 s/\r\n/\n/; 58 58 if (/^(msgid(?:|_plural)|msgctxt) +"(.*)" *$/) { … … 94 94 } 95 95 $self->add_string( \%h ); 96 close F;96 close $F; 97 97 } 98 98 -
trunk/Locale-Msgfmt/t/interface.t
r5854 r5880 10 10 11 11 sub slurp { 12 open F, shift; 13 binmode F; 12 my $file = shift; 13 open my $F, '<', $file or die "Could not open ($file) $!"; 14 binmode $F; 14 15 my $s = ""; 15 while (< F>) { $s .= $_; }16 close F;16 while (<$F>) { $s .= $_; } 17 close $F; 17 18 return $s; 18 19 }
Note: See TracChangeset
for help on using the changeset viewer.
