1 Index: corlib.dll.sources
2 ===================================================================
3 --- corlib.dll.sources (revision 47350)
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 47350)
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/String.cs
57 ===================================================================
58 --- System/String.cs (revision 47350)
59 +++ System/String.cs (working copy)
61 if (this.length < value.length)
64 - return (0 == Compare (this, 0, value, 0 , value.length));
65 + return CultureInfo.CurrentCulture.CompareInfo.IsPrefix (this, value);
68 /* This method is culture insensitive */
69 Index: System.Globalization/CompareInfo.cs
70 ===================================================================
71 --- System.Globalization/CompareInfo.cs (revision 47350)
72 +++ System.Globalization/CompareInfo.cs (working copy)
74 using System.Reflection;
75 using System.Runtime.Serialization;
76 using System.Runtime.CompilerServices;
77 +using Mono.Globalization.Unicode;
79 namespace System.Globalization
82 public class CompareInfo : IDeserializationCallback
84 + static readonly bool useManagedCollation =
85 + Environment.GetEnvironmentVariable ("MONO_USE_MANAGED_COLLATION")
88 + public static bool UseManagedCollation {
90 + if (!useManagedCollation)
92 + return MSCompatUnicodeTable.IsReady;
96 // Keep in synch with MonoCompareInfo in the runtime.
101 private IntPtr ICU_collator;
102 private int win32LCID; // Unused, but MS.NET serializes this
105 + SimpleCollator collator;
107 /* Hide the .ctor() */
110 internal CompareInfo (CultureInfo ci)
112 this.culture = ci.LCID;
113 - this.icu_name = ci.IcuName;
114 - this.construct_compareinfo (icu_name);
115 + if (UseManagedCollation)
116 + collator = new SimpleCollator (ci);
118 + this.icu_name = ci.IcuName;
119 + this.construct_compareinfo (icu_name);
123 [MethodImplAttribute (MethodImplOptions.InternalCall)]
124 private extern void free_internal_collator ();
129 - free_internal_collator ();
130 + if (UseManagedCollation)
133 + free_internal_collator ();
138 [MethodImplAttribute (MethodImplOptions.InternalCall)]
139 private extern int internal_compare (string str1, int offset1,
140 int length1, string str2,
141 int offset2, int length2,
142 CompareOptions options);
144 + private int internal_compare_managed (string str1, int offset1,
145 + int length1, string str2,
146 + int offset2, int length2,
147 + CompareOptions options)
149 + return collator.Compare (str1, offset1, length1,
150 + str2, offset2, length2, options);
153 + private int internal_compare_switch (string str1, int offset1,
154 + int length1, string str2,
155 + int offset2, int length2,
156 + CompareOptions options)
158 + return UseManagedCollation ?
159 + internal_compare_managed (str1, offset1, length1,
160 + str2, offset2, length2, options) :
161 + internal_compare (str1, offset1, length1,
162 + str2, offset2, length2, options);
165 public virtual int Compare (string string1, string string2)
167 - /* Short cuts... */
168 - if(string1.Length == 0) {
169 - if(string2.Length == 0) {
174 - } else if(string2.Length == 0) {
178 + if(string1.Length == 0 && string2.Length == 0)
181 - return(internal_compare (string1, 0, string1.Length,
182 + return(internal_compare_switch (string1, 0, string1.Length,
183 string2, 0, string2.Length,
184 CompareOptions.None));
187 public virtual int Compare (string string1, string string2,
188 CompareOptions options)
190 - /* Short cuts... */
191 - if(string1.Length == 0) {
192 - if(string2.Length == 0) {
197 - } else if(string2.Length == 0) {
201 + if(string1.Length == 0 && string2.Length == 0)
204 - return(internal_compare (string1, 0, string1.Length,
205 + return(internal_compare_switch (string1, 0, string1.Length,
206 string2, 0, string2.Length,
210 * the offset >= string length specified check
213 - if(string1.Length == 0 ||
214 - offset1 == string1.Length) {
215 - if(string2.Length == 0 ||
216 - offset2 == string2.Length) {
221 - } else if(string2.Length == 0 ||
222 - offset2 == string2.Length) {
225 + if ((string1.Length == 0 || offset1 == string1.Length) &&
226 + (string2.Length == 0 || offset2 == string2.Length))
229 if(offset1 < 0 || offset2 < 0) {
230 throw new ArgumentOutOfRangeException ("Offsets must not be less than zero");
232 throw new ArgumentOutOfRangeException ("Offset2 is greater than or equal to the length of string2");
235 - return(internal_compare (string1, offset1,
236 + return(internal_compare_switch (string1, offset1,
237 string1.Length-offset1,
239 string2.Length-offset2,
241 * the offset >= string length specified check
244 - if(string1.Length == 0 ||
245 - offset1 == string1.Length) {
246 - if(string2.Length == 0 ||
247 - offset2 == string2.Length) {
252 - } else if(string2.Length == 0 ||
253 - offset2 == string2.Length) {
256 + if((string1.Length == 0 || offset1 == string1.Length) &&
257 + (string2.Length == 0 || offset2 == string2.Length))
260 if(offset1 < 0 || offset2 < 0) {
261 throw new ArgumentOutOfRangeException ("Offsets must not be less than zero");
263 throw new ArgumentOutOfRangeException ("Offset2 is greater than or equal to the length of string2");
266 - return(internal_compare (string1, offset1,
267 + return(internal_compare_switch (string1, offset1,
268 string1.Length-offset1,
270 string2.Length-offset1,
271 @@ -203,21 +214,13 @@
272 * the offset >= string length specified check
275 - if(string1.Length == 0 ||
276 - offset1 == string1.Length ||
278 - if(string2.Length == 0 ||
279 - offset2 == string2.Length ||
285 - } else if(string2.Length == 0 ||
286 - offset2 == string2.Length ||
290 + if((string1.Length == 0 ||
291 + offset1 == string1.Length ||
293 + (string2.Length == 0 ||
294 + offset2 == string2.Length ||
298 if(offset1 < 0 || length1 < 0 ||
299 offset2 < 0 || length2 < 0) {
301 throw new ArgumentOutOfRangeException ("Length2 is greater than the number of characters from offset2 to the end of string2");
304 - return(internal_compare (string1, offset1, length1,
305 + return(internal_compare_switch (string1, offset1, length1,
306 string2, offset2, length2,
307 CompareOptions.None));
309 @@ -255,21 +258,13 @@
310 * the offset >= string length specified check
313 - if(string1.Length == 0 ||
314 - offset1 == string1.Length ||
316 - if(string2.Length == 0 ||
317 - offset2 == string2.Length ||
319 + if((string1.Length == 0 ||
320 + offset1 == string1.Length ||
322 + (string2.Length == 0 ||
323 + offset2 == string2.Length ||
329 - } else if(string2.Length == 0 ||
330 - offset2 == string2.Length ||
335 if(offset1 < 0 || length1 < 0 ||
336 offset2 < 0 || length2 < 0) {
338 throw new ArgumentOutOfRangeException ("Length2 is greater than the number of characters from offset2 to the end of string2");
341 - return(internal_compare (string1, offset1, length1,
342 + return(internal_compare_switch (string1, offset1, length1,
343 string2, offset2, length2,
347 public virtual SortKey GetSortKey(string source,
348 CompareOptions options)
350 + if (UseManagedCollation)
351 + return collator.GetSortKey (source, options);
352 SortKey key=new SortKey (culture, source, options);
354 /* Need to do the icall here instead of in the
356 int count, char value,
357 CompareOptions options,
361 + private int internal_index_managed (string s, int sindex,
362 + int count, char c, CompareOptions opt,
366 + collator.IndexOf (s, c, sindex, count, opt) :
367 + collator.LastIndexOf (s, c, sindex, count, opt);
370 + private int internal_index_switch (string s, int sindex,
371 + int count, char c, CompareOptions opt,
374 + return UseManagedCollation &&
375 + (CompareOptions.Ordinal & opt) == 0 ?
376 + internal_index_managed (s, sindex, count, c, opt, first) :
377 + internal_index (s, sindex, count, c, opt, first);
380 public virtual int IndexOf (string source, char value,
381 int startIndex, int count,
382 CompareOptions options)
387 - return (internal_index (source, startIndex,
388 + return (internal_index_switch (source, startIndex,
389 count, value, options,
393 int count, string value,
394 CompareOptions options,
398 + private int internal_index_managed (string s1, int sindex,
399 + int count, string s2, CompareOptions opt,
403 + collator.IndexOf (s1, s2, sindex, count, opt) :
404 + collator.LastIndexOf (s1, s2, sindex, count, opt);
407 + private int internal_index_switch (string s1, int sindex,
408 + int count, string s2, CompareOptions opt,
411 + return UseManagedCollation &&
412 + (CompareOptions.Ordinal & opt) == 0 ?
413 + internal_index_managed (s1, sindex, count, s2, opt, first) :
414 + internal_index (s1, sindex, count, s2, opt, first);
417 public virtual int IndexOf (string source, string value,
418 int startIndex, int count,
419 CompareOptions options)
424 - return (internal_index (source, startIndex, count,
425 + return (internal_index_switch (source, startIndex, count,
426 value, options, true));
430 throw new ArgumentNullException("prefix");
433 + if (UseManagedCollation)
434 + return collator.IsPrefix (source, prefix, options);
436 if(source.Length < prefix.Length) {
440 throw new ArgumentNullException("suffix");
443 + if (UseManagedCollation)
444 + return collator.IsSuffix (source, suffix, options);
446 if(source.Length < suffix.Length) {
453 - return (internal_index (source, startIndex,
454 + return (internal_index_switch (source, startIndex,
455 count, value, options,
462 - return(internal_index (source, startIndex, count,
463 + return(internal_index_switch (source, startIndex, count,
464 value, options, false));
467 @@ -724,13 +765,17 @@
469 void IDeserializationCallback.OnDeserialization(object sender)
471 - /* This will build the ICU collator, and store
472 - * the pointer in ICU_collator
475 - this.construct_compareinfo (icu_name);
477 - ICU_collator=IntPtr.Zero;
478 + if (UseManagedCollation) {
479 + collator = new SimpleCollator (new CultureInfo (culture));
481 + /* This will build the ICU collator, and store
482 + * the pointer in ICU_collator
485 + this.construct_compareinfo (icu_name);
487 + ICU_collator=IntPtr.Zero;