+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
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
// 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) {
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;
}
}
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;
}