diff options
author | Matt Ellis <matell@microsoft.com> | 2015-03-25 14:26:38 -0700 |
---|---|---|
committer | Matt Ellis <matell@microsoft.com> | 2015-03-25 14:26:38 -0700 |
commit | ce4fda35c5a3979b6c553f9b7fd8b413a6075468 (patch) | |
tree | 854dbb52191de1e7e4eec55f525a28af04608840 | |
parent | a44381191ef117d59f1f70b6821dfc283ded283e (diff) | |
parent | f08b4fa92d9c0d8101005107859d978f43f02300 (diff) | |
download | coreclr-ce4fda35c5a3979b6c553f9b7fd8b413a6075468.tar.gz coreclr-ce4fda35c5a3979b6c553f9b7fd8b413a6075468.tar.bz2 coreclr-ce4fda35c5a3979b6c553f9b7fd8b413a6075468.zip |
Merge pull request #564 from stephentoub/fix_lastindexof_unix
Fix LastIndexOfOrdinal on Unix
-rw-r--r-- | src/mscorlib/corefx/System/Globalization/CompareInfo.Unix.cs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mscorlib/corefx/System/Globalization/CompareInfo.Unix.cs b/src/mscorlib/corefx/System/Globalization/CompareInfo.Unix.cs index 73a9190de7..fb80cc2f95 100644 --- a/src/mscorlib/corefx/System/Globalization/CompareInfo.Unix.cs +++ b/src/mscorlib/corefx/System/Globalization/CompareInfo.Unix.cs @@ -54,18 +54,19 @@ namespace System.Globalization value = value.ToUpper(CultureInfo.InvariantCulture); } - source = source.Substring(startIndex, count); + source = source.Substring(startIndex - count + 1, count); int last = -1; - int cur = 0; - while((cur = IndexOfOrdinal(source, value, 0, source.Length, false)) != -1) + int cur = 0; + while ((cur = IndexOfOrdinal(source, value, last + 1, source.Length - last - 1, false)) != -1) { last = cur; - source = source.Substring(last + value.Length); } - return last; + return last >= 0 ? + last + startIndex - count + 1 : + -1; } private unsafe int GetHashCodeOfStringCore(string source, CompareOptions options) |