Thread overview
[Issue 761] New: std.format.doFormat fails for items of a char[][] containing %s
Dec 28, 2006
d-bugmail
Dec 28, 2006
d-bugmail
Dec 29, 2006
d-bugmail
December 28, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=761

           Summary: std.format.doFormat fails for items of a char[][]
                    containing %s
           Product: D
           Version: 0.178
          Platform: PC
               URL: http://www.digitalmars.com/webnews/newsgroups.php?art_gr
                    oup=digitalmars.D.announce&article_id=6505
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: lio@lunesu.com


#import std.stdio;
#void main() {
#   const char[][] x = ["%s","123"];
#   writefln(x);
#}

C:\dmd>dmd -run bug
[Error: std.format

This happens because doFormat is called recursively, once for each of the elements of the array. This means that there should never be any parsing for string elements, since there'll never be any 2nd argument to be formatted.

A possible fix (+patch) can be found at: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=6505

"Because the new doFormat takes the extra "bool parse" parameter, the fix is simple: invoke doFormat with parse set to false."


-- 

December 28, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=761





------- Comment #1 from lio@lunesu.com  2006-12-28 14:23 -------
Created an attachment (id=85)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=85&action=view)
Fix by adding "bool parse" argument to doFormat; Adds
write,writeln,fwrite,fwriteln


-- 

December 29, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=761


brunodomedeiros+bugz@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |652




------- Comment #2 from brunodomedeiros+bugz@gmail.com  2006-12-28 18:05 -------
See also #652


--