diff options
Diffstat (limited to 'libphobos/src')
-rw-r--r-- | libphobos/src/MERGE | 2 | ||||
-rw-r--r-- | libphobos/src/std/experimental/allocator/building_blocks/allocator_list.d | 18 | ||||
-rw-r--r-- | libphobos/src/std/experimental/allocator/common.d | 3 | ||||
-rw-r--r-- | libphobos/src/std/format/spec.d | 35 | ||||
-rw-r--r-- | libphobos/src/std/format/write.d | 23 | ||||
-rw-r--r-- | libphobos/src/std/numeric.d | 2 |
6 files changed, 64 insertions, 19 deletions
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index a4888fc..3dfe008 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -79cbde1ab69bae9372f310d663edfc43166095e3 +60034b56e2a036a66fa78cbc0ec0290956423684 The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/std/experimental/allocator/building_blocks/allocator_list.d b/libphobos/src/std/experimental/allocator/building_blocks/allocator_list.d index c6d5fca..9d30b5e 100644 --- a/libphobos/src/std/experimental/allocator/building_blocks/allocator_list.d +++ b/libphobos/src/std/experimental/allocator/building_blocks/allocator_list.d @@ -1140,7 +1140,6 @@ template SharedAllocatorList(alias factoryFunction, import std.algorithm.comparison : max; import std.typecons : Ternary; - enum pageSize = 4096; enum numPages = 2; static void testrw(void[] b) @@ -1269,8 +1268,6 @@ template SharedAllocatorList(alias factoryFunction, import std.algorithm.comparison : max; import std.typecons : Ternary; - enum pageSize = 4096; - static void testrw(void[] b) { ubyte* buf = cast(ubyte*) b.ptr; @@ -1283,17 +1280,17 @@ template SharedAllocatorList(alias factoryFunction, enum numPages = 5; AllocatorList!((n) => AscendingPageAllocator(max(n, numPages * pageSize)), NullAllocator) a; - auto b = a.alignedAllocate(1, pageSize * 2); + auto b = a.alignedAllocate(1, cast(uint) (pageSize * 2)); assert(b.length == 1); - assert(a.expand(b, 4095)); - assert(b.ptr.alignedAt(2 * 4096)); - assert(b.length == 4096); + assert(a.expand(b, pageSize - 1)); + assert(b.ptr.alignedAt(cast(uint) (pageSize * 2))); + assert(b.length == pageSize); - b = a.allocate(4096); - assert(b.length == 4096); + b = a.allocate(pageSize); + assert(b.length == pageSize); assert(a.allocators.length == 1); - assert(a.allocate(4096 * 5).length == 4096 * 5); + assert(a.allocate(pageSize * 5).length == pageSize * 5); assert(a.allocators.length == 2); assert(a.deallocateAll()); @@ -1339,7 +1336,6 @@ template SharedAllocatorList(alias factoryFunction, import std.algorithm.comparison : max; enum numThreads = 100; - enum pageSize = 4096; enum numPages = 10; SharedAllocatorList!((n) => SharedAscendingPageAllocator(max(n, pageSize * numPages)), Mallocator) a; diff --git a/libphobos/src/std/experimental/allocator/common.d b/libphobos/src/std/experimental/allocator/common.d index b06fb62..2451572 100644 --- a/libphobos/src/std/experimental/allocator/common.d +++ b/libphobos/src/std/experimental/allocator/common.d @@ -63,7 +63,8 @@ unittest class C2 { char c; } static assert(stateSize!C2 == 4 * size_t.sizeof); static class C3 { char c; } - static assert(stateSize!C3 == 2 * size_t.sizeof + char.sizeof); + // Uncomment test after dmd issue closed https://github.com/dlang/dmd/issues/21065 + //static assert(stateSize!C3 == 3 * size_t.sizeof); } /** diff --git a/libphobos/src/std/format/spec.d b/libphobos/src/std/format/spec.d index e5564c9..b828bb6 100644 --- a/libphobos/src/std/format/spec.d +++ b/libphobos/src/std/format/spec.d @@ -127,14 +127,16 @@ if (is(Unqual!Char == Char)) Counting starts with `1`. Set to `0` if not used. Default: `0`. */ - ubyte indexStart; + ushort indexStart; /** Index of the last argument for positional parameter ranges. Counting starts with `1`. Set to `0` if not used. Default: `0`. + + The maximum value of this field is used as a sentinel to indicate the arguments' length. */ - ubyte indexEnd; + ushort indexEnd; version (StdDdoc) { @@ -296,6 +298,8 @@ if (is(Unqual!Char == Char)) } width = 0; + indexStart = 0; + indexEnd = 0; precision = UNSPECIFIED; nested = null; // Parse the spec (we assume we're past '%' already) @@ -834,6 +838,33 @@ if (is(Unqual!Char == Char)) == "$ expected after '*10' in format string"); } +// https://github.com/dlang/phobos/issues/10713 +@safe pure unittest +{ + import std.array : appender; + auto f = FormatSpec!char("%3$d%d"); + + auto w = appender!(char[])(); + f.writeUpToNextSpec(w); + assert(f.indexStart == 3); + + f.writeUpToNextSpec(w); + assert(w.data.length == 0); + assert(f.indexStart == 0); +} + +// https://github.com/dlang/phobos/issues/10699 +@safe pure unittest +{ + import std.array : appender; + auto f = FormatSpec!char("%1:$d"); + auto w = appender!(char[])(); + + f.writeUpToNextSpec(w); + assert(f.indexStart == 1); + assert(f.indexEnd == ushort.max); +} + /** Helper function that returns a `FormatSpec` for a single format specifier. diff --git a/libphobos/src/std/format/write.d b/libphobos/src/std/format/write.d index 078fa78..d704c14 100644 --- a/libphobos/src/std/format/write.d +++ b/libphobos/src/std/format/write.d @@ -648,9 +648,16 @@ uint formattedWrite(Writer, Char, Args...)(auto ref Writer w, const scope Char[] break SWITCH; } default: - throw new FormatException( - text("Positional specifier %", spec.indexStart, '$', spec.spec, - " index exceeds ", Args.length)); + if (spec.indexEnd == spec.indexEnd.max) + break; + else if (spec.indexEnd == spec.indexStart) + throw new FormatException( + text("Positional specifier %", spec.indexStart, '$', spec.spec, + " index exceeds ", Args.length)); + else + throw new FormatException( + text("Positional specifier %", spec.indexStart, ":", spec.indexEnd, '$', spec.spec, + " index exceeds ", Args.length)); } } return currentArg; @@ -1199,6 +1206,16 @@ if (isSomeString!(typeof(fmt))) formattedWrite(stream, "%s", aa); } +// https://github.com/dlang/phobos/issues/10699 +@safe pure unittest +{ + import std.array : appender; + auto w = appender!(char[])(); + + formattedWrite(w, "%1:$d", 1, 2, 3); + assert(w.data == "123"); +} + /** Formats a value of any type according to a format specifier and writes the result to an output range. diff --git a/libphobos/src/std/numeric.d b/libphobos/src/std/numeric.d index 9966b1c..918984f 100644 --- a/libphobos/src/std/numeric.d +++ b/libphobos/src/std/numeric.d @@ -37,7 +37,7 @@ public enum CustomFloatFlags * Store values in normalized form by default. The actual precision of the * significand is extended by 1 bit by assuming an implicit leading bit of 1 * instead of 0. i.e. `1.nnnn` instead of `0.nnnn`. - * True for all $(LINK2 https://en.wikipedia.org/wiki/IEEE_floating_point, IEE754) types + * True for all $(LINK2 https://en.wikipedia.org/wiki/IEEE_floating_point, IEEE754) types */ storeNormalized = 2, |