2009-06-15 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 15 Jun 2009 08:57:18 +0000 (08:57 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 15 Jun 2009 08:57:18 +0000 (08:57 -0000)
* Environment.cs : bump corlib version.

* Normalization.cs : For NFC and NFKC, IsNormalized() was not working
  enough to check composed characters. It's not possible without
  the actual composition, so just call Normalize() and compare them.
  In Normalize() mapping helper didn't pick correct map index since
  the table for index stores index for "uncompressed" numbers.
* NormalizationTableUtil.cs : updated to the latest UCD.
* Makefile : to build test, source file must be downloaded too.

* StringTest.cs : added string normalization test.

svn path=/trunk/mcs/; revision=136100

mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog
mcs/class/corlib/Mono.Globalization.Unicode/Makefile
mcs/class/corlib/Mono.Globalization.Unicode/Normalization.cs
mcs/class/corlib/Mono.Globalization.Unicode/NormalizationTableUtil.cs
mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Environment.cs
mcs/class/corlib/Test/System/ChangeLog
mcs/class/corlib/Test/System/StringTest.cs

index 0716a7a42be50c9d6b6f85835ff82ab4ed160f74..385aa5cb4918d417e297b8f1b34c92961246b20f 100644 (file)
@@ -1,3 +1,13 @@
+2008-06-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Normalization.cs : For NFC and NFKC, IsNormalized() was not working
+         enough to check composed characters. It's not possible without
+         the actual composition, so just call Normalize() and compare them.
+         In Normalize() mapping helper didn't pick correct map index since
+         the table for index stores index for "uncompressed" numbers.
+       * NormalizationTableUtil.cs : updated to the latest UCD.
+       * Makefile : to build test, source file must be downloaded too.
+
 2008-11-05  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ucd.cs : Write type for *_count. Add notice to not edit
index 73a3dcbb8ad670544abbcf88e8cb169c28f985e4..021a653b973616985fd16dfb2df033637def6a5c 100644 (file)
@@ -29,7 +29,7 @@ normalization: $(NORM_FILENAME)
 
 collation : $(MSCOMPAT_FILENAME)
 
-norm-test : $(NORM_TEST_CS)
+norm-test : $(NORM_TEST_CS) $(NORM_TEST)
        $(CS2COMPILE) $(NORM_TEST_CS) -d:TEST_STANDALONE
 
 distclean :
@@ -69,11 +69,11 @@ $(COLL_ELEM_FILENAME).exe : $(COLL_TABLE_GENERATOR_SOURCES)
 # normalization (including combining class)
 $(NORM_FILENAME) : $(NORMGEN_FILENAME).exe Normalization.cs $(NORM_TABLE) $(UCD_TABLE) $(CB_CLASS_TABLE)
        echo "// WARNING: Do not edit this file. It is autogenerated." > $(NORM_FILENAME)
-       echo "#define GENERATE_TABLE" > $(NORM_FILENAME)
-       cat Normalization.cs >> $(NORM_FILENAME) || rm $(NORM_FILENAME)
-       $(RUNTIME) $(NORMGEN_FILENAME).exe >> $(NORM_FILENAME) || rm $(NORM_FILENAME)
-       echo "  }" >> $(NORM_FILENAME)
-       echo "}" >> $(NORM_FILENAME)
+       echo "#define GENERATE_TABLE" >> $(NORM_FILENAME); \
+               cat Normalization.cs >> $(NORM_FILENAME); \
+               $(RUNTIME) $(NORMGEN_FILENAME).exe >> $(NORM_FILENAME); \
+               echo "  }" >> $(NORM_FILENAME); \
+               echo "}" >> $(NORM_FILENAME) || rm $(NORM_FILENAME)
 
 NORM_TABLE_GENERATOR_SOURCES = \
        $(NORMGEN_FILENAME).cs \
index 355315d8ed929a63191f40a6865a1059a24f9c51..648ba04dfaea9d8fe65492308791ff92d4366005 100644 (file)
@@ -57,9 +57,10 @@ namespace Mono.Globalization.Unicode
                        return mapIdxToComposite [NUtil.Composite.ToIndex (src)];
                }
 
-               static short GetPrimaryCompositeHelperIndex (int cp)
+               static int GetPrimaryCompositeHelperIndex (int cp)
                {
-                       return helperIndex [NUtil.Helper.ToIndex (cp)];
+                       int originalMapIndex = helperIndex [NUtil.Helper.ToIndex (cp)]; // it returns an index at uncompressed state.
+                       return NUtil.Map.ToIndex (originalMapIndex);
                }
 
                static int GetPrimaryCompositeCharIndex (object chars, int start)
@@ -363,6 +364,14 @@ namespace Mono.Globalization.Unicode
                                case NormalizationCheck.No:
                                        return false;
                                case NormalizationCheck.Maybe:
+                                       // for those forms with composition, it cannot be checked here
+                                       switch (type) {
+                                       case 0: // NFC
+                                       case 2: // NFKC
+                                               return source == Normalize (source, type);
+                                       }
+                                       // go on...
+                                       
                                        // partly copied from Combine()
                                        int cur = i;
                                        // FIXME: It should check "blocked" too
index 357795a4ea347963720f9ad9d2569b1a3b6f72b6..38e47f94fdfc813cce2e7469fafb27658ab9b21a 100644 (file)
@@ -15,13 +15,13 @@ namespace Mono.Globalization.Unicode
                static NormalizationTableUtil ()
                {
                        int [] propStarts = new int [] {
-                               0, 0x0910, 0x1D00, 0x2460, 0x2980,
-                               0x2D60, 0x2E90, 0xF900,
+                               0, 0x0910, 0x1B00, 0x2460, 0x2980,
+                               0x2C70, 0x2D60, 0x2E90, 0xA770, 0xF900,
 //                             0x1D100, 0x2f800, 0x2fa10
                                };
                        int [] propEnds = new int [] {
                                0x06E0, 0x1200, 0x2330, 0x2600, 0x2AE0,
-                               0x2D70, 0x3400, 0x10000,
+                               0x2C80, 0x2D70, 0x3400, 0xA780, 0x10000,
 //                             0x1D800, 0x2f810, 0x2fa20
                                };
                        int [] mapStarts = new int [] {
index 4ab9781fb26d87dca148cb6ac331ed08bdece8fe..d3743f277a6d551671624d918df73eac9c223ea2 100644 (file)
@@ -1,3 +1,7 @@
+2009-06-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Environment.cs : bump corlib version.
+
 2009-06-12  Bill Holmes  <billholmes54@gmail.com>
 
        * Variant.cs (GetValue):  Changing the bool case to use the short value.  
index 7e7ea4a19cbbcf542e91469fc9bef7a83f561f37..8a034027c8871cb3ea7487763a16abea8c457ea8 100644 (file)
@@ -63,7 +63,7 @@ namespace System {
                 * Changes which are already detected at runtime, like the addition
                 * of icalls, do not require an increment.
                 */
-               private const int mono_corlib_version = 77;
+               private const int mono_corlib_version = 78;
 
 #if NET_2_0
                [ComVisible (true)]
index 8f623242172aa4d1a50e08cb9b0a5691e4558bf3..66f79111943c0b590994932f713697a1cb8b8d43 100644 (file)
@@ -1,3 +1,7 @@
+2009-06-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * StringTest.cs : added string normalization test.
+
 2009-05-26 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * TypeTest.cs: test for bug #506757.
index d74ee41e6f6a485992148bf3fa92e202bb920539..2577276ea1324f5b5615c44459163ee4e8b693c7 100644 (file)
@@ -3,10 +3,10 @@
 // Authors:
 //   Jeffrey Stedfast <fejj@ximian.com>
 //   David Brandt <bucky@keystreams.com>
-//   Kornél Pál <http://www.kornelpal.hu/>
+//   Kornel Pal <http://www.kornelpal.hu/>
 //
 // (C) Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2006 Kornél Pál
+// Copyright (C) 2006 Kornel Pal
 // Copyright (C) 2006 Novell (http://www.novell.com)
 //
 
@@ -4267,6 +4267,14 @@ public class StringTest : TestCase
                AssertEquals ("#11-09-2", "..", res[1]);
                AssertEquals ("#11-09-3", 2, res.Length);
        }
+
+       [Test]
+       public void Normalize1 ()
+       {
+               string s = "\u03B1\u0313\u0345";
+               Assert ("#1", s.IsNormalized (s, NormalizationForm.FormC));
+               AssertEquals ("#2", s, s.Normalize (NormalizationForm.FormC));
+       }
 #endif
 }