www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 users.sf.net
        ReportedBy: fire_void 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.


-- 
Aug 26 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1442






Created an attachment (id=171)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=171&action=view)
An example of file that causes problem

(Ah you can post atatchements after the initial post)
Attached is a file that shows the problem


-- 
Aug 26 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1442


dvdfrdmn users.sf.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID





Phobos is not truncating the data.  What you are seeing is overtyping done by
the terminal software.  If you run the 'cat' program on the file, it will
produce the same result.  std.file.read just returns an array of bytes and
should not perform any kind of translation.


-- 
Aug 28 2007