소스 검색

2004-05-27 Gonzalo Paniagua Javier <[email protected]>

	* 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
Gonzalo Paniagua Javier 21 년 전
부모
커밋
fef90f0a49

+ 8 - 0
mcs/class/System/System.Text.RegularExpressions/ChangeLog

@@ -1,3 +1,11 @@
+2004-05-27  Gonzalo Paniagua Javier <[email protected]>
+
+	* 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  <[email protected]>
 
 	* parser.cs: Allow creating a regular expression using {,n} as the

+ 3 - 1
mcs/class/System/System.Text.RegularExpressions/category.cs

@@ -174,7 +174,9 @@ namespace System.Text.RegularExpressions {
 		UnicodeMathematicalAlphanumericSymbols,
 		UnicodeCJKUnifiedIdeographsExtensionB,
 		UnicodeCJKCompatibilityIdeographsSupplement,
-		UnicodeTags
+		UnicodeTags,
+
+		LastValue // Keep this with the higher value in the enumeration
 	}
 
 	class CategoryUtils {

+ 5 - 17
mcs/class/System/System.Text.RegularExpressions/syntax.cs

@@ -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;
 	}