aboutsummaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
authorRilleP <rikkypikki@hotmail.com>2024-04-10 19:10:33 +0200
committerGitHub <noreply@github.com>2024-04-10 19:10:33 +0200
commit95a38d5a96322cd9adbb03bd5b7425b93469e62f (patch)
tree8cdc3b962506ddc4b7b1883f0e2ecb9dce54e2f9 /src/string.cpp
parent239d4e10762a12e96280bd91003acbf2170cadf2 (diff)
parent13e459980b0143b49762cdfd04dd5cf1bbf83daa (diff)
Merge branch 'master' into parsing-package-fixes
Diffstat (limited to 'src/string.cpp')
-rw-r--r--src/string.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/string.cpp b/src/string.cpp
index 9fb933b1b..7bfa52f33 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -89,7 +89,6 @@ gb_internal char *alloc_cstring(gbAllocator a, String s) {
}
-
gb_internal gb_inline bool str_eq_ignore_case(String const &a, String const &b) {
if (a.len == b.len) {
for (isize i = 0; i < a.len; i++) {
@@ -104,6 +103,16 @@ gb_internal gb_inline bool str_eq_ignore_case(String const &a, String const &b)
return false;
}
+template <isize N>
+gb_internal gb_inline bool str_eq_ignore_case(String const &a, char const (&b_)[N]) {
+ if (a.len != N-1) {
+ return false;
+ }
+ String b = {cast(u8 *)b_, N-1};
+ return str_eq_ignore_case(a, b);
+}
+
+
gb_internal void string_to_lower(String *s) {
for (isize i = 0; i < s->len; i++) {
s->text[i] = gb_char_to_lower(s->text[i]);
@@ -293,6 +302,18 @@ gb_internal String filename_from_path(String s) {
return make_string(nullptr, 0);
}
+
+gb_internal String filename_without_directory(String s) {
+ isize j = 0;
+ for (j = s.len-1; j >= 0; j--) {
+ if (s[j] == '/' ||
+ s[j] == '\\') {
+ break;
+ }
+ }
+ return substring(s, gb_max(j+1, 0), s.len);
+}
+
gb_internal String concatenate_strings(gbAllocator a, String const &x, String const &y) {
isize len = x.len+y.len;
u8 *data = gb_alloc_array(a, u8, len+1);