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

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

[Octave-bug-tracker] [bug #41091] fread's second outarg is number of byt


From: Philipp Kutin
Subject: [Octave-bug-tracker] [bug #41091] fread's second outarg is number of bytes read, not elements as required
Date: Fri, 03 Jan 2014 20:34:25 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0

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

                 Summary: fread's second outarg is number of bytes read, not
elements as required
                 Project: GNU Octave
            Submitted by: pkutin
            Submitted on: Fri 03 Jan 2014 08:34:25 PM GMT
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

On a file 'sevenbytes.bin', the following script,


fid = fopen('sevenbytes.bin');
assert(fid >= 0);

[a, cnt] = fread(fid, 3, 'int16');  % should read enough
if (numel(a) ~= 3)
    fprintf('Failed reading 3 16-bit ints\n');
elseif (cnt ~= 3)
    fprintf('Expected cnt==3, got %d\n', cnt);
end

[b, cnt] = fread(fid, 2, 'int16');  % don't have enough data
fprintf('numel(b): %d\n', numel(b));
fprintf('cnt: %d\n', cnt);

fclose(fid);


gives:

% MATLAB R2013a
>> fread_second_outarg
numel(b): 0
cnt: 0

% Octave default
octave:1> fread_second_outarg
Expected cnt==3, got 6
numel(b): 2
cnt: 1


Beisdes being a MATLAB incompatibility, I'm pretty sure that it's an Octave
regression too.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Fri 03 Jan 2014 08:34:25 PM GMT  Name: sevenbytes.bin  Size: 7B   By:
pkutin

<http://savannah.gnu.org/bugs/download.php?file_id=30178>
-------------------------------------------------------
Date: Fri 03 Jan 2014 08:34:25 PM GMT  Name: fread_second_outarg.m  Size: 382B
  By: pkutin

<http://savannah.gnu.org/bugs/download.php?file_id=30179>
-------------------------------------------------------
Date: Fri 03 Jan 2014 08:34:25 PM GMT  Name: fread_second_outarg.log  Size:
156B   By: pkutin

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

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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