summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-24 12:02:40 -0500
committerpommicket <pommicket@gmail.com>2022-12-24 12:02:40 -0500
commita6a06900bf7206dc86017bbb1895272ebfac5418 (patch)
tree2f49cee6002d5d10bb4afc0db18425e5f5dfb38e /util.c
parent1c346f2aba30fcb581f20f2b67bd5e6adcb4a7e6 (diff)
start LSP setting
Diffstat (limited to 'util.c')
-rw-r--r--util.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/util.c b/util.c
index 32115cf..a87d230 100644
--- a/util.c
+++ b/util.c
@@ -80,6 +80,14 @@ static bool str_has_prefix(char const *str, char const *prefix) {
return strncmp(str, prefix, strlen(prefix)) == 0;
}
+// e.g. "/usr/share/bla" has the path prefix "/usr/share" but not "/usr/sha"
+static 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;
+ return path[prefix_len] == '\0' || strchr(ALL_PATH_SEPARATORS, path[prefix_len]);
+}
+
static bool streq(char const *a, char const *b) {
return strcmp(a, b) == 0;
}