From: Raja R Harinath Date: Tue, 11 Aug 2009 19:11:26 +0000 (-0000) Subject: * syntax.cs (BackslashNumber.ResolveReference): Improve ECMAScript semantics. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=4d8fa96830138ff45e2c84008eeb505ab85af5b3;p=mono.git * syntax.cs (BackslashNumber.ResolveReference): Improve ECMAScript semantics. svn path=/trunk/mcs/; revision=139731 --- diff --git a/mcs/class/System/System.Text.RegularExpressions/ChangeLog b/mcs/class/System/System.Text.RegularExpressions/ChangeLog index c71706ec268..0611542c5f1 100644 --- a/mcs/class/System/System.Text.RegularExpressions/ChangeLog +++ b/mcs/class/System/System.Text.RegularExpressions/ChangeLog @@ -1,3 +1,8 @@ +2009-08-12 Raja R Harinath + + * syntax.cs (BackslashNumber.ResolveReference): Improve ECMAScript + semantics. Handle cases like "group 43 exists but group 4 doesn't". + 2009-08-10 Raja R Harinath * syntax.cs (BackslashNumber.ResolveReference): Implement fallback diff --git a/mcs/class/System/System.Text.RegularExpressions/syntax.cs b/mcs/class/System/System.Text.RegularExpressions/syntax.cs index 3b4b717dc7c..265eb7eed80 100644 --- a/mcs/class/System/System.Text.RegularExpressions/syntax.cs +++ b/mcs/class/System/System.Text.RegularExpressions/syntax.cs @@ -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 {