[Issue 3018] New: linefeed ignored after positional parameter in std.format

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 22 19:11:14 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3018

           Summary: linefeed ignored after positional parameter in
                    std.format
           Product: D
           Version: 2.030
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: ghaecker at idworld.net


In std.format, a linefeed after a positional parameter is ignored.  A format
string ending with a positional parameter throws RangeError.

--------------------------------------------------------------
// Demo code

string line1 = "line 1";
string line2 = "line 2";

writefln("With %%s parameters... ok");
writefln("  %s\n  %s\n  %s", line1, line2, line1);

writefln("\nWith positional parameters... ignores linefeed");
writefln("  %1$\n  %2$\n  %1$\n", line1, line2);

writefln("\nWithout trailing linefeed... throws RangeError");
writefln("  %1$\n  %2$\n  %1$", line1, line2);
--------------------------------------------------------------

Output:

With %s parameters... ok
  line 1
  line 2
  line 1

With positional parameters... ignores linefeed
  line 1  line 2  line 1

Without trailing linefeed... throws RangeError
core.exception.RangeError at std.format(1578): Range violation
  line 1  line 2

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