bugGNU Octave - Bugs: bug #47671, textscan re-reads part of the file...

 
 

bug #47671: textscan re-reads part of the file on the second and subsequent calls

Submitter:  Lachlan Andrew <lachlan>
Submitted:  Tue 12 Apr 2016 11:05:23 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  lachlan
Originator Name:  Lachlan Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 14 Apr 2016 12:05:40 AM UTC, comment #3: 

I applied your patch here http://hg.savannah.gnu.org/hgweb/octave/rev/fe0a6de805e4.  Closing report.

Rik <rik5>
Group administrator
Wed 13 Apr 2016 10:11:44 AM UTC, comment #2: 

I forgot to add steps to reproduce the problem.

Type


f = tempname ();
fid = fopen (f, "w+");
fprintf (fid, "1,2\n3,4\n");
fseek (fid, 0, "bof");
A = textscan (fid, "%s %f", 2, "Delimiter", ",");
ftell (fid)
fclose (fid);
unlink (f);


The ftell reports 3, even though 8 characters have been processed.

This is separate from bug #41579 ("textscan: file offset after partial read differs from Matlab").  Matlab returns 7 instead of 8 for some reason.

Lachlan Andrew <lachlan>
Tue 12 Apr 2016 11:07:31 AM UTC, comment #1: 

The attached patch seems to fix the problem, by keeping better track of the number of bytes processed.

(file #36900)

Lachlan Andrew <lachlan>
Tue 12 Apr 2016 11:05:23 AM UTC, original submission:  

When textscan reads only part of a file, the read pointer is left at the wrong position, so that subsequent reads re-read some of the data.

In some circumstances, this can also result in the EOF flag not getting set when the whole file has been read.

Lachlan Andrew <lachlan>

 

(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

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by lachlan (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-04-14 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2016-04-12 lachlan Attached File- Added bug_47671_textscan_file_pos.cset, #36900
        StatusNone Patch Submitted
        Assigned toNone lachlan
        Releaseother dev

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code