lol
1--- a/stdlib/public/stubs/UnicodeNormalization.cpp
2+++ b/stdlib/public/stubs/UnicodeNormalization.cpp
3@@ -86,11 +86,8 @@ ASCIICollation() {
4 for (unsigned char c = 0; c < 128; ++c) {
5 UErrorCode ErrorCode = U_ZERO_ERROR;
6 intptr_t NumCollationElts = 0;
7-#if defined(__CYGWIN__) || defined(_MSC_VER)
8 UChar Buffer[1];
9-#else
10- uint16_t Buffer[1];
11-#endif
12+
13 Buffer[0] = c;
14
15 UCollationElements *CollationIterator =
16@@ -127,18 +124,9 @@ swift::_swift_stdlib_unicode_compare_utf16_utf16(const uint16_t *LeftString,
17 int32_t LeftLength,
18 const uint16_t *RightString,
19 int32_t RightLength) {
20-#if defined(__CYGWIN__) || defined(_MSC_VER)
21- // ICU UChar type is platform dependent. In Cygwin, it is defined
22- // as wchar_t which size is 2. It seems that the underlying binary
23- // representation is same with swift utf16 representation.
24 return ucol_strcoll(GetRootCollator(),
25 reinterpret_cast<const UChar *>(LeftString), LeftLength,
26 reinterpret_cast<const UChar *>(RightString), RightLength);
27-#else
28- return ucol_strcoll(GetRootCollator(),
29- LeftString, LeftLength,
30- RightString, RightLength);
31-#endif
32 }
33
34 /// Compares the strings via the Unicode Collation Algorithm on the root locale.
35@@ -156,12 +144,8 @@ swift::_swift_stdlib_unicode_compare_utf8_utf16(const unsigned char *LeftString,
36 UErrorCode ErrorCode = U_ZERO_ERROR;
37
38 uiter_setUTF8(&LeftIterator, reinterpret_cast<const char *>(LeftString), LeftLength);
39-#if defined(__CYGWIN__) || defined(_MSC_VER)
40 uiter_setString(&RightIterator, reinterpret_cast<const UChar *>(RightString),
41 RightLength);
42-#else
43- uiter_setString(&RightIterator, RightString, RightLength);
44-#endif
45
46 uint32_t Diff = ucol_strcollIter(GetRootCollator(),
47 &LeftIterator, &RightIterator, &ErrorCode);
48@@ -199,14 +183,10 @@ swift::_swift_stdlib_unicode_compare_utf8_utf8(const unsigned char *LeftString,
49 void *swift::_swift_stdlib_unicodeCollationIterator_create(
50 const __swift_uint16_t *Str, __swift_uint32_t Length) {
51 UErrorCode ErrorCode = U_ZERO_ERROR;
52-#if defined(__CYGWIN__) || defined(_MSC_VER)
53 UCollationElements *CollationIterator = ucol_openElements(
54 GetRootCollator(), reinterpret_cast<const UChar *>(Str), Length,
55 &ErrorCode);
56-#else
57- UCollationElements *CollationIterator = ucol_openElements(
58- GetRootCollator(), Str, Length, &ErrorCode);
59-#endif
60+
61 if (U_FAILURE(ErrorCode)) {
62 swift::crash("_swift_stdlib_unicodeCollationIterator_create: ucol_openElements() failed.");
63 }
64@@ -244,17 +224,12 @@ swift::_swift_stdlib_unicode_strToUpper(uint16_t *Destination,
65 const uint16_t *Source,
66 int32_t SourceLength) {
67 UErrorCode ErrorCode = U_ZERO_ERROR;
68-#if defined(__CYGWIN__) || defined(_MSC_VER)
69 uint32_t OutputLength = u_strToUpper(reinterpret_cast<UChar *>(Destination),
70 DestinationCapacity,
71 reinterpret_cast<const UChar *>(Source),
72 SourceLength,
73 "", &ErrorCode);
74-#else
75- uint32_t OutputLength = u_strToUpper(Destination, DestinationCapacity,
76- Source, SourceLength,
77- "", &ErrorCode);
78-#endif
79+
80 if (U_FAILURE(ErrorCode) && ErrorCode != U_BUFFER_OVERFLOW_ERROR) {
81 swift::crash("u_strToUpper: Unexpected error uppercasing unicode string.");
82 }
83@@ -271,17 +246,12 @@ swift::_swift_stdlib_unicode_strToLower(uint16_t *Destination,
84 const uint16_t *Source,
85 int32_t SourceLength) {
86 UErrorCode ErrorCode = U_ZERO_ERROR;
87-#if defined(__CYGWIN__) || defined(_MSC_VER)
88 uint32_t OutputLength = u_strToLower(reinterpret_cast<UChar *>(Destination),
89 DestinationCapacity,
90 reinterpret_cast<const UChar *>(Source),
91 SourceLength,
92 "", &ErrorCode);
93-#else
94- uint32_t OutputLength = u_strToLower(Destination, DestinationCapacity,
95- Source, SourceLength,
96- "", &ErrorCode);
97-#endif
98+
99 if (U_FAILURE(ErrorCode) && ErrorCode != U_BUFFER_OVERFLOW_ERROR) {
100 swift::crash("u_strToLower: Unexpected error lowercasing unicode string.");
101 }
102@@ -300,9 +300,9 @@
103
104 swift::__swift_stdlib_UBreakIterator *swift::__swift_stdlib_ubrk_open(
105 swift::__swift_stdlib_UBreakIteratorType type, const char *locale,
106- const UChar *text, int32_t textLength, __swift_stdlib_UErrorCode *status) {
107+ const __swift_stdlib_UChar * text, __swift_int32_t textLength, __swift_stdlib_UErrorCode *status) {
108 return ptr_cast<swift::__swift_stdlib_UBreakIterator>(
109- ubrk_open(static_cast<UBreakIteratorType>(type), locale, text, textLength,
110+ ubrk_open(static_cast<UBreakIteratorType>(type), locale, reinterpret_cast<const UChar *>(text), textLength,
111 ptr_cast<UErrorCode>(status)));
112 }
113