www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2783] New: Truncation of long string by std.stdio.write

reply d-bugmail puremagic.com writes:
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


-- 
Apr 02 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2783






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


-- 
Apr 02 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2783






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);


-- 
Apr 02 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2783






I've fixed the problem, will be part of the next release.

Andrei


-- 
Apr 02 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Oct 11 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2783


Andrei Alexandrescu <andrei metalanguage.com> changed:

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



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: -------
Sep 26 2010