aboutsummaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
authorAndreas T Jonsson <mail@andreasjonsson.se>2024-05-10 09:04:52 +0200
committerAndreas T Jonsson <mail@andreasjonsson.se>2024-05-10 09:04:52 +0200
commitb72c2edabbc9087b07a30b781de1925d6570dd62 (patch)
tree0e96f43038901ec8c6f6b015071c1803a2166d41 /src/string.cpp
parent273e4c6b4ce6f1060870782c8e780fe2b371ede4 (diff)
parent41bd8cf7143902db59c02c56fc5318a7e749d7a5 (diff)
Merge branch 'master' into netbsd
Diffstat (limited to 'src/string.cpp')
-rw-r--r--src/string.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/string.cpp b/src/string.cpp
index b92dd589e..86eddeddd 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -328,6 +328,25 @@ gb_internal bool string_contains_char(String const &s, u8 c) {
return false;
}
+gb_internal bool string_contains_string(String const &haystack, String const &needle) {
+ if (needle.len == 0) return true;
+ if (needle.len > haystack.len) return false;
+
+ for (isize i = 0; i <= haystack.len - needle.len; i++) {
+ bool found = true;
+ for (isize j = 0; j < needle.len; j++) {
+ if (haystack[i + j] != needle[j]) {
+ found = false;
+ break;
+ }
+ }
+ if (found) {
+ return true;
+ }
+ }
+ return false;
+}
+
gb_internal String filename_from_path(String s) {
isize i = string_extension_position(s);
if (i >= 0) {