From fef90f0a49ddd2ffb83efef7623f386a61e194bd Mon Sep 17 00:00:00 2001 From: Gonzalo Paniagua Javier Date: Thu, 27 May 2004 03:40:44 +0000 Subject: [PATCH] 2004-05-27 Gonzalo Paniagua Javier * 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 --- .../System.Text.RegularExpressions/ChangeLog | 8 +++++++ .../category.cs | 4 +++- .../System.Text.RegularExpressions/syntax.cs | 22 +++++-------------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/mcs/class/System/System.Text.RegularExpressions/ChangeLog b/mcs/class/System/System.Text.RegularExpressions/ChangeLog index b5cb73e65dc..3967632a442 100644 --- a/mcs/class/System/System.Text.RegularExpressions/ChangeLog +++ b/mcs/class/System/System.Text.RegularExpressions/ChangeLog @@ -1,3 +1,11 @@ +2004-05-27 Gonzalo Paniagua Javier + + * 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 * parser.cs: Allow creating a regular expression using {,n} as the diff --git a/mcs/class/System/System.Text.RegularExpressions/category.cs b/mcs/class/System/System.Text.RegularExpressions/category.cs index 32625887664..b2bd899f08f 100644 --- a/mcs/class/System/System.Text.RegularExpressions/category.cs +++ b/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 { diff --git a/mcs/class/System/System.Text.RegularExpressions/syntax.cs b/mcs/class/System/System.Text.RegularExpressions/syntax.cs index ed02509572a..387a2f2f87b 100644 --- a/mcs/class/System/System.Text.RegularExpressions/syntax.cs +++ b/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; } -- 2.25.1