Author: atsushi
Date: 2006-01-20 03:42:11 -0500 (Fri, 20 Jan 2006)
New Revision: 55824

Modified:
   trunk/mcs/class/I18N/CJK/CP950.cs
   trunk/mcs/class/I18N/CJK/ChangeLog
   trunk/mcs/class/I18N/CJK/Test/ChangeLog
   trunk/mcs/class/I18N/CJK/Test/I18N.CJK.Test.cs
Log:
2006-01-20  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * CP950.cs : GetChars() should filter out invalid index to internal
          conversion array. Fixed bug #77274.

        * I18N.CJK.Test.cs : added test for bug #77274. Unify those
          "all pair of bytes" tests code.



Modified: trunk/mcs/class/I18N/CJK/CP950.cs
===================================================================
--- trunk/mcs/class/I18N/CJK/CP950.cs   2006-01-20 08:21:53 UTC (rev 55823)
+++ trunk/mcs/class/I18N/CJK/CP950.cs   2006-01-20 08:42:11 UTC (rev 55824)
@@ -76,22 +76,28 @@
                                if (lastByte == 0) {
                                        if (b <= 0x80 || b == 0xFF) { // ASCII
                                                chars[charIndex++] = (char)b;
-                                               continue;
                                        } else if (b < 0xA1 || b >= 0xFA) {
-                                               continue;
+                                               // incorrect first byte.
+                                               chars[charIndex++] = '?';
+                                               byteCount--; // cut one more 
byte.
                                        } else {
                                                lastByte = b;
-                                               continue;
                                        }
+                                       continue;
                                }
                                int ord = ((lastByte - 0xA1) * 191 + b - 0x40) 
* 2;
-                               char c1 = (char)(convert.n2u[ord] + 
convert.n2u[ord + 1] * 256);
+                               char c1 = ord < 0 || ord > convert.n2u.Length ?
+                                       '\0' :
+                                       (char)(convert.n2u[ord] + 
convert.n2u[ord + 1] * 256);
                                if (c1 == 0)
                                        chars[charIndex++] = '?';
                                else
                                        chars[charIndex++] = c1;
                                lastByte = 0;
                        }
+                       if (lastByte != 0)
+                               chars[charIndex++] = '?';
+
                        return charIndex - origIndex;
                }
                

Modified: trunk/mcs/class/I18N/CJK/ChangeLog
===================================================================
--- trunk/mcs/class/I18N/CJK/ChangeLog  2006-01-20 08:21:53 UTC (rev 55823)
+++ trunk/mcs/class/I18N/CJK/ChangeLog  2006-01-20 08:42:11 UTC (rev 55824)
@@ -1,3 +1,8 @@
+2006-01-20  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * CP950.cs : GetChars() should filter out invalid index to internal
+         conversion array. Fixed bug #77274.
+
 2006-01-17  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * DbcsEncoding.cs CP950.cs CP932.cs CP936.cs CP51932.cs CP949.cs :

Modified: trunk/mcs/class/I18N/CJK/Test/ChangeLog
===================================================================
--- trunk/mcs/class/I18N/CJK/Test/ChangeLog     2006-01-20 08:21:53 UTC (rev 
55823)
+++ trunk/mcs/class/I18N/CJK/Test/ChangeLog     2006-01-20 08:42:11 UTC (rev 
55824)
@@ -1,3 +1,8 @@
+2006-01-20  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * I18N.CJK.Test.cs : added test for bug #77274. Unify those
+         "all pair of bytes" tests code.
+
 2006-01-16  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * I18N.CJK.Test.cs : added test for bug #77238.

Modified: trunk/mcs/class/I18N/CJK/Test/I18N.CJK.Test.cs
===================================================================
--- trunk/mcs/class/I18N/CJK/Test/I18N.CJK.Test.cs      2006-01-20 08:21:53 UTC 
(rev 55823)
+++ trunk/mcs/class/I18N/CJK/Test/I18N.CJK.Test.cs      2006-01-20 08:42:11 UTC 
(rev 55824)
@@ -208,10 +208,9 @@
                                e.GetBytes (new char [] {(char) i});
                }
 
-               [Test]
-               public void Bug77222 ()
+               GetCharsAllBytePairs (int enc)
                {
-                       Encoding e = Encoding.GetEncoding (51932);
+                       Encoding e = Encoding.GetEncoding (enc);
                        byte [] bytes = new byte [2];
                        for (int i0 = 0; i0 < 0x100; i0++) {
                                bytes [0] = (byte) i0;
@@ -223,19 +222,23 @@
                }
 
                [Test]
+               public void Bug77222 ()
+               {
+                       GetCharsAllBytePairs (51932);
+               }
+
+               [Test]
                public void Bug77238 ()
                {
-                       Encoding e = Encoding.GetEncoding(936);
-                       byte [] bytes = new byte [2];
-                       for (int i0 = 0; i0 < 0x100; i0++) {
-                               bytes [0] = (byte) i0;
-                               for (int i1 = 0; i1 < 0x100; i1++) {
-                                       bytes [1] = (byte) i1;
-                                       e.GetChars (bytes);
-                               }
-                       }
+                       GetCharsAllBytePairs (936);
                }
 
+               [Test]
+               public void Bug7774 ()
+               {
+                       GetCharsAllBytePairs (950);
+               }
+
                #endregion
 
                #region Korean

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to