summaryrefslogtreecommitdiffstats
path: root/source/core/slang-string-util.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-06-08 11:54:27 -0700
committerGitHub <noreply@github.com>2022-06-08 11:54:27 -0700
commit1146920bc9ed9bef2b5bb91b3cdec4700eb09881 (patch)
treee8d94a3aad0d204f7c33f38b42b9e03d862cc3c8 /source/core/slang-string-util.cpp
parentff2ae7e0c1b48fa222f14dc84f15d0178ed056a1 (diff)
Add smoke test for language server. (#2266)
Diffstat (limited to 'source/core/slang-string-util.cpp')
-rw-r--r--source/core/slang-string-util.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp
index 5282f01a6..c4b654072 100644
--- a/source/core/slang-string-util.cpp
+++ b/source/core/slang-string-util.cpp
@@ -645,4 +645,28 @@ ComPtr<ISlangBlob> StringUtil::createStringBlob(const String& string)
return (cur == end) ? SLANG_OK : SLANG_FAIL;
}
+int StringUtil::parseIntAndAdvancePos(UnownedStringSlice text, Index& pos)
+{
+ int result = 0;
+ while (text[pos] == ' ' && pos < text.getLength())
+ {
+ pos++;
+ continue;
+ }
+ while (pos < text.getLength())
+ {
+ if (text[pos] >= '0' && text[pos] <= '9')
+ {
+ result *= 10;
+ result += text[pos] - '0';
+ pos++;
+ }
+ else
+ {
+ break;
+ }
+ }
+ return result;
+}
+
} // namespace Slang