Selaa lähdekoodia

2007-01-25 Atsushi Enomoto <[email protected]>

	* SimpleCollator.cs : GetTailContraction() was broken to pick correct
	  contraction/special sortkey out and thus LastIndexOf() failed when 
	  it is involved. Fixed bug #80612.

	* CompareInfoTest.cs : added test for bug #80612.


svn path=/trunk/mcs/; revision=71632
Atsushi Eno 19 vuotta sitten
vanhempi
sitoutus
17cd7585e6

+ 6 - 0
mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog

@@ -1,3 +1,9 @@
+2007-01-25  Atsushi Enomoto  <[email protected]>
+
+	* SimpleCollator.cs : GetTailContraction() was broken to pick correct
+	  contraction/special sortkey out and thus LastIndexOf() failed when 
+	  it is involved. Fixed bug #80612.
+
 2007-01-22  Atsushi Enomoto  <[email protected]>
 
 	* SimpleCollator.cs : for non-StringSort comparison, level5 (- and ')

+ 9 - 9
mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs

@@ -352,21 +352,21 @@ Console.WriteLine (" -> '{0}'", c.Replacement);
 				throw new SystemException (String.Format ("MONO internal error. Failed to get TailContraction. start = {0} end = {1} string = '{2}'", start, end, s));
 			for (int i = 0; i < clist.Length; i++) {
 				Contraction ct = clist [i];
-				int diff = ct.Source [0] - s [end + 1];
-				if (diff > 0)
-					return null; // it's already sorted
-				else if (diff < 0)
-					continue;
 				char [] chars = ct.Source;
-
-				bool match = true;
 				if (chars.Length > start - end)
 					continue;
-				for (int n = 0; n < chars.Length; n++)
-					if (s [start - n] != chars [chars.Length - 1 - n]) {
+				if (chars [chars.Length - 1] != s [start])
+					continue;
+
+				bool match = true;
+				for (int n = 0, spos = start - chars.Length + 1;
+				     n < chars.Length;
+				     n++, spos++) {
+					if (s [spos] != chars [n]) {
 						match = false;
 						break;
 					}
+				}
 				if (match)
 					return ct;
 			}

+ 4 - 0
mcs/class/corlib/Test/System.Globalization/ChangeLog

@@ -1,3 +1,7 @@
+2007-01-25  Atsushi Enomoto  <[email protected]>
+
+	* CompareInfoTest.cs : added test for bug #80612.
+
 2007-01-22  Atsushi Enomoto  <[email protected]>
 
 	* CompareInfoTest.cs : Added Compare() tests for hyphens.

+ 5 - 0
mcs/class/corlib/Test/System.Globalization/CompareInfoTest.cs

@@ -851,6 +851,8 @@ public class CompareInfoTest : Assertion
 		AssertLastIndexOf ("#11", 0, "\\", '\\');
 		AssertEquals ("#11en", 0, new CultureInfo ("en").CompareInfo.LastIndexOf ("\\", '\\'));
 		AssertEquals ("#11ja", 0, new CultureInfo ("ja").CompareInfo.LastIndexOf ("\\", '\\'));
+		AssertLastIndexOf ("#12", 8, "/system/web", 'w');
+		AssertEquals ("#12sv", 8, new CultureInfo ("sv").CompareInfo.LastIndexOf ("/system/web", 'w'));
 	}
 
 	[Test]
@@ -1084,6 +1086,9 @@ public class CompareInfoTest : Assertion
 		AssertLastIndexOf ("#19", 0, "\\b\\a a", "\\b\\a a");
 		AssertEquals ("#19en", 0, new CultureInfo ("en").CompareInfo.LastIndexOf ("\\b\\a a", "\\b\\a a"));
 		AssertEquals ("#19ja", 0, new CultureInfo ("ja").CompareInfo.LastIndexOf ("\\b\\a a", "\\b\\a a"));
+		// bug #80612
+		AssertLastIndexOf ("#20", 8, "/system/web", "w");
+		AssertEquals ("#20sv", 8, new CultureInfo ("sv").CompareInfo.LastIndexOf ("/system/web", "w"));
 	}
 
 	[Test]