Merge pull request #297 from ermshiperete/4959
[mono.git] / mcs / class / corlib / Mono.Globalization.Unicode / SortKeyBuffer.cs
index 46b69817c0eb23164edfc3caf7cbc145914ca5fe..61e909aa1d97f15ca49ce1134e0f70ad909265b9 100644 (file)
@@ -37,16 +37,16 @@ namespace Mono.Globalization.Unicode
        {
                // l4s = small kana sensitivity, l4t = mark type,
                // l4k = katakana flag, l4w = kana width sensitivity
-               int l1, l2, l3, l4s, l4t, l4k, l4w, l5;
                byte [] l1b, l2b, l3b, l4sb, l4tb, l4kb, l4wb, l5b;
-               int level5LastPos;
+//             int level5LastPos;
 
                string source;
+               int l1, l2, l3, l4s, l4t, l4k, l4w, l5;
+               int lcid;
+               CompareOptions options;
                bool processLevel2;
                bool frenchSort;
                bool frenchSorted;
-               int lcid;
-               CompareOptions options;
 
                public SortKeyBuffer (int lcid)
                {
@@ -55,7 +55,7 @@ namespace Mono.Globalization.Unicode
                public void Reset ()
                {
                        l1 = l2 = l3 = l4s = l4t = l4k = l4w = l5 = 0;
-                       level5LastPos = 0;
+//                     level5LastPos = 0;
                        frenchSorted = false;
                }
 
@@ -195,7 +195,7 @@ namespace Mono.Globalization.Unicode
                        AppendBufferPrimitive ((byte) ((offsetValue / 64) + 0x80), ref l5b, ref l5);
                        AppendBufferPrimitive ((byte) (offsetValue % 64 * 4 + 3), ref l5b, ref l5);
 
-                       level5LastPos = l2;
+//                     level5LastPos = l2;
 
                        // sortkey value
                        AppendBufferPrimitive (category, ref l5b, ref l5);
@@ -234,7 +234,10 @@ namespace Mono.Globalization.Unicode
 
                public SortKey GetResult ()
                {
-                       if (frenchSort && !frenchSorted) {
+                       if (source.Length == 0)
+                               return new SortKey (lcid, source, new byte [0], options, 0, 0, 0, 0, 0, 0, 0, 0);
+
+                       if (frenchSort && !frenchSorted && l2b != null) {
                                int i = 0;
                                for (; i < l2b.Length; i++)
                                        if (l2b [i] == 0)