Просмотр исходного кода

2003-07-09 Gonzalo Paniagua Javier <[email protected]>

	* regex.cs: patch from Eric Lindvall <[email protected]> that fixes bug
	#44830.

svn path=/trunk/mcs/; revision=16053
Gonzalo Paniagua Javier 22 лет назад
Родитель
Сommit
f06cdb496a

+ 5 - 0
mcs/class/System/System.Text.RegularExpressions/ChangeLog

@@ -1,3 +1,8 @@
+2003-07-09  Gonzalo Paniagua Javier <[email protected]>
+
+	* regex.cs: patch from Eric Lindvall <[email protected]> that fixes bug
+	#44830.
+
 2003-03-05  Miguel de Icaza  <[email protected]>
 
 	* category.cs (CategoryUtils.CategoryFromName): Use StartsWith

+ 4 - 5
mcs/class/System/System.Text.RegularExpressions/regex.cs

@@ -321,7 +321,7 @@ namespace System.Text.RegularExpressions {
 				count = Int32.MaxValue;
 
 			int ptr = startat;
-			while (count -- > 0) {
+			while (--count > 0) {
 				Match m = Match (input, ptr);
 				if (!m.Success)
 					break;
@@ -330,12 +330,11 @@ namespace System.Text.RegularExpressions {
 				ptr = m.Index + m.Length;
 			}
 
-			if (count > 0)
+			if (ptr < input.Length) {
 				splits.Add (input.Substring (ptr));
+			}
 
-			string[] result = new string[splits.Count];
-			splits.CopyTo (result);
-			return result;
+			return (string []) splits.ToArray (typeof (string));
 		}
 
 		// object methods