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