[Issue 8730] writeln stops on a nul character, even if passed a D string
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 4 17:17:28 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8730
Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |andrej.mitrovich at gmail.com
--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-10-04 17:11:33 PDT ---
I'm just guessing, but:
void writeln(T...)(T args)
{
static if (T.length == 0)
{
enforce(fputc('\n', .stdout.p.handle) == '\n');
}
else static if (T.length == 1 &&
is(typeof(args[0]) : const(char)[]) &&
!is(typeof(args[0]) == enum) && !is(typeof(args[0]) ==
typeof(null)) &&
!isAggregateType!(typeof(args[0])))
{
// Specialization for strings - a very frequent case
enforce(fprintf(.stdout.p.handle, "%.*s\n",
cast(int) args[0].length, args[0].ptr) >= 0);
}
else
{
// Most general instance
stdout.write(args, '\n');
}
}
The specialization is probably to blame. I think 'args[0].length' probably sets
the max limit rather than min, but I don't know enough about fprintf internals.
:)
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list