Bug 16336 – Inconsistent flag handling of std.format.FormatSpec

Status
NEW
Severity
minor
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2016-07-29T15:49:55Z
Last change time
2024-12-01T16:27:38Z
Assigned to
No Owner
Creator
Ryuichi OHORI
See also
https://issues.dlang.org/show_bug.cgi?id=3248
Moved to GitHub: phobos#10194 →

Comments

Comment #0 by r.97all — 2016-07-29T15:49:55Z
import std.format; struct FormatSpecPrinter { void toString(scope void delegate(const(char)[]) sink, FormatSpec!char fmt) { sink.formattedWrite("%s", fmt); } } void main() { import std.stdio; "%(%(%s%)%)".writefln(FormatSpecPrinter()); // just fine. "%-(%-(%s%)%)".writefln(FormatSpecPrinter()); // dash is nicely handled. "%+(%(%s%)%)".writefln(FormatSpecPrinter()); // OK: plus flag for outer %(..%). "%(%+(%s%)%)".writefln(FormatSpecPrinter()); // inner plus flag crashes: first "%)" matches "%(" and the second "%)" left orphan. } Like in the example in the wiki article, I'd like to use '+' flag for another meaning, in a nested way. https://wiki.dlang.org/Defining_custom_print_format_specifiers So, I'd like '+' flags to be allowed both for outermost and nested '(' specifier. However, current implementation considers only "%-(" when looking for the matching "%)" of outer "%(". https://github.com/dlang/phobos/blob/f75eeb596d44544e98a23ee1fd0b60f9ae8b0956/std/format.d#L918
Comment #1 by robert.schadek — 2024-12-01T16:27:38Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10194 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB