[Mono-bugs] [Bug 601772] New: String.Split() can return too many substrings
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Sun May 2 07:26:53 EDT 2010
http://bugzilla.novell.com/show_bug.cgi?id=601772
http://bugzilla.novell.com/show_bug.cgi?id=601772#c0
Summary: String.Split() can return too many substrings
Classification: Mono
Product: Mono: Class Libraries
Version: 2.6.x
Platform: All
OS/Version: Linux
Status: NEW
Severity: Normal
Priority: P5 - None
Component: CORLIB
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: Chuck.Esterbrook at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us)
AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7
The docs for String.Split say that the 'count' argument is the "The maximum
number of substrings to return." See
http://msdn.microsoft.com/en-us/library/1bwe3zdy.aspx
But at least one of the overloads of Split will return count+1 substrings. Code
in "Steps to Reproduce"
Reproducible: Always
Steps to Reproduce:
// compile and run this program.
// Bug: String.Split() can return an extra substring in violation of the
'count' parameter value passed to it.
// This program
// ... prints "1" and "True" on .NET 3.5 as expected
// ... prints "2" and "False" on Mono 2.6.3 on Linux (and Mono 2.6.1 on Mac OS
X 10.6)
using System;
namespace TestSplit {
class Program {
static void Main(string[] args) {
var maxSubStrings = 1;
var r = "aoeuXXasdf".Split(new string[] { "XX" }, maxSubStrings,
StringSplitOptions.None);
Console.WriteLine(r.Length);
Console.WriteLine(r.Length == maxSubStrings);
}
}
}
Actual Results:
2
False
Expected Results:
1
True
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list