Bug report: Octave 3.0.x fgetl works wrong on DOS files in UNIX
John W. Eaton
jwe at octave.org
Fri Feb 13 15:43:01 CST 2009
|
| 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
More information about the Bug-octave
mailing list