Bug 2783 – Truncation of long string by std.stdio.write

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-04-02T05:01:00Z
Last change time
2015-06-09T01:18:23Z
Assigned to
andrei
Creator
steve.teale

Attachments

IDFilenameSummaryContent-TypeSize
310middle.txtThe file used in my description of the issuetext/plain88764

Comments

Comment #0 by steve.teale — 2009-04-02T05:01:18Z
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
Comment #1 by steve.teale — 2009-04-02T05:03:48Z
Created attachment 310 The file used in my description of the issue
Comment #2 by dfj1esp02 — 2009-04-02T07:40:35Z
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);
Comment #3 by andrei — 2009-04-02T08:23:53Z
I've fixed the problem, will be part of the next release. Andrei
Comment #4 by andrei — 2010-09-26T14:25:37Z
Fixed a while ago.