* syntax.cs (BackslashNumber.ResolveReference): Improve ECMAScript semantics.
authorRaja R Harinath <harinath@hurrynot.org>
Tue, 11 Aug 2009 19:11:26 +0000 (19:11 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Tue, 11 Aug 2009 19:11:26 +0000 (19:11 -0000)
svn path=/trunk/mcs/; revision=139731

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

index c71706ec268a53272b671945e278a593b558c728..0611542c5f175251706dad70efe8d16cb232651f 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-12  Raja R Harinath  <harinath@hurrynot.org>
+
+       * syntax.cs (BackslashNumber.ResolveReference): Improve ECMAScript
+       semantics.  Handle cases like "group 43 exists but group 4 doesn't".
+
 2009-08-10  Raja R Harinath  <harinath@hurrynot.org>
 
        * syntax.cs (BackslashNumber.ResolveReference): Implement fallback
index 3b4b717dc7c95941d10b7c8ca6af4f8c62d0a9f5..265eb7eed8030c7c23f9c2de29126e063a664270 100644 (file)
@@ -817,16 +817,14 @@ namespace System.Text.RegularExpressions.Syntax {
                public bool ResolveReference (string num_str, Hashtable groups)
                {
                        if (ecma) {
-                               int i;
-                               for (i = 1; i < num_str.Length; ++i) {
-                                       string name = num_str.Substring (0, i);
-                                       CapturingGroup group = (CapturingGroup) groups [name];
-                                       if (group == null)
-                                               break;
-                                       CapturingGroup = group;
+                               int last_i = 0;
+                               for (int i = 1; i < num_str.Length; ++i) {
+                                       if (groups [num_str.Substring (0, i)] != null)
+                                               last_i = i;
                                }
-                               if (i > 1) {
-                                       literal = num_str.Substring (i - 1);
+                               if (last_i != 0) {
+                                       CapturingGroup = (CapturingGroup) groups [num_str.Substring (0, last_i)];
+                                       literal = num_str.Substring (last_i);
                                        return true;
                                }
                        } else {