diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2023-07-10 17:16:17 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2023-07-10 23:31:29 +0200 |
commit | e9251fea2debebfebe1f762a4a8d5b3b1d4c75ef (patch) | |
tree | 09b47f4d760019131aa27d19bfb8e5ee0f1ed31f /libphobos/src/std/uni | |
parent | 2d7c95e31431a297060c94697af84f498abf97a2 (diff) | |
download | gcc-e9251fea2debebfebe1f762a4a8d5b3b1d4c75ef.zip gcc-e9251fea2debebfebe1f762a4a8d5b3b1d4c75ef.tar.gz gcc-e9251fea2debebfebe1f762a4a8d5b3b1d4c75ef.tar.bz2 |
d: Merge upstream dmd, druntime a88e1335f7, phobos 1921d29df.
D front-end changes:
- Import dmd v2.104.1.
- Deprecation phase ended for access to private method when
overloaded with public method.
D runtime changes:
- Import druntime v2.104.1.
- Linux input header translations were added to druntime.
- Integration with the Valgrind `memcheck' tool has been added
to the garbage collector.
Phobos changes:
- Import phobos v2.104.1.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd a88e1335f7.
* dmd/VERSION: Bump version to v2.104.1.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime a88e1335f7.
* src/MERGE: Merge upstream phobos 1921d29df.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac (libphobos-checking): Add valgrind flag.
(DRUNTIME_LIBRARIES_VALGRIND): Call.
* libdruntime/Makefile.am (DRUNTIME_CSOURCES): Add
etc/valgrind/valgrind_.c.
(DRUNTIME_DSOURCES): Add etc/valgrind/valgrind.d.
(DRUNTIME_DSOURCES_LINUX): Add core/sys/linux/input.d,
core/sys/linux/input_event_codes.d, core/sys/linux/uinput.d.
* libdruntime/Makefile.in: Regenerate.
* m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_VALGRIND): Define.
Diffstat (limited to 'libphobos/src/std/uni')
-rw-r--r-- | libphobos/src/std/uni/package.d | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/libphobos/src/std/uni/package.d b/libphobos/src/std/uni/package.d index e2a0de7..6ab6ba0 100644 --- a/libphobos/src/std/uni/package.d +++ b/libphobos/src/std/uni/package.d @@ -8592,7 +8592,7 @@ public: Decomposes a Hangul syllable. If `ch` is not a composed syllable then this function returns $(LREF Grapheme) containing only `ch` as is. */ -Grapheme decomposeHangul(dchar ch) @safe +Grapheme decomposeHangul(dchar ch) nothrow pure @safe { immutable idxS = cast(int) ch - jamoSBase; if (idxS < 0 || idxS >= jamoSCount) return Grapheme(ch); @@ -8709,7 +8709,15 @@ enum { In cases where the string in question is already normalized, it is returned unmodified and no memory allocation happens. +/ -inout(C)[] normalize(NormalizationForm norm=NFC, C)(return scope inout(C)[] input) +/* + WARNING: @trusted lambda inside - handle with same care as @trusted + functions + + Despite being a template, the attributes do no harm since this doesn't work + with user-defined range or character types anyway. +*/ +pure @safe inout(C)[] normalize(NormalizationForm norm=NFC, C) + (return scope inout(C)[] input) { import std.algorithm.mutation : SwapStrategy; import std.algorithm.sorting : sort; @@ -8790,20 +8798,24 @@ inout(C)[] normalize(NormalizationForm norm=NFC, C)(return scope inout(C)[] inpu // reset variables decomposed.length = 0; () @trusted { - decomposed.assumeSafeAppend(); + // assumeSafeAppend isn't considered pure as of writing, hence the + // cast. It isn't pure in the sense that the elements after + // the array in question are affected, but we don't use those + // making the call pure for our purposes. + (cast(void delegate() pure nothrow) {decomposed.assumeSafeAppend();})(); ccc.length = 0; - ccc.assumeSafeAppend(); + (cast(void delegate() pure nothrow) {ccc.assumeSafeAppend();})(); } (); input = input[anchors[1]..$]; // and move on anchors = splitNormalized!norm(input); - }while (anchors[0] != input.length); + } while (anchors[0] != input.length); app.put(input[0 .. anchors[0]]); return () @trusted inout { return cast(inout(C)[]) app.data; } (); } /// -@safe unittest +@safe pure unittest { // any encoding works wstring greet = "Hello world"; @@ -8817,7 +8829,7 @@ inout(C)[] normalize(NormalizationForm norm=NFC, C)(return scope inout(C)[] inpu assert(normalize!NFKD("ϓ") == "\u03A5\u0301"); } -@safe unittest +@safe pure unittest { import std.conv : text; @@ -8825,18 +8837,9 @@ inout(C)[] normalize(NormalizationForm norm=NFC, C)(return scope inout(C)[] inpu assert(normalize!NFKD("2¹⁰") == "210", normalize!NFKD("2¹⁰")); assert(normalize!NFD("Äffin") == "A\u0308ffin"); - // check example - - // any encoding works - wstring greet = "Hello world"; + // test with dstring + dstring greet = "Hello world"; assert(normalize(greet) is greet); // the same exact slice - - // An example of a character with all 4 forms being different: - // Greek upsilon with acute and hook symbol (code point 0x03D3) - assert(normalize!NFC("ϓ") == "\u03D3"); - assert(normalize!NFD("ϓ") == "\u03D2\u0301"); - assert(normalize!NFKC("ϓ") == "\u038E"); - assert(normalize!NFKD("ϓ") == "\u03A5\u0301"); } // canonically recompose given slice of code points, works in-place and mutates data |