[Mono-bugs] [Bug 605340] Unexpected exception on calling String.LastIndexOf on empty strings with startIndex=-1
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Jul 2 20:37:18 EDT 2010
http://bugzilla.novell.com/show_bug.cgi?id=605340
http://bugzilla.novell.com/show_bug.cgi?id=605340#c1
--- Comment #1 from Matthew Smit <zapp70 at hotmail.com> 2010-07-03 00:37:17 UTC ---
This should do it. Haven't had a chance to fully run tests on it yet.
Index:
String.cs===================================================================
--- String.cs (revision 158670)
+++ String.cs (working copy)
public int LastIndexOf (string value, StringComparison comparisonType)
{
if (this.Length == 0)
- return value == String.Empty ? 0 : -1;
+ return value == -1;
else
return LastIndexOf (value, this.Length - 1, this.Length,
comparisonType);
}
public int LastIndexOf (char value, int startIndex, int count)
{
- if (startIndex == 0 && this.length == 0)
+ if (this.length == 0)
return -1;
// >= for char (> for string)
if ((startIndex < 0) || (startIndex >= this.Length))
throw new ArgumentOutOfRangeException ("startIndex", "< 0 || >=
this.Length");
if ((count < 0) || (count > this.Length))
throw new ArgumentOutOfRangeException ("count", "< 0 || >
this.Length");
if (startIndex - count + 1 < 0)
throw new ArgumentOutOfRangeException ("startIndex - count + 1 <
0");
return LastIndexOfUnchecked (value, startIndex, count);
}
--
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