Skip Menu |

This queue is for tickets about the File-Binary CPAN distribution.

Report information
The Basics
Id: 15928
Status: resolved
Priority: 0/
Queue: File-Binary

People
Owner: Nobody in particular
Requestors: karl.forner [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: seek bug - another patch and test
From: karl.forner#gmail.com Hello, I also got into trouble with the seek method. Basically it lacks the whence argument to the seek method. I wrote a simple patch and a simplistic test to contribute if it can help you. Here's the patch: ================================================================= --- Binary.pm 2005-11-18 15:00:54.000000000 +0100 +++ Binary.pm.fixed 2005-11-18 15:00:33.000000000 +0100 @@ -158,12 +158,13 @@ sub seek { my $self = shift; my $seek = shift; + my $whence = shift || SEEK_SET; unless ($self->{_is_seekable}) { carp "FH is not seekable" if $DEBUG; return 0; } - $self->{_fh}->seek($seek) if defined $seek; + $self->{_fh}->seek($seek, $whence) if defined $seek; $self->_init_bits(); return $self->{_fh}->tell(); ====================================================== and here's the test: t/00seek.t ===================================================== #!perl -w use strict; use Test::More qw(no_plan); use File::Binary; use Data::Dumper; my $bin = File::Binary->new('t/le.fibonacci.n32.ints'); $bin->set_endian($File::Binary::LITTLE_ENDIAN); my %pos_2_value; foreach (1..10) { my $key = $bin->tell(); $pos_2_value{$key} = $bin->get_si32(); } foreach my $key (keys %pos_2_value) { $bin->seek( $key ); is( $bin->get_si32(), $pos_2_value{$key}); } $bin->close(); ========================================================== Thanks for your work. Karl Forner
Date: Fri, 18 Nov 2005 14:35:25 +0000
From: Simon Wistow <simon [...] thegestalt.org>
To: Guest via RT <bug-File-Binary [...] rt.cpan.org>
Subject: Re: [cpan #15928] seek bug - another patch and test
RT-Send-Cc:
On Fri, Nov 18, 2005 at 09:08:05AM -0500, Guest via RT said: Show quoted text
> I also got into trouble with the seek method. Basically it lacks the > whence argument to the seek method. I wrote a simple patch and a > simplistic test to contribute if it can help you.
Cool, I'll patch this weekend and release. Thanks. Simon
I have no idea why I never released this. My apologies. Fixed and released now as 1.3