Author: gonzalo
Date: 2005-02-27 04:49:55 -0500 (Sun, 27 Feb 2005)
New Revision: 41254
Modified:
branches/mono-1-0/mcs/class/System/System.Text.RegularExpressions/ChangeLog
branches/mono-1-0/mcs/class/System/System.Text.RegularExpressions/parser.cs
Log:
2005-02-27 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* parser.cs: stuff inside {} might not be a quantifier. Fixes
bug #69193.
Modified:
branches/mono-1-0/mcs/class/System/System.Text.RegularExpressions/ChangeLog
===================================================================
--- branches/mono-1-0/mcs/class/System/System.Text.RegularExpressions/ChangeLog
2005-02-27 09:49:14 UTC (rev 41253)
+++ branches/mono-1-0/mcs/class/System/System.Text.RegularExpressions/ChangeLog
2005-02-27 09:49:55 UTC (rev 41254)
@@ -1,3 +1,8 @@
+2005-02-27 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * parser.cs: stuff inside {} might not be a quantifier. Fixes
+ bug #69193.
+
2005-01-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* quicksearch.cs: handle IgnoreCase when getting the shift distance.
Modified:
branches/mono-1-0/mcs/class/System/System.Text.RegularExpressions/parser.cs
===================================================================
--- branches/mono-1-0/mcs/class/System/System.Text.RegularExpressions/parser.cs
2005-02-27 09:49:14 UTC (rev 41253)
+++ branches/mono-1-0/mcs/class/System/System.Text.RegularExpressions/parser.cs
2005-02-27 09:49:55 UTC (rev 41254)
@@ -287,20 +287,29 @@
if (ptr < pattern.Length) {
char k = pattern[ptr];
+ int min = 0, max = 0;
+ bool lazy = false;
+ bool haveRep = false;
- if (k == '?' || k == '*' || k == '+' ||
k == '{') {
+
+ if (k == '?' || k == '*' || k == '+') {
++ ptr;
+ haveRep = true;
- int min = 0, max = 0;
- bool lazy = false;
-
switch (k) {
case '?': min = 0; max = 1;
break;
case '*': min = 0; max =
0xffff; break;
case '+': min = 1; max =
0xffff; break;
- case '{': ParseRepetitionBounds
(out min, out max, options); break;
}
+ } else if (k == '{' && ptr + 1 <
pattern.Length) {
+ int saved_ptr = ptr;
+ ++ptr;
+ haveRep = ParseRepetitionBounds
(out min, out max, options);
+ if (!haveRep)
+ ptr = saved_ptr;
+ }
+ if (haveRep) {
ConsumeWhitespace
(IsIgnorePatternWhitespace (options));
if (ptr < pattern.Length &&
pattern[ptr] == '?') {
++ ptr;
@@ -738,8 +747,9 @@
return cls;
}
- private void ParseRepetitionBounds (out int min, out int max,
RegexOptions options) {
+ private bool ParseRepetitionBounds (out int min, out int max,
RegexOptions options) {
int n, m;
+ min = max = 0;
/* check syntax */
@@ -761,10 +771,10 @@
m = ParseNumber (10, 1, 0);
ConsumeWhitespace (IsIgnorePatternWhitespace
(options));
if (pattern[ptr ++] != '}')
- throw NewParseException ("Illegal {x,y}
- bad value of y.");
+ return false;
break;
default:
- throw NewParseException ("Illegal {x,y}");
+ return false;
}
/* check bounds and ordering */
@@ -781,6 +791,8 @@
max = m;
else
max = 0xffff;
+
+ return true;
}
private Category ParseUnicodeCategory () {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches