bugGNU Octave - Bugs: bug #47537, textscan reads entire file even...

 
 

bug #47537: textscan reads entire file even when given a count

Submitter:  Mike Miller <mtmiller>
Submitted:  Fri 25 Mar 2016 11:22:42 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Duplicate Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 28 Mar 2016 05:23:19 PM UTC, comment #2: 

Example works now with fix for bug #47517.

Mike Miller <mtmiller>
Group Member
Sat 26 Mar 2016 07:22:46 AM UTC, comment #1: 

Mike, see bug #47517.

The file isn't read until EOF, as you can see from the size of the return value.  The problem is that the patch for seekg() was not committed when the rest of textscan was.  Without it, seekg() always returns -1 even if not at EOF.  I've attached it again, in case that makes finding it easier.

(file #36764)

Lachlan Andrew <lachlan>
Fri 25 Mar 2016 11:22:42 PM UTC, original submission:  

When told to read a certain number of elements matching the format specifier and its input is a file descriptor, textscan is supposed to stop reading the input file at the last character that matched a conversion. Instead, the new textscan reads the entire file up to EOF.

Example:


>> str = "1 2 3 4 5 6";
>> [t, pos] = textscan (str, "%d", 1)
t =
{
  [1,1] = 1
}
pos =  2
>> fid = tmpfile;
>> fprintf (fid, str);
>> frewind (fid);
>> [t, pos] = textscan (fid, "%d", 1);
>> ftell (fid)
ans =  11
>> fclose (fid);
>> t, pos
t =
{
  [1,1] = 1
}
pos = -1


I think in this case the results for both pos and ftell should be 2.

It would be helpful if someone could confirm these in Matlab.

Mike Miller <mtmiller>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by lachlan (Updated the item)
  • -email is unavailable- added by mtmiller (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-28 mtmiller Open/ClosedOpen Closed
    2016-03-26 lachlan Attached File- Added textscan_enable_seek_v2.cset, #36764
        StatusNeed Info Duplicate
    2016-03-25 mtmiller Dependencies- bugs #41579 is dependent

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code