aboutsummaryrefslogtreecommitdiff
path: root/libphobos/src/std/format/package.d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-12-09 18:59:38 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2022-12-11 17:17:58 +0100
commit6d799f0aed18be25a5c908499b6411ab6d06b78c (patch)
tree3e6a91048c7fe3e78bae9f75b24eb37c5504681b /libphobos/src/std/format/package.d
parentcc7f509d3c0b3ab63891cf7ca2def0fdfb3642c4 (diff)
downloadgcc-6d799f0aed18be25a5c908499b6411ab6d06b78c.zip
gcc-6d799f0aed18be25a5c908499b6411ab6d06b78c.tar.gz
gcc-6d799f0aed18be25a5c908499b6411ab6d06b78c.tar.bz2
d: Merge upstream dmd, druntime c8ae4adb2e, phobos 792c8b7c1.
D front-end changes: - Import dmd v2.101.0. - Deprecate the ability to call `__traits(getAttributes)' on overload sets. - Deprecate non-empty `for' statement increment clause with no effect. - Array literals assigned to `scope' array variables can now be allocated on the stack. D runtime changes: - Import druntime v2.101.0. Phobos changes: - Import phobos v2.101.0. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd c8ae4adb2e. * typeinfo.cc (check_typeinfo_type): Update for new front-end interface. (TypeInfoVisitor::visit (TypeInfoStructDeclaration *)): Remove warning that toHash() must be declared 'nothrow @safe`. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime c8ae4adb2e. * src/MERGE: Merge upstream phobos 792c8b7c1.
Diffstat (limited to 'libphobos/src/std/format/package.d')
-rw-r--r--libphobos/src/std/format/package.d31
1 files changed, 26 insertions, 5 deletions
diff --git a/libphobos/src/std/format/package.d b/libphobos/src/std/format/package.d
index d83f028..f1d4705 100644
--- a/libphobos/src/std/format/package.d
+++ b/libphobos/src/std/format/package.d
@@ -212,17 +212,17 @@ There are several flags that affect the outcome of the formatting.
$(BOOKTABLE ,
$(TR $(TH Flag) $(TH Semantics))
$(TR $(TD $(B '-'))
- $(TD When the formatted result is shorter then the value
- given by the width parameter, the output is right
- justified. With the $(B '-') flag this is changed
- to left justification.
+ $(TD When the formatted result is shorter than the value
+ given by the width parameter, the output is left
+ justified. Without the $(B '-') flag, the output remains
+ right justified.
There are two exceptions where the $(B '-') flag has a
different meaning: (1) with $(B 'r') it denotes to use little
endian and (2) in case of a compound indicator it means that
no special handling of the members is applied.))
$(TR $(TD $(B '='))
- $(TD When the formatted result is shorter then the value
+ $(TD When the formatted result is shorter than the value
given by the width parameter, the output is centered.
If the central position is not possible it is moved slightly
to the right. In this case, if $(B '-') flag is present in
@@ -1563,6 +1563,14 @@ char[] sformat(Char, Args...)(return scope char[] buf, scope const(Char)[] fmt,
{
char[] buf;
size_t i;
+ void put(char c)
+ {
+ if (buf.length <= i)
+ throw new RangeError(__FILE__, __LINE__);
+
+ buf[i] = c;
+ i += 1;
+ }
void put(dchar c)
{
char[4] enc;
@@ -1687,6 +1695,19 @@ if (isSomeString!(typeof(fmt)))
assert(u == v);
}
+@safe unittest // https://issues.dlang.org/show_bug.cgi?id=23488
+{
+ static struct R
+ {
+ string s = "Ü";
+ bool empty() { return s.length == 0; }
+ char front() { return s[0]; }
+ void popFront() { s = s[1 .. $]; }
+ }
+ char[2] buf;
+ assert(sformat(buf, "%s", R()) == "Ü");
+}
+
version (StdUnittest)
private void formatReflectTest(T)(ref T val, string fmt, string formatted, string fn = __FILE__, size_t ln = __LINE__)
{