In System.Text.RegularExpressions:
authorRaja R Harinath <harinath@hurrynot.org>
Mon, 17 Apr 2006 14:05:46 +0000 (14:05 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Mon, 17 Apr 2006 14:05:46 +0000 (14:05 -0000)
2006-04-17  Florian Gross  <flgr@ccan.de>
    Raja R Harinath  <rharinath@novell.com>

* syntax.cs (CharacterClass.Compile): Emit categories after the
character intervals so that the evaluator can pick up the
'IgnoreCase' flag.

In Test/System.Text.RegularExpressions:
2006-04-17  Florian Gross  <flgr@ccan.de>

* RegexBugs.cs (CharClassWithIgnoreCase): Ensure that character
classes don't interfere with RegexOptions.IgnoreCase.

Started looking at some of Florian's patches, which I realized now that
he hadn't applied.

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

mcs/class/System/System.Text.RegularExpressions/ChangeLog
mcs/class/System/System.Text.RegularExpressions/syntax.cs
mcs/class/System/Test/System.Text.RegularExpressions/ChangeLog
mcs/class/System/Test/System.Text.RegularExpressions/RegexBugs.cs

index 8b3fdd843309f1e491a816a65223c17aa91854cd..29d5bff13c9772beab01493e922454ea1d16baf6 100644 (file)
@@ -1,3 +1,10 @@
+2006-04-17  Florian Gross  <flgr@ccan.de>
+           Raja R Harinath  <rharinath@novell.com>
+
+       * syntax.cs (CharacterClass.Compile): Emit categories after the
+       character intervals so that the evaluator can pick up the
+       'IgnoreCase' flag.
+
 2006-04-07  Raja R Harinath  <rharinath@novell.com>
 
        Fix #78007
index 7caa690adee8e5afeb0ad5b4906204ee0800186a..d9bb6fbadaa50fa32b88effba16f260ced57a1f1 100644 (file)
@@ -865,38 +865,22 @@ namespace System.Text.RegularExpressions.Syntax {
                                intervals.GetMetaCollection (new IntervalCollection.CostDelegate (GetIntervalCost));
 
                        // count ops
-                       
                        int count = meta.Count;
                        for (int i = 0; i < pos_cats.Length; ++ i) {
-                               if (pos_cats[i]) ++ count;
-                               if (neg_cats[i]) ++ count;
+                               if (pos_cats[i] || neg_cats [i])
+                                       ++ count;
                        }
 
                        if (count == 0)
                                return;
 
                        // emit in op for |meta| > 1
-
                        LinkRef tail = cmp.NewLink ();
                        if (count > 1)
                                cmp.EmitIn (tail);
-                               
-
-                       // emit categories
-
-                       for (int i = 0; i < pos_cats.Length; ++ i) {
-                               if (pos_cats[i]) {
-                                       if (neg_cats [i])
-                                               cmp.EmitCategory (Category.AnySingleline, negate, reverse);
-                                       else
-                                               cmp.EmitCategory ((Category)i, negate, reverse);
-                               } else if (neg_cats[i]) {
-                                       cmp.EmitNotCategory ((Category)i, negate, reverse);
-                               }
-                       }
 
                        // emit character/range/sets from meta-collection
-
+                       // we emit these first so that any 'ignore' flags will be noticed by the evaluator
                        foreach (Interval a in meta) {
                                if (a.IsDiscontiguous) {                        // Set
                                        BitArray bits = new BitArray (a.Size);
@@ -914,9 +898,20 @@ namespace System.Text.RegularExpressions.Syntax {
                                else                                            // Range
                                        cmp.EmitRange ((char)a.low, (char)a.high, negate, ignore, reverse);
                        }
-                       
-                       // finish up
 
+                       // emit categories
+                       for (int i = 0; i < pos_cats.Length; ++ i) {
+                               if (pos_cats[i]) {
+                                       if (neg_cats [i])
+                                               cmp.EmitCategory (Category.AnySingleline, negate, reverse);
+                                       else
+                                               cmp.EmitCategory ((Category)i, negate, reverse);
+                               } else if (neg_cats[i]) {
+                                       cmp.EmitNotCategory ((Category)i, negate, reverse);
+                               }
+                       }
+
+                       // finish up
                        if (count > 1) {
                                if (negate)
                                        cmp.EmitTrue ();
index d7f90a5fe5f28ac77d200438dbb9ae7ef3f5aa38..423162863468b3ab797e70b531b2bc10735f8d66 100644 (file)
@@ -1,3 +1,8 @@
+2006-04-17  Florian Gross  <flgr@ccan.de>
+
+       * RegexBugs.cs (CharClassWithIgnoreCase): Ensure that character
+       classes don't interfere with RegexOptions.IgnoreCase.
+
 2006-04-07  Raja R Harinath  <rharinath@novell.com>
 
        * RegexBugs.cs (Bug78007): New test from #78007.
index 3b371d38385c0d9f5d9f2e97af8e66a4a3dbce12..19d8fdc6b60b231188420c22fe7a298b86157b9b 100644 (file)
@@ -368,5 +368,14 @@ namespace MonoTests.System.Text.RegularExpressions
                        m = m.NextMatch ();
                        Assert ("#02", !m.Success);
                }
+
+               [Test]
+               public void CharClassWithIgnoreCase ()
+               {
+                       string str = "Foobar qux";
+                       Regex re = new Regex (@"[a-z\s]*", RegexOptions.IgnoreCase);
+                       Match m = re.Match (str);
+                       AssertEquals ("#01", str, m.Value);
+                }
        }
 }