fread(..inf..skip) returns to many elements
John W. Eaton
jwe at bevo.che.wisc.edu
Wed Feb 27 21:50:10 CST 2008
On 27-Feb-2008, Alois Schloegl wrote:
| To: bug at octave.org
| Cc: a.schloegl at ieee.org
| Subject: bug in fread with skip
| --------
| Bug report for Octave 3.0.0+ configured for i686-pc-linux-gnu
|
| Description:
| -----------
|
| I came across a problem using a rather complex call to fread.
| The file contains some header (10752 bytes) and 40 data blocks with
| 62976 bytes.
| This results in a file size of 2 555 904 bytes. When, I tried to read
| the last 1536 bytes from each data block, using this command,
| [t,c] = fread(fid,inf,'1536*uint8',61440);
|
| one gets 98304 bytes, this is much more than the expected 40*1536=61440.
|
|
| The problem appears in Octave 2.9.19 as well as in 3.0.0+ a recent CVS
| snapshot (from Feb 24).
|
|
|
|
| Repeat-By:
| ---------
|
| Here is a script for repeating the problem,
|
| % generate test file with 2 555 904 bytes
| testfile='/tmp/test.bin';
| fid = fopen(testfile,'w');
| fwrite(fid,1:638976,'uint32');
| fclose(fid);
|
| % read 1536 bytes and skip 61440 byes as long as data elements are available
| fid = fopen(testfile,'r');
| fseek(fid,10752+61440,'bof');
| [t,count] = fread(fid,inf,'1536*uint8',61440);
| fclose(fid);
| count,
|
| length(t) and count have a value of 87552 instead of 61440.
Please try the following patch.
Thanks,
jwe
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diffs
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080227/795d045f/attachment-0001.ksh
More information about the Bug-octave
mailing list