2004-05-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 27 May 2004 03:40:44 +0000 (03:40 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 27 May 2004 03:40:44 +0000 (03:40 -0000)
* category.cs: added LastValue field to mark the end of enum Category.
* syntax.cs: in CharacterClass, use Category.LastValue to get the size
of the array needed. Use a BitArray instead of bool[].
In AddCategory(), don't set the opposite category as false. Fixes
bug #59150. All tests pass.

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

mcs/class/System/System.Text.RegularExpressions/ChangeLog
mcs/class/System/System.Text.RegularExpressions/category.cs
mcs/class/System/System.Text.RegularExpressions/syntax.cs

index b5cb73e65dc8a377ec671dc37532d537d978fd60..3967632a44226c6e2b15dc1438a0a431681761c7 100644 (file)
@@ -1,3 +1,11 @@
+2004-05-27  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * category.cs: added LastValue field to mark the end of enum Category.
+       * syntax.cs: in CharacterClass, use Category.LastValue to get the size
+       of the array needed. Use a BitArray instead of bool[].
+       In AddCategory(), don't set the opposite category as false. Fixes
+       bug #59150. All tests pass.
+
 2004-05-25  Jackson Harper  <jackson@ximian.com>
 
        * parser.cs: Allow creating a regular expression using {,n} as the
index 32625887664929690973318857d010d13428e96d..b2bd899f08f4bfbba129d1f7c2208debb6537166 100644 (file)
@@ -174,7 +174,9 @@ namespace System.Text.RegularExpressions {
                UnicodeMathematicalAlphanumericSymbols,\r
                UnicodeCJKUnifiedIdeographsExtensionB,\r
                UnicodeCJKCompatibilityIdeographsSupplement,\r
-               UnicodeTags\r
+               UnicodeTags,\r
+\r
+               LastValue // Keep this with the higher value in the enumeration\r
        }\r
 \r
        class CategoryUtils {\r
index ed02509572ae2a9f82d8aaef5486d46a8146d579..387a2f2f87b6c903b239f3d57c49fa27fbfeaf0c 100644 (file)
@@ -773,14 +773,9 @@ namespace System.Text.RegularExpressions.Syntax {
 
                        // initialize pos/neg category arrays
 
-                       Array cat_values = Enum.GetValues (typeof (Category));
-                       int cat_size = (int)(Category)cat_values.GetValue (cat_values.Length - 1) + 1;
-                       pos_cats = new bool[cat_size];
-                       neg_cats = new bool[cat_size];
-                       for (int i = 0; i < cat_size; ++ i) {
-                               pos_cats[i] = false;
-                               neg_cats[i] = false;
-                       }
+                       int cat_size = (int) Category.LastValue;
+                       pos_cats = new BitArray (cat_size);
+                       neg_cats = new BitArray (cat_size);
                }
 
                public CharacterClass (Category cat, bool negate) : this (false, false) {
@@ -801,15 +796,8 @@ namespace System.Text.RegularExpressions.Syntax {
                        int n = (int)cat;
                        
                        if (negate) {
-                               if (pos_cats[n])
-                                       pos_cats[n] = false;
-
                                neg_cats[n] = true;
-                       }
-                       else {
-                               if (neg_cats[n])
-                                       neg_cats[n] = false;
-
+                       } else {
                                pos_cats[n] = true;
                        }
                }
@@ -938,7 +926,7 @@ namespace System.Text.RegularExpressions.Syntax {
                private static Interval upper_case_characters = new Interval ((char)65, (char)90);
                private const int distance_between_upper_and_lower_case = 32;
                private bool negate, ignore;
-               private bool[] pos_cats, neg_cats;
+               private BitArray pos_cats, neg_cats;
                private IntervalCollection intervals;
        }