summaryrefslogtreecommitdiffstats
path: root/src/path.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/path.c b/src/path.c
index 404557a..2240031 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1,12 +1,14 @@
-// Copyright 2007-2022 David Robillard <d@drobilla.net>
+// Copyright 2007-2024 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
-#include "zix/path.h"
+#include <zix/path.h>
#include "index_range.h"
#include "path_iter.h"
-#include "zix/string_view.h"
+#include <zix/allocator.h>
+#include <zix/attributes.h>
+#include <zix/string_view.h>
#include <stdbool.h>
#include <stddef.h>
@@ -92,8 +94,7 @@ typedef struct {
ZixIndexRange dir;
} ZixRootSlices;
-ZIX_PURE_FUNC
-static ZixRootSlices
+ZIX_PURE_FUNC static ZixRootSlices
zix_path_root_slices(const char* const path)
{
// A root name not trailed by a separator has no root directory
@@ -128,8 +129,7 @@ zix_string_ranges_equal(const char* const lhs,
!strncmp(lhs + lhs_range.begin, rhs + rhs_range.begin, lhs_len));
}
-ZIX_PURE_FUNC
-static ZixIndexRange
+ZIX_PURE_FUNC static ZixIndexRange
zix_path_root_path_range(const char* const path)
{
const ZixRootSlices root = zix_path_root_slices(path);
@@ -140,8 +140,7 @@ zix_path_root_path_range(const char* const path)
: zix_make_range(root.name.begin, root.name.end + dir_len);
}
-ZIX_PURE_FUNC
-static ZixIndexRange
+ZIX_PURE_FUNC static ZixIndexRange
zix_path_parent_path_range(const ZixStringView path)
{
if (!path.length) {
@@ -178,8 +177,7 @@ zix_path_parent_path_range(const ZixStringView path)
return zix_make_range(root.begin, root.begin + l + 1U - p);
}
-ZIX_PURE_FUNC
-static ZixIndexRange
+ZIX_PURE_FUNC static ZixIndexRange
zix_path_filename_range(const ZixStringView path)
{
if (!path.length) {
@@ -201,8 +199,7 @@ zix_path_filename_range(const ZixStringView path)
return zix_make_range(f, path.length);
}
-ZIX_PURE_FUNC
-static ZixIndexRange
+ZIX_PURE_FUNC static ZixIndexRange
zix_path_stem_range(const ZixStringView path)
{
const ZixIndexRange name = zix_path_filename_range(path);
@@ -221,8 +218,7 @@ zix_path_stem_range(const ZixStringView path)
return zix_is_empty_range(stem) ? name : stem;
}
-ZIX_PURE_FUNC
-static ZixIndexRange
+ZIX_PURE_FUNC static ZixIndexRange
zix_path_extension_range(const ZixStringView path)
{
const ZixIndexRange stem = zix_path_stem_range(path);
@@ -701,7 +697,7 @@ zix_path_is_absolute(const char* const path)
{
#ifdef _WIN32
const ZixRootSlices root = zix_path_root_slices(path);
- return (!zix_is_empty_range(root.name) &&
+ return (path && !zix_is_empty_range(root.name) &&
(!zix_is_empty_range(root.dir) ||
(is_dir_sep(path[0]) && is_dir_sep(path[1]))));