summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-09 21:59:51 -0500
committerpommicket <pommicket@gmail.com>2023-01-09 22:00:23 -0500
commit7f0255cb40bb85276191ec3ddffe507e53abf2ac (patch)
tree2376d10183d4085a7e8c85bba008f8ba3516d731 /util.c
parentce158f26b9136b3fc831c6325ad911e3bf403a4b (diff)
fixed a bunch of windows stuff
also compile_commands.json does fix the usages problem!
Diffstat (limited to 'util.c')
-rw-r--r--util.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/util.c b/util.c
index d1daa7d..ef96d29 100644
--- a/util.c
+++ b/util.c
@@ -126,11 +126,14 @@ bool str_has_prefix(const char *str, const char *prefix) {
return strncmp(str, prefix, strlen(prefix)) == 0;
}
-// e.g. "/usr/share/bla" has the path prefix "/usr/share" but not "/usr/sha"
bool str_has_path_prefix(const char *path, const char *prefix) {
size_t prefix_len = strlen(prefix);
- if (strncmp(path, prefix, prefix_len) != 0)
- return false;
+ for (int i = 0; i < prefix_len; ++i) {
+ if (strchr(ALL_PATH_SEPARATORS, path[i]) && strchr(ALL_PATH_SEPARATORS, prefix[i]))
+ continue; // treat all path separators as the same
+ if (prefix[i] != path[i])
+ return false;
+ }
return path[prefix_len] == '\0' || strchr(ALL_PATH_SEPARATORS, path[prefix_len]);
}