Thread overview
[Issue 2783] New: Truncation of long string by std.stdio.write
Apr 02, 2009
d-bugmail
Apr 02, 2009
d-bugmail
Apr 02, 2009
d-bugmail
Apr 02, 2009
d-bugmail
April 02, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2783

           Summary: Truncation of long string by std.stdio.write
           Product: D
           Version: 2.026
          Platform: PC
               URL: http://www.britseyeview.com/middle.txt
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: steve.teale@britseyeview.com


Walter,

The file middle.txt at the URL above has lines numbered up to 555. If I read it into a string and std.stdio.write the string to the console, the output is truncated at line 261.

import std.file;
import std.stdio;
import std.c.stdio;

void main()
{
   string s2 = cast(immutable(char[])) std.file.read("middle.txt");
   std.stdio.write(s2);
   printf("%s", (s2 ~ "\x00").ptr);
}

It isn't std.file.read, as I got similar behavior when the string was output to the console from the program that generated middle.txt - then it was at line 221.

I checked the string for embedded zeroes and 0x1a when it was doing the fail at 221, but it seemed to be OK.

printf works as expected.

I'm sorry I can't come up with anything more compact than this, and I'm probably missing something stupid.

Steve


-- 

April 02, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2783





------- Comment #1 from steve.teale@britseyeview.com  2009-04-02 05:03 -------
Created an attachment (id=310)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=310&action=view)
The file used in my description of the issue


-- 

April 02, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2783





------- Comment #2 from maxmo@pochta.ru  2009-04-02 07:40 -------
format.d
1623: short precision = short.max - 1;
2010: auto s = obj[0 .. f.precision < $ ? f.precision : $];
2016: w.write(s);

try std.stdio.write("%s",s2);


-- 

April 02, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2783





------- Comment #3 from andrei@metalanguage.com  2009-04-02 08:23 -------
I've fixed the problem, will be part of the next release.

Andrei


-- 

October 11, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2783


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@metalanguage.com
         AssignedTo|nobody@puremagic.com        |andrei@metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2783


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #4 from Andrei Alexandrescu <andrei@metalanguage.com> 2010-09-26 14:25:37 PDT ---
Fixed a while ago.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------