octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #41648] fread not working with skip parameter


From: anonymous
Subject: [Octave-bug-tracker] [bug #41648] fread not working with skip parameter
Date: Thu, 20 Feb 2014 18:03:13 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:27.0) Gecko/20100101 Firefox/27.0

URL:
  <http://savannah.gnu.org/bugs/?41648>

                 Summary: fread not working with skip parameter
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Thu 20 Feb 2014 06:03:11 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Regression
                  Status: None
             Assigned to: None
         Originator Name: Tiago Loureiro
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.8.0
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

The fread function is not behaving correctly when skipping after a read.

With the following data in a binary file (attached):

000102030405060708090A0B0C0D0E0F

Reading it with the following commands:


fid=fopen("test.bin","rb","ieee-be");
a=fread(fid, inf, "uint8",1);
a'


should yield (in hex):

ans =

    0    2    4    6    8    10   12   14


but returns instead (in hex):


ans =

    0    2    3    4    5    6    7    8    9   10   11   12   13   14   15


It is interesting to note that if called sequentially like this with skip=1:

fread(fid, 1, "uint8",1);


the correct sequence is read. 

However, if called like this:

fread(fid, inf, "2*uint8",2)


it yields a strange sequence:

ans =

    0    1    4    5    6    7    8    9   10   11   12   13   14   15


Note the first two bytes being read correctly, and then the skip is forgotten
and the rest of the file is read. The expected sequence would be instead:

ans =

    0    1    4    5    8    9   12   13


Finally, when doing the following:


fread(fid, 1, "2*uint8",2)


octave crashes with the message "Aborted".

It is as if it is getting confused between bytes to read and elements to read,
and that the logic of whether to skip or not is broken.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 20 Feb 2014 06:03:11 PM UTC  Name: test.bin  Size: 16B   By: None

<http://savannah.gnu.org/bugs/download.php?file_id=30618>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?41648>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]