Bug report: Octave 3.0.x fgetl works wrong on DOS files in UNIX

Jörg Bretschneider Joerg.Bretschneider at eas.iis.fraunhofer.de
Tue Feb 17 03:05:03 CST 2009


Thanks for the prompt response. However I am not familiar with
recompiling those fixes into my installation, so I hope for this change
to be included in the next 3.0.x bugfix release...
Until then, a one-liner deleting the CRs from fgetls output will work
for me.

Joerg Bretschneider

John W. Eaton wrote:
> | 
> | Bug report for Octave 3.0.1 configured for i486-pc-linux-gnu
> | Erroneous output of fgetl on a unix system with DOS style files
> | 
> | 
> | Octave's fgetl function is told to deliver a line from an open file,
> | excluding the end of line (EOL) character (sequence). If operating a
> | file generated on a WINDOWS system from octave 3.0.x running on a UNIX
> | system, fgetl returns a line where the LF character (ASCII 10) has been
> | correctly removed, but the CR character (ASCII 13) remains.
> | 
> | This is not really a bug, as there would be no EOL in those lines in
> | Unix, but it may cause strange behaviour if one works works with those
> | strings.
> | I got strange errors when I composed commands for eval() from
> | definitions in a file, just adding ';' to the command. Octave was
> | unable to understand this command and threw a parser error.
> | 
> | Repeat-By:
> | ---------
> | 
> | testline = 'x_vec = ';
> | if ~isunix, error('This  won''t work on windows'), end
> | fid = fopen('dosfile.txt','wt');
> | for k=1:3,
> | 	s = sprintf('%s\n', [testline num2str(k) ' !' char(13)])
> | 	fprintf(fid,'%s', s);
> | end, fclose(fid);
> | fid = fopen('dosfile.txt','rt');
> | for k=1:3,
> | 	s = fgetl(fid),
> | 	disp([ s '###']),
> | 	% eval([s ';'})   % uncomment this line to see the parser error
> | end, fclose(fid);
> 
> I checked in the following change.
> 
>   http://hg.savannah.gnu.org/hgweb/octave/rev/d477e57e811c
> 
> jwe
> 
> 

-- 
Jörg Bretschneider

Fraunhofer-Institut für Integrierte Schaltungen
Institutsteil Entwurfsautomatisierung
Zeunerstr. 38,
01069 Dresden,
Germany

Tel. ++49(0)351/4640-749
Fax: ++49(0)351/4640-703
Joerg.Bretschneider at eas.iis.fraunhofer.de
www.eas.iis.fraunhofer.de

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3627 bytes
Desc: S/MIME Cryptographic Signature
Url : https://www-old.cae.wisc.edu/pipermail/bug-octave/attachments/20090217/d928b8d0/attachment.bin 


More information about the Bug-octave mailing list