stdlib: Always find an empty substring

This patch fixes the following tests:
    external_stdlib_text_StringTest/replace.kt
    external_stdlib_text_StringTest/replaceDelimited.kt
    external_stdlib_text_StringTest/replaceFirst.kt
This commit is contained in:
Ilya Matveev
2017-04-25 14:35:21 +07:00
committed by ilmat192
parent a4f3691a7b
commit a8dad22332
2 changed files with 4 additions and 4 deletions
+4
View File
@@ -1060,6 +1060,10 @@ KInt Kotlin_String_indexOfString(KString thiz, KString other, KInt fromIndex) {
other->count_ > thiz->count_ - fromIndex) {
return -1;
}
// An empty string can be always found.
if (other->count_ == 0) {
return fromIndex;
}
KInt count = thiz->count_;
const KChar* thizRaw = CharArrayAddressOfElementAt(thiz, fromIndex);
const KChar* otherRaw = CharArrayAddressOfElementAt(other, 0);
@@ -640,10 +640,6 @@ public fun String.replaceBeforeLast(delimiter: String, replacement: String, miss
return if (index == -1) missingDelimiterValue else replaceRange(0, index, replacement)
}
// public fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean): String // JVM- and JS-specific
// public fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean): String // JVM- and JS-specific
/**
* Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression
* with the given [replacement].