When D is not nice

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Jul 7 19:36:56 PDT 2008


"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. 





More information about the Digitalmars-d mailing list