2004-03-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Wed, 24 Mar 2004 23:27:24 +0000 (23:27 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Wed, 24 Mar 2004 23:27:24 +0000 (23:27 -0000)
* parser.cs: fixed group numbering.

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

mcs/class/System/System.Text.RegularExpressions/ChangeLog
mcs/class/System/System.Text.RegularExpressions/parser.cs

index 3301459995cd651558a5f2b20445bcd0882d2740..47cbfdf11555cf3cfa0a15592cdd4fd4f96467a5 100644 (file)
@@ -1,6 +1,11 @@
+2004-03-24  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * parser.cs: fixed group numbering.
+
 2004-03-22  Jackson Harper  <jackson@ximian.com>
 
-       * parser.cs: Use the group number as the name in mapping. Patch by Gert Driesen.
+       * parser.cs: Use the group number as the name in mapping. Patch by
+       Gert Driesen.
        * regex.cs: Fix off by one error. Patch by Gert Driesen.
 
 2004-03-17  Francois Beauchemin <beauche@softhome.net>
index 4ce13139b818091ffaec261b184687470878e7ae..0653c4a7222a4a98198cfdb91cfd473162c846f2 100644 (file)
@@ -128,15 +128,20 @@ namespace System.Text.RegularExpressions.Syntax {
 \r
                public IDictionary GetMapping () {\r
                        Hashtable mapping = new Hashtable ();\r
+                       Hashtable numbers = new Hashtable ();\r
                        int end = caps.Count;\r
                        mapping.Add ("0", 0);\r
-                       for (int i = 0; i < end;) {\r
+                       for (int i = 0; i < end; i++) {\r
                                CapturingGroup group = (CapturingGroup) caps [i];\r
-                               i++;\r
-                               if (group.Name != null && !mapping.Contains (group.Name))\r
+                               if (group.Name != null && !mapping.Contains (group.Name)) {\r
                                        mapping.Add (group.Name, group.Number);\r
-                               else\r
-                                       mapping.Add (group.Number.ToString (), group.Number);\r
+                                       numbers.Add (group.Number, group.Number);\r
+                               }\r
+                       }\r
+\r
+                       for (int i = 1; i < end; i++) {\r
+                               if (numbers [i] == null)\r
+                                       mapping.Add (i.ToString (), i);\r
                        }\r
 \r
                        return mapping;\r