Skip to content

Commit

Permalink
2004-03-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
Browse files Browse the repository at this point in the history
	* parser.cs: fixed group numbering.

svn path=/trunk/mcs/; revision=24551
  • Loading branch information
gonzalop committed Mar 24, 2004
1 parent b24f237 commit b55ee14
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 6 additions & 1 deletion mcs/class/System/System.Text.RegularExpressions/ChangeLog
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
15 changes: 10 additions & 5 deletions mcs/class/System/System.Text.RegularExpressions/parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,20 @@ public RegularExpression ParseRegularExpression (string pattern, RegexOptions op

public IDictionary GetMapping () {
Hashtable mapping = new Hashtable ();
Hashtable numbers = new Hashtable ();
int end = caps.Count;
mapping.Add ("0", 0);
for (int i = 0; i < end;) {
for (int i = 0; i < end; i++) {
CapturingGroup group = (CapturingGroup) caps [i];
i++;
if (group.Name != null && !mapping.Contains (group.Name))
if (group.Name != null && !mapping.Contains (group.Name)) {
mapping.Add (group.Name, group.Number);
else
mapping.Add (group.Number.ToString (), group.Number);
numbers.Add (group.Number, group.Number);
}
}

for (int i = 1; i < end; i++) {
if (numbers [i] == null)
mapping.Add (i.ToString (), i);
}

return mapping;
Expand Down

0 comments on commit b55ee14

Please sign in to comment.