[Patch, Fortran] PR57633 - Fix EOL handling with \r in list-directed I/O

Tobias Burnus burnus@net-b.de
Thu Jun 20 09:12:00 GMT 2013


gfortran failed to correctly read the file
    line1,1,
    line2
with DOS (\r\n) line endings. As the code already set EOL for "\r", 
finish_list_read didn't call eat_line. Result: The attempt to read 
"line2" actually accessed the last byte of line one, namely "\n", which 
it regarded as zero-sized string.

That's fixed by the patch to next_char.

eat_separator is a separate issue and unrelated to the PR. I also failed 
to create a test case for it. In any case, I regard the following as wrong:

      case '\r':
       dtp->u.p.at_eol = 1;
...
        if (n != '\n')
         {
           unget_char (dtp, n);
           break;

As the code explicitly does not regard "\r" as EOL in this case, I 
believe EOL shouldn't be set here.

(Recall, Unix (MacOS X, Linux, ...) have '\n' while DOS/Windows has 
"\r\n". While '\r' as line break exists (old Macs, pre MacOS X), 
gfortran does not support formatted I/O with "\r" record markers.)


Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: read.diff
Type: text/x-patch
Size: 2429 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20130620/04efebd6/attachment.bin>


More information about the Fortran mailing list