1 Index: corlib.dll.sources
2 ===================================================================
3 --- corlib.dll.sources (revision 47189)
4 +++ corlib.dll.sources (working copy)
6 Microsoft.Win32/Win32RegistryApi.cs
7 Microsoft.Win32/Win32ResultCode.cs
8 Microsoft.Win32.SafeHandles/SafeFileHandle.cs
9 +Mono.Globalization.Unicode/CodePointIndexer.cs
10 +Mono.Globalization.Unicode/MSCompatUnicodeTable.cs
11 +Mono.Globalization.Unicode/MSCompatUnicodeTableUtil.cs
12 +Mono.Globalization.Unicode/SimpleCollator.cs
13 +Mono.Globalization.Unicode/SortKey.cs
14 +Mono.Globalization.Unicode/SortKeyBuffer.cs
16 Mono.Math/BigInteger.cs
17 Mono.Math.Prime/ConfidenceFactor.cs
19 System.Globalization/NumberFormatInfo.cs
20 System.Globalization/NumberStyles.cs
21 System.Globalization/RegionInfo.cs
22 -System.Globalization/SortKey.cs
23 System.Globalization/StringInfo.cs
24 System.Globalization/TaiwanCalendar.cs
25 System.Globalization/TextElementEnumerator.cs
27 ===================================================================
28 --- Makefile (revision 47189)
29 +++ Makefile (working copy)
31 include ../../build/rules.make
32 export __SECURITY_BOOTSTRAP_DB=$(topdir)/class/corlib
36 + collation.core.bin \
37 + collation.tailoring.bin \
38 + collation.cjkCHS.bin \
39 + collation.cjkCHT.bin \
40 + collation.cjkJA.bin \
41 + collation.cjkKO.bin \
42 + collation.cjkKOlv2.bin
44 # corlib is crazy to build so we skip build/library.make and do stuff
47 # Here, we define a bunch of variables.
49 corlib_flags = /unsafe /nostdlib
50 -LOCAL_MCS_FLAGS = /nowarn:649 /nowarn:169 /nowarn:414 -nowarn:612 -nowarn:618 -d:INSIDE_CORLIB
51 +LOCAL_MCS_FLAGS = /nowarn:649 /nowarn:169 /nowarn:414 -nowarn:612 -nowarn:618 -d:INSIDE_CORLIB \
52 + $(RESOURCE_FILES:%=/resource:%)
55 LIBRARY_NAME = mscorlib.dll
56 Index: System.Globalization/CompareInfo.cs
57 ===================================================================
58 --- System.Globalization/CompareInfo.cs (revision 47196)
59 +++ System.Globalization/CompareInfo.cs (working copy)
61 using System.Reflection;
62 using System.Runtime.Serialization;
63 using System.Runtime.CompilerServices;
64 +using Mono.Globalization.Unicode;
66 namespace System.Globalization
69 public class CompareInfo : IDeserializationCallback
71 + static readonly bool useManagedCollation =
72 + Environment.GetEnvironmentVariable ("MONO_USE_MANAGED_COLLATION")
75 + public static bool UseManagedCollation {
77 + if (!useManagedCollation)
79 + return MSCompatUnicodeTable.IsReady;
83 // Keep in synch with MonoCompareInfo in the runtime.
88 private IntPtr ICU_collator;
89 private int win32LCID; // Unused, but MS.NET serializes this
92 + SimpleCollator collator;
94 /* Hide the .ctor() */
97 internal CompareInfo (CultureInfo ci)
99 this.culture = ci.LCID;
100 - this.icu_name = ci.IcuName;
101 - this.construct_compareinfo (icu_name);
102 + if (UseManagedCollation)
103 + collator = new SimpleCollator (ci);
105 + this.icu_name = ci.IcuName;
106 + this.construct_compareinfo (icu_name);
110 [MethodImplAttribute (MethodImplOptions.InternalCall)]
111 private extern void free_internal_collator ();
116 - free_internal_collator ();
117 + if (UseManagedCollation)
120 + free_internal_collator ();
125 [MethodImplAttribute (MethodImplOptions.InternalCall)]
126 private extern int internal_compare (string str1, int offset1,
127 int length1, string str2,
128 int offset2, int length2,
129 CompareOptions options);
131 + private int internal_compare_managed (string str1, int offset1,
132 + int length1, string str2,
133 + int offset2, int length2,
134 + CompareOptions options)
136 + return collator.Compare (str1, offset1, length1,
137 + str2, offset2, length2, options);
140 + private int internal_compare_switch (string str1, int offset1,
141 + int length1, string str2,
142 + int offset2, int length2,
143 + CompareOptions options)
145 + return UseManagedCollation ?
146 + internal_compare_managed (str1, offset1, length1,
147 + str2, offset2, length2, options) :
148 + internal_compare (str1, offset1, length1,
149 + str2, offset2, length2, options);
152 public virtual int Compare (string string1, string string2)
154 - /* Short cuts... */
155 - if(string1.Length == 0) {
156 - if(string2.Length == 0) {
161 - } else if(string2.Length == 0) {
165 + if(string1.Length == 0 && string2.Length == 0)
168 - return(internal_compare (string1, 0, string1.Length,
169 + return(internal_compare_switch (string1, 0, string1.Length,
170 string2, 0, string2.Length,
171 CompareOptions.None));
174 public virtual int Compare (string string1, string string2,
175 CompareOptions options)
177 - /* Short cuts... */
178 - if(string1.Length == 0) {
179 - if(string2.Length == 0) {
184 - } else if(string2.Length == 0) {
188 + if(string1.Length == 0 && string2.Length == 0)
191 - return(internal_compare (string1, 0, string1.Length,
192 + return(internal_compare_switch (string1, 0, string1.Length,
193 string2, 0, string2.Length,
197 * the offset >= string length specified check
200 - if(string1.Length == 0 ||
201 - offset1 == string1.Length) {
202 - if(string2.Length == 0 ||
203 - offset2 == string2.Length) {
208 - } else if(string2.Length == 0 ||
209 - offset2 == string2.Length) {
212 + if ((string1.Length == 0 || offset1 == string1.Length) &&
213 + (string2.Length == 0 || offset2 == string2.Length))
216 if(offset1 < 0 || offset2 < 0) {
217 throw new ArgumentOutOfRangeException ("Offsets must not be less than zero");
219 throw new ArgumentOutOfRangeException ("Offset2 is greater than or equal to the length of string2");
222 - return(internal_compare (string1, offset1,
223 + return(internal_compare_switch (string1, offset1,
224 string1.Length-offset1,
226 string2.Length-offset2,
228 * the offset >= string length specified check
231 - if(string1.Length == 0 ||
232 - offset1 == string1.Length) {
233 - if(string2.Length == 0 ||
234 - offset2 == string2.Length) {
239 - } else if(string2.Length == 0 ||
240 - offset2 == string2.Length) {
243 + if((string1.Length == 0 || offset1 == string1.Length) &&
244 + (string2.Length == 0 || offset2 == string2.Length))
247 if(offset1 < 0 || offset2 < 0) {
248 throw new ArgumentOutOfRangeException ("Offsets must not be less than zero");
250 throw new ArgumentOutOfRangeException ("Offset2 is greater than or equal to the length of string2");
253 - return(internal_compare (string1, offset1,
254 + return(internal_compare_switch (string1, offset1,
255 string1.Length-offset1,
257 string2.Length-offset1,
258 @@ -203,21 +214,13 @@
259 * the offset >= string length specified check
262 - if(string1.Length == 0 ||
263 - offset1 == string1.Length ||
265 - if(string2.Length == 0 ||
266 - offset2 == string2.Length ||
272 - } else if(string2.Length == 0 ||
273 - offset2 == string2.Length ||
277 + if((string1.Length == 0 ||
278 + offset1 == string1.Length ||
280 + (string2.Length == 0 ||
281 + offset2 == string2.Length ||
285 if(offset1 < 0 || length1 < 0 ||
286 offset2 < 0 || length2 < 0) {
288 throw new ArgumentOutOfRangeException ("Length2 is greater than the number of characters from offset2 to the end of string2");
291 - return(internal_compare (string1, offset1, length1,
292 + return(internal_compare_switch (string1, offset1, length1,
293 string2, offset2, length2,
294 CompareOptions.None));
296 @@ -255,21 +258,13 @@
297 * the offset >= string length specified check
300 - if(string1.Length == 0 ||
301 - offset1 == string1.Length ||
303 - if(string2.Length == 0 ||
304 - offset2 == string2.Length ||
306 + if((string1.Length == 0 ||
307 + offset1 == string1.Length ||
309 + (string2.Length == 0 ||
310 + offset2 == string2.Length ||
316 - } else if(string2.Length == 0 ||
317 - offset2 == string2.Length ||
322 if(offset1 < 0 || length1 < 0 ||
323 offset2 < 0 || length2 < 0) {
325 throw new ArgumentOutOfRangeException ("Length2 is greater than the number of characters from offset2 to the end of string2");
328 - return(internal_compare (string1, offset1, length1,
329 + return(internal_compare_switch (string1, offset1, length1,
330 string2, offset2, length2,
334 public virtual SortKey GetSortKey(string source,
335 CompareOptions options)
337 + if (UseManagedCollation)
338 + return collator.GetSortKey (source, options);
339 SortKey key=new SortKey (culture, source, options);
341 /* Need to do the icall here instead of in the
343 int count, char value,
344 CompareOptions options,
348 + private int internal_index_managed (string s, int sindex,
349 + int count, char c, CompareOptions opt,
353 + collator.IndexOf (s, c, sindex, count, opt) :
354 + collator.LastIndexOf (s, c, sindex, count, opt);
357 + private int internal_index_switch (string s, int sindex,
358 + int count, char c, CompareOptions opt,
361 + return UseManagedCollation &&
362 + (CompareOptions.Ordinal & opt) == 0 ?
363 + internal_index_managed (s, sindex, count, c, opt, first) :
364 + internal_index (s, sindex, count, c, opt, first);
367 public virtual int IndexOf (string source, char value,
368 int startIndex, int count,
369 CompareOptions options)
374 - return (internal_index (source, startIndex,
375 + return (internal_index_switch (source, startIndex,
376 count, value, options,
380 int count, string value,
381 CompareOptions options,
385 + private int internal_index_managed (string s1, int sindex,
386 + int count, string s2, CompareOptions opt,
390 + collator.IndexOf (s1, s2, sindex, count, opt) :
391 + collator.LastIndexOf (s1, s2, sindex, count, opt);
394 + private int internal_index_switch (string s1, int sindex,
395 + int count, string s2, CompareOptions opt,
398 + return UseManagedCollation &&
399 + (CompareOptions.Ordinal & opt) == 0 ?
400 + internal_index_managed (s1, sindex, count, s2, opt, first) :
401 + internal_index (s1, sindex, count, s2, opt, first);
404 public virtual int IndexOf (string source, string value,
405 int startIndex, int count,
406 CompareOptions options)
411 - return (internal_index (source, startIndex, count,
412 + return (internal_index_switch (source, startIndex, count,
413 value, options, true));
417 throw new ArgumentNullException("prefix");
420 + if (UseManagedCollation)
421 + return collator.IsPrefix (source, prefix, options);
423 if(source.Length < prefix.Length) {
427 throw new ArgumentNullException("suffix");
430 + if (UseManagedCollation)
431 + return collator.IsSuffix (source, suffix, options);
433 if(source.Length < suffix.Length) {
440 - return (internal_index (source, startIndex,
441 + return (internal_index_switch (source, startIndex,
442 count, value, options,
449 - return(internal_index (source, startIndex, count,
450 + return(internal_index_switch (source, startIndex, count,
451 value, options, false));
454 @@ -724,13 +765,17 @@
456 void IDeserializationCallback.OnDeserialization(object sender)
458 - /* This will build the ICU collator, and store
459 - * the pointer in ICU_collator
462 - this.construct_compareinfo (icu_name);
464 - ICU_collator=IntPtr.Zero;
465 + if (UseManagedCollation) {
466 + collator = new SimpleCollator (new CultureInfo (culture));
468 + /* This will build the ICU collator, and store
469 + * the pointer in ICU_collator
472 + this.construct_compareinfo (icu_name);
474 + ICU_collator=IntPtr.Zero;