summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-12-13 08:47:26 +0100
committerGitHub <noreply@github.com>2019-12-13 08:47:26 +0100
commitd39284a65fec4d62d56972e03e7aa7042ad673ea (patch)
tree2915e4a4d3ed2520229a488749140e8042100f5c
parent0da0eec6cc42066626f867079700c10737092217 (diff)
parentd09193b08ae8fdb082bee6ffd3828eb19fd45ce6 (diff)
Merge pull request #34295 from aaronfranke/potato-knishes
[Mono] Fix string Find methods having reversed case sensitivity
-rw-r--r--modules/mono/glue/Managed/Files/StringExtensions.cs14
1 files changed, 7 insertions, 7 deletions
diff --git a/modules/mono/glue/Managed/Files/StringExtensions.cs b/modules/mono/glue/Managed/Files/StringExtensions.cs
index 6045c83e95..079e9912d6 100644
--- a/modules/mono/glue/Managed/Files/StringExtensions.cs
+++ b/modules/mono/glue/Managed/Files/StringExtensions.cs
@@ -18,7 +18,7 @@ namespace Godot
int pos = 0;
int slices = 1;
- while ((pos = instance.Find(splitter, pos)) >= 0)
+ while ((pos = instance.Find(splitter, true, pos)) >= 0)
{
slices++;
pos += splitter.Length;
@@ -325,17 +325,17 @@ namespace Godot
// <summary>
// Find the first occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
// </summary>
- public static int Find(this string instance, string what, int from = 0)
+ public static int Find(this string instance, string what, bool caseSensitive = true, int from = 0)
{
- return instance.IndexOf(what, StringComparison.OrdinalIgnoreCase);
+ return instance.IndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase);
}
// <summary>
// Find the last occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
// </summary>
- public static int FindLast(this string instance, string what)
+ public static int FindLast(this string instance, string what, bool caseSensitive = true, int from = 0)
{
- return instance.LastIndexOf(what, StringComparison.OrdinalIgnoreCase);
+ return instance.LastIndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase);
}
// <summary>
@@ -343,7 +343,7 @@ namespace Godot
// </summary>
public static int FindN(this string instance, string what, int from = 0)
{
- return instance.IndexOf(what, StringComparison.Ordinal);
+ return instance.IndexOf(what, from, StringComparison.OrdinalIgnoreCase);
}
// <summary>
@@ -928,7 +928,7 @@ namespace Godot
while (true)
{
- int end = instance.Find(divisor, from);
+ int end = instance.Find(divisor, true, from);
if (end < 0)
end = len;
if (allowEmpty || end > from)