[Issue 1442] New: std.file.read returns truncated data on OS X if line ends are not Unix

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 26 17:04:41 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1442

           Summary: std.file.read returns truncated data on OS X if line
                    ends are not Unix
           Product: DGCC aka GDC
           Version: 0.24
          Platform: Macintosh
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: dvdfrdmn at users.sf.net
        ReportedBy: fire_void at hotmail.com


The following test program shows how I am able to reproduce the error on my
system. It happens everytime the program is run.

------------
testd.d
------------

import std.file;
import std.stdio;

void main()
{
        char[] contents = cast(char[]) std.file.read("test_file.txt");
        writefln( contents );
}

--------------
test_file.txt
--------------
name = dunzip
[dunzip.d]
target = dunzip

If you type the contents of test_file.txt, it will work. It only fails when the
line ending is not that of OS X.

My procedure to reproduce was the following: (it would have been easier to
upload the text file but i can't upload stuff here...)
* go to http://www.dsource.org/projects/dsss/wiki/DSSSByExample, copy the
contents of the file depicted above
* paste them in either smultron or textedit. save the file to "test_file.txt"
next to the executable.
* run the executable. it prints only "target = HelloWorld".
* In smultron, if i then select "Text > Line Ending > Unix" and save, running
the program now gives correct line endings.

The read method should load the data with whatever line endings the file
contains, however it should not truncate data, especially not when the same
file opens correctly in all OS X text editors.

The following code was tested on OS X 10.4.10, PPC, G4 (32-bits). It ran
correctly when the same procedure was done in Linux.


-- 



More information about the D.gnu mailing list