help-octave
[Top][All Lists]
Advanced

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

RE: frewind() broken octave 3.6.1 on winxp/32b ?


From: Jeff Harrang
Subject: RE: frewind() broken octave 3.6.1 on winxp/32b ?
Date: Wed, 18 Apr 2012 13:55:47 -0700

No, meant GUI Octave (sigh .. Octave project might choose another name
rather than 'octave GUI' to avoid massive confusion with previous
efforts). But GUI Octave isn't relevant to bug.

This is a problem with Octave 3.6.1 (see email title) running standalone
CLI under WinXP/32b. See sample script. Actually frewind() reports
success (returns 0) but doesn't appear to actually rewind the stream so
that subsequent fputs fails returning -1. Work around in comments works
as expected i.e. overwrites starting at first line of file. 

Maybe I'm expecting something non-supported from frewind() and fputs()?
(note that if you use ftell() before and after the frewind() it
*appears* to reset the file pointer correctly but fputs fails)

function errno = frewindBug(fileName, fileMode)
        
        errno = [0];
        if ~exist("fileMode", "var"), fileMode='rt+'; end
        [fd,errmsg] = fopen(fileName, fileMode);
        if fd<0
                printf("%s\n", errmsg);
                errno = [-1];
                return;
        end
        
        lineno = 1;
        while ischar(fgets(fd))
                printf("frewindBug: read line %d\n", lineno++);
        end
        
        errno = [errno(:); frewind(fd)];        % FAILS??
        
        # work-around
        #fclose(fd);
        #fd = fopen(fileName,'rt+');
        #errno = [errno(:); fd];
                
        errno = [errno(:); fputs(fd, "line 111")];
        
endfunction     

Where the example *.txt file is something simple like:
line one
line two
line three
last line of file

Jeff

-----Original Message-----
From: Ben Abbott [mailto:address@hidden 
Sent: Tuesday, April 17, 2012 5:06 PM
To: Jeff Harrang
Cc: address@hidden
Subject: Re: frewind() broken octave 3.6.1 on winxp/32b ?

On Apr 17, 2012, at 4:41 PM, Jeff Harrang wrote:

> Ran a script today that has worked previously (octave 3.4) and found
that a file manipulation function fails. The reason seems to be that
frewind() is not working. In debug mode it doesn't return anything and
does not seem to do its function so that subsequent fputs() calls fail.
Work-around closing file and reopening works properly.
>  
> File opened like this ..
> [fd,errmsg] = fopen(fileName,'r+t');
>  
> Known issue?
>  
> BTW - running under latest GUIoctave.
>  
> Jeff

GUI Octave is not actually Octave software.

        http://guioctave.com/

Do you mean Octave GUI built from the developers sources?

        http://hg.savannah.gnu.org/hgweb/octave/file/f6b4236da9f8/gui

If the problem is with GUI Octave, please try Octave by itself.

If the problem is with Octave GUI also try Octave by itself.

If the problem persists, please tell us what version of Octave your are
running, and try to create a simple example so that others can duplicate
the problem.

Ben



reply via email to

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