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:
@@ -1060,6 +1060,10 @@ KInt Kotlin_String_indexOfString(KString thiz, KString other, KInt fromIndex) {
|
|||||||
other->count_ > thiz->count_ - fromIndex) {
|
other->count_ > thiz->count_ - fromIndex) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
// An empty string can be always found.
|
||||||
|
if (other->count_ == 0) {
|
||||||
|
return fromIndex;
|
||||||
|
}
|
||||||
KInt count = thiz->count_;
|
KInt count = thiz->count_;
|
||||||
const KChar* thizRaw = CharArrayAddressOfElementAt(thiz, fromIndex);
|
const KChar* thizRaw = CharArrayAddressOfElementAt(thiz, fromIndex);
|
||||||
const KChar* otherRaw = CharArrayAddressOfElementAt(other, 0);
|
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)
|
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
|
* Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression
|
||||||
* with the given [replacement].
|
* with the given [replacement].
|
||||||
|
|||||||
Reference in New Issue
Block a user