summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-io.h6
-rw-r--r--source/core/slang-string.cpp15
-rw-r--r--source/core/slang-string.h1
3 files changed, 21 insertions, 1 deletions
diff --git a/source/core/slang-io.h b/source/core/slang-io.h
index 43812aaf9..4de246289 100644
--- a/source/core/slang-io.h
+++ b/source/core/slang-io.h
@@ -63,6 +63,12 @@ namespace Slang
static const char kPathDelimiter = '/';
+#if SLANG_WINDOWS_FAMILY
+ static const char kOSCanonicalPathDelimiter = '\\';
+#else
+ static const char kOSCanonicalPathDelimiter = '/';
+#endif
+
/// Finds all all the items in the specified directory, that matches the pattern.
///
/// @param directoryPath The directory to do the search in. If the directory is not found, SLANG_E_NOT_FOUND is returned
diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp
index 03de07ee1..c02ba048d 100644
--- a/source/core/slang-string.cpp
+++ b/source/core/slang-string.cpp
@@ -134,7 +134,7 @@ namespace Slang
if (otherSize > thisSize)
return false;
- return UnownedStringSlice(begin(), begin() + otherSize) == other;
+ return head(otherSize) == other;
}
bool UnownedStringSlice::startsWith(char const* str) const
@@ -142,6 +142,17 @@ namespace Slang
return startsWith(UnownedTerminatedStringSlice(str));
}
+ bool UnownedStringSlice::startsWithCaseInsensitive(UnownedStringSlice const& other) const
+ {
+ UInt thisSize = getLength();
+ UInt otherSize = other.getLength();
+
+ if (otherSize > thisSize)
+ return false;
+
+ return head(otherSize).caseInsensitiveEquals(other);
+ }
+
bool UnownedStringSlice::endsWith(UnownedStringSlice const& other) const
{
@@ -474,6 +485,8 @@ namespace Slang
{
auto oldLength = getLength();
auto textLength = textEnd - textBegin;
+ if (textLength <= 0)
+ return;
auto newLength = oldLength + textLength;
diff --git a/source/core/slang-string.h b/source/core/slang-string.h
index 59d441b76..69ca7e2c3 100644
--- a/source/core/slang-string.h
+++ b/source/core/slang-string.h
@@ -154,6 +154,7 @@ namespace Slang
/// True if contents is a single char of c
SLANG_FORCE_INLINE bool isChar(char c) const { return getLength() == 1 && m_begin[0] == c; }
+ bool startsWithCaseInsensitive(UnownedStringSlice const& other) const;
bool startsWith(UnownedStringSlice const& other) const;
bool startsWith(char const* str) const;