From dd3026f05111a0858ee87146ba9c37f164afa815 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 7 Jan 2025 01:05:54 +0100 Subject: d: Merge dmd, druntime 2b89c2909d, phobos bdedad3bf D front-end changes: - Import latest fixes from dmd v2.110.0-beta.1. D runtime changes: - Import latest fixes from druntime v2.110.0-beta.1. Phobos changes: - Import latest fixes from phobos v2.110.0-beta.1. - Added `popGrapheme' function to `std.uni'. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 2b89c2909d. * Make-lang.in (D_FRONTEND_OBJS): Rename d/basicmangle.o to d/mangle-basic.o, d/cppmangle.o to d/mangle-cpp.o, and d/dmangle.o to d/mangle-package.o. (d/mangle-%.o): New rule. * d-builtins.cc (maybe_set_builtin_1): Update for new front-end interface. * d-diagnostic.cc (verrorReport): Likewise. (verrorReportSupplemental): Likewise. * d-frontend.cc (getTypeInfoType): Likewise. * d-lang.cc (d_init_options): Likewise. (d_handle_option): Likewise. (d_post_options): Likewise. * d-target.cc (TargetC::contributesToAggregateAlignment): New. * d-tree.h (create_typeinfo): Adjust prototype. * decl.cc (layout_struct_initializer): Update for new front-end interface. * typeinfo.cc (create_typeinfo): Remove generate parameter. * types.cc (layout_aggregate_members): Update for new front-end interface. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 2b89c2909d. * src/MERGE: Merge upstream phobos bdedad3bf. --- libphobos/src/std/uni/package.d | 250 ++++++++++++++++++++++++++-------------- 1 file changed, 165 insertions(+), 85 deletions(-) (limited to 'libphobos/src/std/uni') diff --git a/libphobos/src/std/uni/package.d b/libphobos/src/std/uni/package.d index f7610c0..34d15e0 100644 --- a/libphobos/src/std/uni/package.d +++ b/libphobos/src/std/uni/package.d @@ -16,6 +16,7 @@ $(TR $(TD Decode) $(TD $(LREF byGrapheme) $(LREF decodeGrapheme) $(LREF graphemeStride) + $(LREF popGrapheme) )) $(TR $(TD Comparison) $(TD $(LREF icmp) @@ -708,8 +709,8 @@ import std.meta : AliasSeq; import std.range.primitives : back, ElementEncodingType, ElementType, empty, front, hasLength, hasSlicing, isForwardRange, isInputRange, isRandomAccessRange, popFront, put, save; -import std.traits : isConvertibleToString, isIntegral, isSomeChar, - isSomeString, Unqual, isDynamicArray; +import std.traits : isAutodecodableString, isConvertibleToString, isIntegral, + isSomeChar, isSomeString, Unqual, isDynamicArray; // debug = std_uni; import std.internal.unicode_tables; // generated file @@ -961,7 +962,7 @@ struct MultiArray(Types...) } void store(OutRange)(scope OutRange sink) const - if (isOutputRange!(OutRange, char)) + if (isOutputRange!(OutRange, char)) { import std.format.write : formattedWrite; formattedWrite(sink, "[%( 0x%x, %)]", offsets[]); @@ -1652,7 +1653,7 @@ if (is(T : ElementType!Range)) template sharMethod(alias uniLowerBound) { size_t sharMethod(alias _pred="a !x.isAlpha); + // Windows-style line ending is two code points in a single grapheme. + assert(testPiece.popGrapheme() == 2); + assert(testPiece.equal("!"d)); +} + +// Attribute compliance test. Should be nothrow `@nogc` when +// no autodecoding needed. +@safe pure nothrow @nogc unittest +{ + import std.algorithm.iteration : filter; + + auto str = "abcdef"d; + assert(str.popGrapheme() == 1); + + // also test with non-random access + auto filtered = "abcdef"d.filter!(x => x%2); + assert(filtered.popGrapheme() == 1); +} + +/++ $(P Iterate a string by $(LREF Grapheme).) $(P Useful for doing string manipulation that needs to be aware @@ -7556,15 +7636,15 @@ if (isInputRange!Range && is(immutable ElementType!Range == immutable dchar)) public: /// Ctor this(C)(const scope C[] chars...) - if (is(C : dchar)) + if (is(C : dchar)) { this ~= chars; } ///ditto this(Input)(Input seq) - if (!isDynamicArray!Input - && isInputRange!Input && is(ElementType!Input : dchar)) + if (!isDynamicArray!Input + && isInputRange!Input && is(ElementType!Input : dchar)) { this ~= seq; } @@ -7683,7 +7763,7 @@ public: /// Append all $(CHARACTERS) from the input range `inp` to this Grapheme. ref opOpAssign(string op, Input)(scope Input inp) - if (isInputRange!Input && is(ElementType!Input : dchar)) + if (isInputRange!Input && is(ElementType!Input : dchar)) { static if (op == "~") { @@ -7722,7 +7802,7 @@ public: @property bool valid()() /*const*/ { auto r = this[]; - genericDecodeGrapheme!false(r); + genericDecodeGrapheme!(GraphemeRet.none)(r); return r.length == 0; } @@ -9868,7 +9948,7 @@ private template toCaseInPlaceAlloc(alias indexFn, uint maxIdx, alias tableFn) { void toCaseInPlaceAlloc(C)(ref C[] s, size_t curIdx, size_t destIdx) @trusted pure - if (is(C == char) || is(C == wchar) || is(C == dchar)) + if (is(C == char) || is(C == wchar) || is(C == dchar)) { import std.utf : decode; alias caseLength = toCaseLength!(indexFn, maxIdx, tableFn); -- cgit v1.1