Bug 18047 – std.format value.length modulo seperator step width leads to wrong length

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-12-08T13:16:51Z
Last change time
2017-12-29T22:17:50Z
Assigned to
No Owner
Creator
Robert Schadek

Comments

Comment #0 by rburners — 2017-12-08T13:16:51Z
@safe unittest { auto cmp = " 123,456"; assert(cmp.length == 12, format("%d", cmp.length)); auto tmp = format("%12,d", 123456); assert(tmp.length == 12, format("%d", tmp.length)); assert(tmp == cmp, "'" ~ tmp ~ "'"); } The length of tmp should be 12, but it is 11. Does not depend on number type. The error also occurs with floats.
Comment #1 by github-bugzilla — 2017-12-09T17:30:43Z
Commit pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/aa92422b215c7109bd74bb1cad1226654b7b6f3b Merge pull request #5911 from burner/issue_17459_issue18047 Fix for two problems with format separators merged-on-behalf-of: Andrei Alexandrescu <[email protected]>
Comment #2 by github-bugzilla — 2017-12-18T22:57:34Z
Commit pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/aa92422b215c7109bd74bb1cad1226654b7b6f3b Merge pull request #5911 from burner/issue_17459_issue18047