Package: libogg-vorbis-header-pureperl-perl
Version: 0.07-1
Severity: normal
Tags: patch

When calling the comment_tags method, if the Ogg file contains multiple
instances of a given tag, the tag will appear multiple times in the
resulting list. However, there is already a method to deal with multiple
instances of the same tag, which is that the comment method returns a
list, rather than a scalar. Thus, to actually retrieve the correct list
of comments, one must manually remove duplicates from the result of the
comment_tags method.

As an example, consider the following code:
  foreach my $k ($ogg->comment_tags()) {
    foreach my $v ($ogg->comment($k)) {
      print "$k=$v\n";
    }
  }
When run on an oggfile containing the two comments:
  foo=bar
  foo=baz
the following output is produced:
  foo=bar
  foo=baz
  foo=bar
  foo=baz

I suggest instead that comment_tags return a unique list of tags found
in the file. I have attached a patch which does this, while preserving
the order of tags as they were found in the file.

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.10-1-k7-smp
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages libogg-vorbis-header-pureperl-perl depends on:
ii  perl                          5.8.4-6    Larry Wall's Practical Extraction 

-- no debconf information
--- PurePerl.pm.orig    2004-07-07 18:29:41.000000000 -0400
+++ PurePerl.pm 2005-02-14 11:43:37.000000000 -0500
@@ -380,6 +380,7 @@
     $byteCount += 4;
 
     $data->{'COMMENT_KEYS'} = [];
+    my %seen_comments;
 
     # finally, read the comments
     for (my $i = 0; $i < $user_comment_count; $i++)
@@ -397,7 +398,9 @@
        my ($value) = $buffer =~ /=(.*)$/;
 
        push @{$comments{lc $key}}, $value;
-       push @{$data->{'COMMENT_KEYS'}}, lc $key;
+       push @{$data->{'COMMENT_KEYS'}}, lc $key
+         unless $seen_comments{lc $key};
+       $seen_comments{lc $key} = 1;
     }
     
     # read past the framing_bit

Reply via email to