r39396 - in /trunk/liblocale-msgfmt-perl: Build.PL Changes MANIFEST META.yml debian/changelog lib/Locale/Msgfmt.pm lib/Locale/Msgfmt/Utils.pm lib/Locale/Msgfmt/mo.pm lib/Locale/Msgfmt/po.pm t/00-load.t t/interface.t t/msgfmt.t

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Mon Jul 6 05:50:36 UTC 2009


Author: ryan52-guest
Date: Mon Jul  6 05:50:30 2009
New Revision: 39396

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=39396
Log:
New upstream release

Modified:
    trunk/liblocale-msgfmt-perl/Build.PL
    trunk/liblocale-msgfmt-perl/Changes
    trunk/liblocale-msgfmt-perl/MANIFEST
    trunk/liblocale-msgfmt-perl/META.yml
    trunk/liblocale-msgfmt-perl/debian/changelog
    trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt.pm
    trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/Utils.pm
    trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/mo.pm
    trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/po.pm
    trunk/liblocale-msgfmt-perl/t/00-load.t
    trunk/liblocale-msgfmt-perl/t/interface.t
    trunk/liblocale-msgfmt-perl/t/msgfmt.t

Modified: trunk/liblocale-msgfmt-perl/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/Build.PL?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/Build.PL (original)
+++ trunk/liblocale-msgfmt-perl/Build.PL Mon Jul  6 05:50:30 2009
@@ -9,7 +9,7 @@
     dist_version_from   => 'lib/Locale/Msgfmt.pm',
     build_requires => {
         'Test::More' => 0,
-        $ENV{AUTOMATED_TESTING} ? ('Locale::Maketext::Gettext' => 0) : (),
+        $ENV{AUTOMATED_TESTING} ? ('Locale::Maketext::Gettext' => '1.28') : (),
     },
     add_to_cleanup      => [ 'Locale-Msgfmt-*' ],
     create_makefile_pl => 'traditional',

Modified: trunk/liblocale-msgfmt-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/Changes?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/Changes (original)
+++ trunk/liblocale-msgfmt-perl/Changes Mon Jul  6 05:50:30 2009
@@ -1,4 +1,15 @@
 Revision history for Locale-Msgfmt
+
+0.09    unreleased
+        - still require the newer version of Locale::Maketext::Gettext
+          when running under CPAN Testers
+        - use is_deeply instead of making a string out of the hash and
+          then using is
+        - add Module::Install::Msgfmt. just replace install_share with
+          install_share_with_mofiles in your Makefile.PL.
+        - add remove option to remove the source file(s) and all .pot
+          files if a directory is being processed
+        - add verbose option to print the files that were converted
 
 0.08    Jun 27, 2009
         - again remove the dependency on Locale::Maketext::Gettext,

Modified: trunk/liblocale-msgfmt-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/MANIFEST?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/MANIFEST (original)
+++ trunk/liblocale-msgfmt-perl/MANIFEST Mon Jul  6 05:50:30 2009
@@ -9,7 +9,9 @@
 lib/Locale/Msgfmt/mo.pm
 lib/Locale/Msgfmt/po.pm
 lib/Locale/Msgfmt/Utils.pm
+Makefile.PL
 MANIFEST			This list of files
+META.yml
 README
 t/00-load.t
 t/interface.t
@@ -25,5 +27,3 @@
 t/samples/ja.po
 t/samples/ngettext.mo
 t/samples/ngettext.po
-Makefile.PL
-META.yml

Modified: trunk/liblocale-msgfmt-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/META.yml?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/META.yml (original)
+++ trunk/liblocale-msgfmt-perl/META.yml Mon Jul  6 05:50:30 2009
@@ -1,6 +1,6 @@
 ---
 name: Locale-Msgfmt
-version: 0.08
+version: 0.09
 author:
   - 'Ryan Niebur <ryanryan52 at gmail.com>'
 abstract: Compile .po files to .mo files
@@ -12,16 +12,16 @@
 provides:
   Locale::Msgfmt:
     file: lib/Locale/Msgfmt.pm
-    version: 0.08
+    version: 0.09
   Locale::Msgfmt::Utils:
     file: lib/Locale/Msgfmt/Utils.pm
-    version: 0.08
+    version: 0.09
   Locale::Msgfmt::mo:
     file: lib/Locale/Msgfmt/mo.pm
-    version: 0.08
+    version: 0.09
   Locale::Msgfmt::po:
     file: lib/Locale/Msgfmt/po.pm
-    version: 0.08
+    version: 0.09
 generated_by: Module::Build version 0.33
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html

Modified: trunk/liblocale-msgfmt-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/debian/changelog?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/debian/changelog (original)
+++ trunk/liblocale-msgfmt-perl/debian/changelog Mon Jul  6 05:50:30 2009
@@ -1,3 +1,9 @@
+liblocale-msgfmt-perl (0.09-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Ryan Niebur <ryanryan52 at gmail.com>  Sun, 05 Jul 2009 22:50:19 -0700
+
 liblocale-msgfmt-perl (0.08-1) unstable; urgency=low
 
   * Initial Release. (Closes: #534651)

Modified: trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt.pm?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt.pm (original)
+++ trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt.pm Mon Jul  6 05:50:30 2009
@@ -12,82 +12,91 @@
 
 our @EXPORT = qw/msgfmt/;
 
-our $VERSION = '0.08';
+our $VERSION = '0.09';
 
 sub msgfmt {
-  my $hash = shift;
-  if(!defined($hash)) {
-    die("error: must give input");
-  }
-  if(!(ref($hash) eq "HASH")) {
-    $hash = {in => $hash};
-  }
-  if(!defined($hash->{in}) or !length($hash->{in})) {
-    die("error: must give an input file");
-  }
-  if(! -e $hash->{in}) {
-    die("error: input does not exist");
-  }
-  if(-d $hash->{in}) {
-    return _msgfmt_dir($hash);
-  } else {
-    return _msgfmt($hash);
-  }
+	my $hash = shift;
+	if ( !defined($hash) ) {
+		die("error: must give input");
+	}
+	if ( !( ref($hash) eq "HASH" ) ) {
+		$hash = { in => $hash };
+	}
+	if ( !defined( $hash->{in} ) or !length( $hash->{in} ) ) {
+		die("error: must give an input file");
+	}
+	if ( !-e $hash->{in} ) {
+		die("error: input does not exist");
+	}
+	if ( -d $hash->{in} ) {
+		return _msgfmt_dir($hash);
+	} else {
+		return _msgfmt($hash);
+	}
 }
 
 sub _msgfmt {
-  my $hash = shift;
-  if(! defined($hash->{in})) {
-    die("error: must give an input file");
-  }
-  if(! -f $hash->{in}) {
-    die("error: input file does not exist");
-  }
-  if(! defined($hash->{out})) {
-    if($hash->{in} =~ /\.po$/) {
-      $hash->{out} = $hash->{in};
-      $hash->{out} =~ s/po$/mo/;
-    } else {
-      die("error: must give an output file");
-    }
-  }
-  my $mo = Locale::Msgfmt::mo->new();
-  $mo->initialize();
-  my $po = Locale::Msgfmt::po->new({fuzzy => $hash->{fuzzy}});
-  $po->parse($hash->{in}, $mo);
-  $mo->prepare();
-  $mo->out($hash->{out});
+	my $hash = shift;
+	if ( !defined( $hash->{in} ) ) {
+		die("error: must give an input file");
+	}
+	if ( !-f $hash->{in} ) {
+		die("error: input file does not exist");
+	}
+	if ( !defined( $hash->{out} ) ) {
+		if ( $hash->{in} =~ /\.po$/ ) {
+			$hash->{out} = $hash->{in};
+			$hash->{out} =~ s/po$/mo/;
+		} else {
+			die("error: must give an output file");
+		}
+	}
+	my $mo = Locale::Msgfmt::mo->new();
+	$mo->initialize();
+	my $po = Locale::Msgfmt::po->new( { fuzzy => $hash->{fuzzy} } );
+	$po->parse( $hash->{in}, $mo );
+	$mo->prepare();
+	$mo->out( $hash->{out} );
+	print $hash->{in} . " -> " . $hash->{out} . "\n" if ( $hash->{verbose} );
+	unlink( $hash->{in} ) if ( $hash->{remove} );
 }
 
 sub _msgfmt_dir {
-  my $hash = shift;
-  if(! -d $hash->{in}) {
-    die("error: input directory does not exist");
-  }
-  if(! defined($hash->{out})) {
-    $hash->{out} = $hash->{in};
-  }
-  if(! -d $hash->{out}) {
-    File::Path::mkpath($hash->{out});
-  }
-  opendir D, $hash->{in};
-  my @list = readdir D;
-  closedir D;
-  @list = grep /\.po$/, @list;
-  my %files;
-  foreach(@list) {
-    my $in = File::Spec->catfile($hash->{in}, $_);
-    my $out = File::Spec->catfile($hash->{out}, substr($_, 0, -3) . ".mo");
-    $files{$in} = $out;
-  }
-  delete $hash->{in};
-  delete $hash->{out};
-  foreach(keys %files) {
-    my %newhash = (%{$hash});
-    $newhash{in} = $_;
-    $newhash{out} = $files{$_};
-    _msgfmt(\%newhash);
-  }
+	my $hash = shift;
+	if ( !-d $hash->{in} ) {
+		die("error: input directory does not exist");
+	}
+	if ( !defined( $hash->{out} ) ) {
+		$hash->{out} = $hash->{in};
+	}
+	if ( !-d $hash->{out} ) {
+		File::Path::mkpath( $hash->{out} );
+	}
+	opendir D, $hash->{in};
+	my @list = readdir D;
+	closedir D;
+	my @removelist = ();
+	if ( $hash->{remove} ) {
+		@removelist = grep /\.pot$/, @list;
+	}
+	@list = grep /\.po$/, @list;
+	my %files;
+	foreach (@list) {
+		my $in = File::Spec->catfile( $hash->{in}, $_ );
+		my $out = File::Spec->catfile( $hash->{out}, substr( $_, 0, -3 ) . ".mo" );
+		$files{$in} = $out;
+	}
+	foreach ( keys %files ) {
+		my %newhash = ( %{$hash} );
+		$newhash{in}  = $_;
+		$newhash{out} = $files{$_};
+		_msgfmt( \%newhash );
+	}
+	foreach (@removelist) {
+		my $f = File::Spec->catfile( $hash->{in}, $_ );
+		print "-$f\n" if ( $hash->{verbose} );
+		unlink($f);
+	}
 }
 
 1;

Modified: trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/Utils.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/Utils.pm?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/Utils.pm (original)
+++ trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/Utils.pm Mon Jul  6 05:50:30 2009
@@ -3,54 +3,54 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.08';
+our $VERSION = '0.09';
 
 sub character {
-  return map {pack "N*", $_} @_;
+	return map { pack "N*", $_ } @_;
 }
 
 sub _from_character {
-  return map {ord($_)} @_;
+	return map { ord($_) } @_;
 }
 
 sub from_character {
-  return character(_from_character(@_));
+	return character( _from_character(@_) );
 }
 
 sub _from_hex {
-  return map {hex($_)} @_;
+	return map { hex($_) } @_;
 }
 
 sub from_hex {
-  return character(_from_hex(@_));
+	return character( _from_hex(@_) );
 }
 
 sub _from_string {
-  return split //, join '', @_;
+	return split //, join '', @_;
 }
 
 sub from_string {
-  return join_string(from_character(_from_string(@_)));
+	return join_string( from_character( _from_string(@_) ) );
 }
 
 sub join_string {
-  return join '', @_;
+	return join '', @_;
 }
 
 sub number_to_s {
-  return sprintf "%d", shift;
+	return sprintf "%d", shift;
 }
 
 sub null_terminate {
-  return pack "Z*", shift;
+	return pack "Z*", shift;
 }
 
 sub null {
-  return null_terminate("");
+	return null_terminate("");
 }
 
 sub eot {
-  return chr(4);
+	return chr(4);
 }
 
 =head1 NAME

Modified: trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/mo.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/mo.pm?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/mo.pm (original)
+++ trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/mo.pm Mon Jul  6 05:50:30 2009
@@ -3,68 +3,69 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.08';
+our $VERSION = '0.09';
 
 use Locale::Msgfmt::Utils;
 
 sub new {
-  return bless {}, shift;
+	return bless {}, shift;
 }
 
 sub initialize {
-  my $self = shift;
-  $self->{magic} = "0x950412de";
-  $self->{format} = 0;
-  $self->{strings} = {};
+	my $self = shift;
+	$self->{magic}   = "0x950412de";
+	$self->{format}  = 0;
+	$self->{strings} = {};
 }
 
 sub add_string {
-  my ($self, $string, $translation) = @_;
-  $self->{strings}->{$string} = $translation;
+	my ( $self, $string, $translation ) = @_;
+	$self->{strings}->{$string} = $translation;
 }
 
 sub prepare {
-  my $self = shift;
-  $self->{count} = scalar keys %{$self->{strings}};
-  $self->{free_mem} = 28 + $self->{count} * 16;
-  @{$self->{sorted}} = sort keys %{$self->{strings}};
-  @{$self->{translations}} = ();
-  foreach(@{$self->{sorted}}) {
-    push @{$self->{translations}}, $self->{strings}->{$_};
-  }
+	my $self = shift;
+	$self->{count}    = scalar keys %{ $self->{strings} };
+	$self->{free_mem} = 28 + $self->{count} * 16;
+	@{ $self->{sorted} }       = sort keys %{ $self->{strings} };
+	@{ $self->{translations} } = ();
+	foreach ( @{ $self->{sorted} } ) {
+		push @{ $self->{translations} }, $self->{strings}->{$_};
+	}
 }
 
 sub out {
-  my $self = shift;
-  my $file = shift;
-  open OUT, ">", $file;
-  binmode OUT;
-  print OUT Locale::Msgfmt::Utils::from_hex($self->{magic});
-  print OUT Locale::Msgfmt::Utils::character($self->{format});
-  print OUT Locale::Msgfmt::Utils::character($self->{count});
-  print OUT Locale::Msgfmt::Utils::character(28);
-  print OUT Locale::Msgfmt::Utils::character(28 + $self->{count} * 8);
-  print OUT Locale::Msgfmt::Utils::character(0);
-  print OUT Locale::Msgfmt::Utils::character(0);
-  foreach(@{$self->{sorted}}) {
-    my $length = length($_);
-    print OUT Locale::Msgfmt::Utils::character($length);
-    print OUT Locale::Msgfmt::Utils::character($self->{free_mem});
-    $self->{free_mem} += $length + 1;
-  }
-  foreach(@{$self->{translations}}) {
-    my $length = length($_);
-    print OUT Locale::Msgfmt::Utils::character($length);
-    print OUT Locale::Msgfmt::Utils::character($self->{free_mem});
-    $self->{free_mem} += $length + 1;
-  }
-  foreach(@{$self->{sorted}}) {
-    print OUT Locale::Msgfmt::Utils::null_terminate($_);
-  }
-  foreach(@{$self->{translations}}) {
-    print OUT Locale::Msgfmt::Utils::null_terminate($_);
-  }
-  close OUT;
+	my $self = shift;
+	my $file = shift;
+	open OUT, ">", $file;
+	binmode OUT;
+	print OUT Locale::Msgfmt::Utils::from_hex( $self->{magic} );
+	print OUT Locale::Msgfmt::Utils::character( $self->{format} );
+	print OUT Locale::Msgfmt::Utils::character( $self->{count} );
+	print OUT Locale::Msgfmt::Utils::character(28);
+	print OUT Locale::Msgfmt::Utils::character( 28 + $self->{count} * 8 );
+	print OUT Locale::Msgfmt::Utils::character(0);
+	print OUT Locale::Msgfmt::Utils::character(0);
+
+	foreach ( @{ $self->{sorted} } ) {
+		my $length = length($_);
+		print OUT Locale::Msgfmt::Utils::character($length);
+		print OUT Locale::Msgfmt::Utils::character( $self->{free_mem} );
+		$self->{free_mem} += $length + 1;
+	}
+	foreach ( @{ $self->{translations} } ) {
+		my $length = length($_);
+		print OUT Locale::Msgfmt::Utils::character($length);
+		print OUT Locale::Msgfmt::Utils::character( $self->{free_mem} );
+		$self->{free_mem} += $length + 1;
+	}
+	foreach ( @{ $self->{sorted} } ) {
+		print OUT Locale::Msgfmt::Utils::null_terminate($_);
+	}
+	foreach ( @{ $self->{translations} } ) {
+		print OUT Locale::Msgfmt::Utils::null_terminate($_);
+	}
+	close OUT;
 }
 
 =head1 NAME

Modified: trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/po.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/po.pm?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/po.pm (original)
+++ trunk/liblocale-msgfmt-perl/lib/Locale/Msgfmt/po.pm Mon Jul  6 05:50:30 2009
@@ -5,104 +5,102 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.08';
+our $VERSION = '0.09';
 
 sub new {
-  my $class = shift;
-  return bless shift || {}, $class;
+	my $class = shift;
+	return bless shift || {}, $class;
 }
 
 sub cleanup_string {
-  my $str = shift;
-  $str =~ s/\\n/\n/g;
-  $str =~ s/\\r/\r/g;
-  $str =~ s/\\t/\t/g;
-  $str =~ s/\\"/"/g;
-  $str =~ s/\\\\/\\/g;
-  return $str;
+	my $str = shift;
+	$str =~ s/\\n/\n/g;
+	$str =~ s/\\r/\r/g;
+	$str =~ s/\\t/\t/g;
+	$str =~ s/\\"/"/g;
+	$str =~ s/\\\\/\\/g;
+	return $str;
 }
 
 sub add_string {
-  my $self = shift;
-  my $hash = shift;
-  my %h = %{$hash};
-  return if !(defined($h{msgid}) && defined($h{msgstr}));
-  return if ($h{fuzzy} && !$self->{fuzzy} && length($h{msgid}) > 0);
-  my $msgstr = join Locale::Msgfmt::Utils::null(), @{$h{msgstr}};
-  return if($msgstr eq "");
-  my $context;
-  my $plural;
-  if($h{msgctxt}) {
-    $context = cleanup_string($h{msgctxt}) . Locale::Msgfmt::Utils::eot();
-  } else {
-    $context = "";
-  }
-  if($h{msgid_plural}) {
-    $plural = Locale::Msgfmt::Utils::null() . cleanup_string($h{msgid_plural});
-  } else {
-    $plural = "";
-  }
-  $self->{mo}->add_string($context . cleanup_string($h{msgid}) . $plural, cleanup_string($msgstr));
+	my $self = shift;
+	my $hash = shift;
+	my %h    = %{$hash};
+	return if !( defined( $h{msgid} ) && defined( $h{msgstr} ) );
+	return if ( $h{fuzzy} && !$self->{fuzzy} && length( $h{msgid} ) > 0 );
+	my $msgstr = join Locale::Msgfmt::Utils::null(), @{ $h{msgstr} };
+	return if ( $msgstr eq "" );
+	my $context;
+	my $plural;
+
+	if ( $h{msgctxt} ) {
+		$context = cleanup_string( $h{msgctxt} ) . Locale::Msgfmt::Utils::eot();
+	} else {
+		$context = "";
+	}
+	if ( $h{msgid_plural} ) {
+		$plural = Locale::Msgfmt::Utils::null() . cleanup_string( $h{msgid_plural} );
+	} else {
+		$plural = "";
+	}
+	$self->{mo}->add_string( $context . cleanup_string( $h{msgid} ) . $plural, cleanup_string($msgstr) );
 }
 
 sub read_po {
-  my $self = shift;
-  my $pofile = shift;
-  my $mo = $self->{mo};
-  open F, $pofile;
-  my %h = ();
-  my $type;
-  while (<F>) {
-    s/\r\n/\n/;
-    if(/^(msgid(?:|_plural)|msgctxt) +"(.*)" *$/) {
-      $type = $1;
-      if(defined($h{$type})) {
-        $self->add_string(\%h);
-        %h = ();
-      }
-      $h{$type} = $2;
-    }
-    elsif(/^msgstr(?:\[(\d*)\])? +"(.*)" *$/) {
-      $type = "msgstr";
-      if(!$h{$type}) {
-        @{$h{$type}} = ();
-      }
-      push @{$h{$type}}, $2;
-    }
-    elsif(/^"(.*)" *$/) {
-      if($type eq "msgstr") {
-        @{$h{$type}}[scalar(@{$h{$type}}) - 1] .= $1;
-      } else {
-        $h{$type} .= $1;
-      }
-    }
-    elsif(/^ *$/) {
-      $self->add_string(\%h);
-      %h = ();
-      $type = undef;
-    } elsif(/^#/) {
-      if(/^#, fuzzy/) {
-        $h{fuzzy} = 1;
-      } elsif (/^#:/) {
-        if(defined($h{msgid})) {
-          $self->add_string(\%h);
-          %h = ();
-          $type = undef;
-        }
-      }
-    } else {
-      print "unknown line: " . $_ . "\n";
-    }
-  }
-  $self->add_string(\%h);
-  close F;
+	my $self   = shift;
+	my $pofile = shift;
+	my $mo     = $self->{mo};
+	open F, $pofile;
+	my %h = ();
+	my $type;
+	while (<F>) {
+		s/\r\n/\n/;
+		if (/^(msgid(?:|_plural)|msgctxt) +"(.*)" *$/) {
+			$type = $1;
+			if ( defined( $h{$type} ) ) {
+				$self->add_string( \%h );
+				%h = ();
+			}
+			$h{$type} = $2;
+		} elsif (/^msgstr(?:\[(\d*)\])? +"(.*)" *$/) {
+			$type = "msgstr";
+			if ( !$h{$type} ) {
+				@{ $h{$type} } = ();
+			}
+			push @{ $h{$type} }, $2;
+		} elsif (/^"(.*)" *$/) {
+			if ( $type eq "msgstr" ) {
+				@{ $h{$type} }[ scalar( @{ $h{$type} } ) - 1 ] .= $1;
+			} else {
+				$h{$type} .= $1;
+			}
+		} elsif (/^ *$/) {
+			$self->add_string( \%h );
+			%h    = ();
+			$type = undef;
+		} elsif (/^#/) {
+			if (/^#, fuzzy/) {
+				$h{fuzzy} = 1;
+			} elsif (/^#:/) {
+				if ( defined( $h{msgid} ) ) {
+					$self->add_string( \%h );
+					%h    = ();
+					$type = undef;
+				}
+			}
+		} else {
+			print "unknown line: " . $_ . "\n";
+		}
+	}
+	$self->add_string( \%h );
+	close F;
 }
 
 sub parse {
-  my $self = shift;
-  my ($pofile, $mo) = @_;
-  $self->{mo} = $mo;
-  $self->read_po($pofile);
+	my $self = shift;
+	my ( $pofile, $mo ) = @_;
+	$self->{mo} = $mo;
+	$self->read_po($pofile);
 }
 
 =head1 NAME

Modified: trunk/liblocale-msgfmt-perl/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/t/00-load.t?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/t/00-load.t (original)
+++ trunk/liblocale-msgfmt-perl/t/00-load.t Mon Jul  6 05:50:30 2009
@@ -3,7 +3,7 @@
 use Test::More tests => 1;
 
 BEGIN {
-	use_ok( 'Locale::Msgfmt' );
+	use_ok('Locale::Msgfmt');
 }
 
-diag( "Testing Locale::Msgfmt $Locale::Msgfmt::VERSION, Perl $], $^X" );
+diag("Testing Locale::Msgfmt $Locale::Msgfmt::VERSION, Perl $], $^X");

Modified: trunk/liblocale-msgfmt-perl/t/interface.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/t/interface.t?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/t/interface.t (original)
+++ trunk/liblocale-msgfmt-perl/t/interface.t Mon Jul  6 05:50:30 2009
@@ -9,47 +9,48 @@
 use File::Path;
 
 sub slurp {
-    open F, shift;
-    binmode F;
-    my $s = "";
-    while(<F>) { $s .= $_; };
-    close F;
-    return $s;
+	open F, shift;
+	binmode F;
+	my $s = "";
+	while (<F>) { $s .= $_; }
+	close F;
+	return $s;
 }
 
-$dir = File::Temp::tempdir(CLEANUP => 0);
-copy(File::Spec->catfile("t", "samples", "basic.po"), File::Spec->catfile($dir, "basic.po"));
-msgfmt(File::Spec->catfile($dir, "basic.po"));
-ok(-f File::Spec->catfile($dir, "basic.mo"));
-unlink File::Spec->catfile($dir, "basic.mo");
-msgfmt({in => File::Spec->catfile($dir, "basic.po")});
-ok(-f File::Spec->catfile($dir, "basic.mo"));
-unlink File::Spec->catfile($dir, "basic.mo");
-msgfmt({in => File::Spec->catfile($dir, "basic.po"), out => File::Spec->catfile($dir, "mo")});
-ok(-f File::Spec->catfile($dir, "mo"));
-unlink(File::Spec->catfile($dir, "mo"));
-mkdir(File::Spec->catdir($dir, "a"));
-mkdir(File::Spec->catdir($dir, "b"));
-move(File::Spec->catfile($dir, "basic.po"), File::Spec->catfile($dir, "a", "basic.po"));
-msgfmt(File::Spec->catdir($dir, "a"));
-ok(-f File::Spec->catfile($dir, "a", "basic.mo"));
-unlink File::Spec->catfile($dir, "a", "basic.mo");
-msgfmt({in => File::Spec->catdir($dir, "a")});
-ok(-f File::Spec->catfile($dir, "a", "basic.mo"));
-unlink File::Spec->catfile($dir, "a", "basic.mo");
-msgfmt({in => File::Spec->catdir($dir, "a"), out => File::Spec->catdir($dir, "b"),});
-ok(-f File::Spec->catfile($dir, "b", "basic.mo"));
-unlink(File::Spec->catfile($dir, "b", "basic.mo"));
-move(File::Spec->catfile($dir, "a", "basic.po"), File::Spec->catfile($dir, "basic.po"));
-msgfmt({in => File::Spec->catfile($dir, "basic.po"), fuzzy => 1, out => File::Spec->catfile($dir, "fuzzy")});
-msgfmt({in => File::Spec->catfile($dir, "basic.po"), out => File::Spec->catfile($dir, "not_fuzzy")});
-ok(!(slurp(File::Spec->catfile($dir, "not_fuzzy")) eq slurp(File::Spec->catfile($dir, "fuzzy"))));
-unlink(File::Spec->catfile($dir, "not_fuzzy"));
-unlink(File::Spec->catfile($dir, "fuzzy"));
-move(File::Spec->catfile($dir, "basic.po"), File::Spec->catfile($dir, "a", "basic.po"));
-msgfmt({in => File::Spec->catfile($dir, "a"), fuzzy => 1, out => File::Spec->catfile($dir, "b")});
-msgfmt({in => File::Spec->catfile($dir, "a"), out => File::Spec->catfile($dir, "c")});
-ok(!(slurp(File::Spec->catfile($dir, "b", "basic.mo")) eq slurp(File::Spec->catfile($dir, "c", "basic.mo"))));
-unlink(File::Spec->catfile($dir, "c", "basic.mo"));
-unlink(File::Spec->catfile($dir, "b", "basic.mo"));
+$dir = File::Temp::tempdir( CLEANUP => 0 );
+copy( File::Spec->catfile( "t", "samples", "basic.po" ), File::Spec->catfile( $dir, "basic.po" ) );
+msgfmt( File::Spec->catfile( $dir, "basic.po" ) );
+ok( -f File::Spec->catfile( $dir, "basic.mo" ) );
+unlink File::Spec->catfile( $dir, "basic.mo" );
+msgfmt( { in => File::Spec->catfile( $dir, "basic.po" ) } );
+ok( -f File::Spec->catfile( $dir, "basic.mo" ) );
+unlink File::Spec->catfile( $dir, "basic.mo" );
+msgfmt( { in => File::Spec->catfile( $dir, "basic.po" ), out => File::Spec->catfile( $dir, "mo" ) } );
+ok( -f File::Spec->catfile( $dir, "mo" ) );
+unlink( File::Spec->catfile( $dir, "mo" ) );
+mkdir( File::Spec->catdir( $dir, "a" ) );
+mkdir( File::Spec->catdir( $dir, "b" ) );
+move( File::Spec->catfile( $dir, "basic.po" ), File::Spec->catfile( $dir, "a", "basic.po" ) );
+msgfmt( File::Spec->catdir( $dir, "a" ) );
+ok( -f File::Spec->catfile( $dir, "a", "basic.mo" ) );
+unlink File::Spec->catfile( $dir, "a", "basic.mo" );
+msgfmt( { in => File::Spec->catdir( $dir, "a" ) } );
+ok( -f File::Spec->catfile( $dir, "a", "basic.mo" ) );
+unlink File::Spec->catfile( $dir, "a", "basic.mo" );
+msgfmt( { in => File::Spec->catdir( $dir, "a" ), out => File::Spec->catdir( $dir, "b" ), } );
+ok( -f File::Spec->catfile( $dir, "b", "basic.mo" ) );
+unlink( File::Spec->catfile( $dir, "b", "basic.mo" ) );
+move( File::Spec->catfile( $dir, "a", "basic.po" ), File::Spec->catfile( $dir, "basic.po" ) );
+msgfmt( { in => File::Spec->catfile( $dir, "basic.po" ), fuzzy => 1, out => File::Spec->catfile( $dir, "fuzzy" ) } );
+msgfmt( { in => File::Spec->catfile( $dir, "basic.po" ), out => File::Spec->catfile( $dir, "not_fuzzy" ) } );
+ok( !( slurp( File::Spec->catfile( $dir, "not_fuzzy" ) ) eq slurp( File::Spec->catfile( $dir, "fuzzy" ) ) ) );
+unlink( File::Spec->catfile( $dir, "not_fuzzy" ) );
+unlink( File::Spec->catfile( $dir, "fuzzy" ) );
+move( File::Spec->catfile( $dir, "basic.po" ), File::Spec->catfile( $dir, "a", "basic.po" ) );
+msgfmt( { in => File::Spec->catfile( $dir, "a" ), fuzzy => 1, out => File::Spec->catfile( $dir, "b" ) } );
+msgfmt( { in => File::Spec->catfile( $dir, "a" ), out => File::Spec->catfile( $dir, "c" ) } );
+ok( !( slurp( File::Spec->catfile( $dir, "b", "basic.mo" ) ) eq slurp( File::Spec->catfile( $dir, "c", "basic.mo" ) ) )
+);
+unlink( File::Spec->catfile( $dir, "c", "basic.mo" ) );
+unlink( File::Spec->catfile( $dir, "b", "basic.mo" ) );
 

Modified: trunk/liblocale-msgfmt-perl/t/msgfmt.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblocale-msgfmt-perl/t/msgfmt.t?rev=39396&op=diff
==============================================================================
--- trunk/liblocale-msgfmt-perl/t/msgfmt.t (original)
+++ trunk/liblocale-msgfmt-perl/t/msgfmt.t Mon Jul  6 05:50:30 2009
@@ -7,44 +7,45 @@
 use File::Spec;
 
 SKIP: {
-    skip "Test needs Locale::Maketext::Gettext", 5 if(!eval("use Locale::Maketext::Gettext; 1;"));
-    sub my_read_mo {
-        my $str = "";
-        my %h = read_mo(shift);
-        foreach(sort keys %h){$str .= $_ . " " . $h{$_} . "\n";};
-        return $str;
-    }
-    sub my_msgfmt {
-        my ($fh, $filename) = File::Temp::tempfile();
-        close $fh;
-        my $in = shift;
-        my $fuzzy = 0;
-        if(shift) {
-            $fuzzy = 1;
-        }
-        msgfmt({in => $in, out => $filename, fuzzy => $fuzzy});
-        return $filename;
-    }
-    sub do_one_test {
-        my $basename = shift;
-        my $po = File::Spec->catfile("t", "samples", $basename . ".po");
-        my $mo = File::Spec->catfile("t", "samples", $basename . ".mo");
-        my $good = my_read_mo($mo);
-        my $filename = my_msgfmt($po);
-        my $test = my_read_mo($filename);
-        is($test, $good);
-        if($basename eq "basic") {
-            unlink($filename);
-            $filename = my_msgfmt($po, 1);
-            $good = my_read_mo(File::Spec->catfile("t", "samples", "fuzz.mo"));
-            $test = my_read_mo($filename);
-            is($test, $good);
-        }
-        unlink($filename);
-    }
-    do_one_test("basic");
-    do_one_test("ja");
-    do_one_test("context");
-    do_one_test("ngettext");
+	skip "Test needs Locale::Maketext::Gettext", 5 if ( !eval("use Locale::Maketext::Gettext; 1;") );
+
+	sub my_read_mo {
+		my %h = read_mo(shift);
+		return \%h;
+	}
+
+	sub my_msgfmt {
+		my ( $fh, $filename ) = File::Temp::tempfile();
+		close $fh;
+		my $in    = shift;
+		my $fuzzy = 0;
+		if (shift) {
+			$fuzzy = 1;
+		}
+		msgfmt( { in => $in, out => $filename, fuzzy => $fuzzy } );
+		return $filename;
+	}
+
+	sub do_one_test {
+		my $basename = shift;
+		my $po       = File::Spec->catfile( "t", "samples", $basename . ".po" );
+		my $mo       = File::Spec->catfile( "t", "samples", $basename . ".mo" );
+		my $good     = my_read_mo($mo);
+		my $filename = my_msgfmt($po);
+		my $test     = my_read_mo($filename);
+		is_deeply( $test, $good );
+		if ( $basename eq "basic" ) {
+			unlink($filename);
+			$filename = my_msgfmt( $po, 1 );
+			$good = my_read_mo( File::Spec->catfile( "t", "samples", "fuzz.mo" ) );
+			$test = my_read_mo($filename);
+			is_deeply( $test, $good );
+		}
+		unlink($filename);
+	}
+	do_one_test("basic");
+	do_one_test("ja");
+	do_one_test("context");
+	do_one_test("ngettext");
 }
 




More information about the Pkg-perl-cvs-commits mailing list