When D is not nice

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Jul 7 19:38:39 PDT 2008


"Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote in message 
news:g4ujs8$2d2m$1 at digitalmars.com...
> "Nick Sabalausky" <a at a.a> wrote in message 
> news:g4uip0$2ag1$1 at digitalmars.com...
>
>>> import std.stdio, std.string;
>>>
>>> void main()
>>> {
>>>    string shit = "I embed a %s thing";
>>>    // ...
>>>    writeln(format("innocent formatting string ", shit));
>>> }
>>>
>>> this will fail dynamically. the problem is that any string argument is 
>>> searched for %. that bad behavior was fixed in writefln but not in 
>>> string.format. writefln only parses its first string for % shit but not 
>>> the others. as it should.
>>
>> If that's true and hasn't been fixed, you should probably submit a 
>> bugzilla report if you/someone else hasn't already.
>
> It's true and expected behavior in phobos 1.  All strings are interpreted 
> as format strings unless they themselves are formatted into another string 
> using %s.  Phobos 2 only interprets the first parameter as a format 
> string, so it won't break there.

Actually that seems only to be writefln in Phobos 2, not sure about format. 





More information about the Digitalmars-d mailing list