www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3018] New: linefeed ignored after positional parameter in std.format

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: ghaecker 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 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: -------
May 22 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3018


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 11 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3018




PDT ---
This issue still persists in 2.048, although the exception thrown now is
FormatError, not RangeError.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 15 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3018


Glenn Haecker <ghaecker idworld.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |INVALID



PDT ---
You'd think that sometime in the 15-month period since I first reported this
"bug" someone would say, "No, you're an idiot. It works just fine when used
correctly."  Obviously, this is not a bug. My apologies.

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

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

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

writeln("\nWith positional parameters... works fine.");
writefln("  %1$s\n  %2$s\n  %3$s\n  %2$s\n  %1$s", line1, line2, line3);
writeln("(complete)");
--------------------------------------------------------------

Output:

With explicit parameters... ok
  line 1
  line 2
  line 3
  line 2
  line 1
(complete)

With positional parameters... works fine.
  line 1
  line 2
  line 3
  line 2
  line 1
(complete)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 15 2010