path: expose `git_path_is_dirsep` This function has previously been implemented in Windows-specific path handling code as `path__is_dirsep`. As we will need this functionality in other parts, extract the logic into "path.h" alongside with a non-Windows implementation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/src/path.h b/src/path.h
index d674b1b..aa24bcd 100644
--- a/src/path.h
+++ b/src/path.h
@@ -108,6 +108,9 @@ GIT_INLINE(int) git_path_is_dot_or_dotdotW(const wchar_t *name)
#define git_path_is_absolute(p) \
(git__isalpha((p)[0]) && (p)[1] == ':' && ((p)[2] == '\\' || (p)[2] == '/'))
+#define git_path_is_dirsep(p) \
+ ((p) == '/' || (p) == '\\')
+
/**
* Convert backslashes in path to forward slashes.
*/
@@ -126,6 +129,9 @@ GIT_INLINE(void) git_path_mkposix(char *path)
#define git_path_is_absolute(p) \
((p)[0] == '/')
+#define git_path_is_dirsep(p) \
+ ((p) == '/')
+
#endif
/**
diff --git a/src/win32/path_w32.c b/src/win32/path_w32.c
index 8cea48b..5e24260 100644
--- a/src/win32/path_w32.c
+++ b/src/win32/path_w32.c
@@ -18,8 +18,6 @@
#define PATH__ABSOLUTE_LEN 3
-#define path__is_dirsep(p) ((p) == '/' || (p) == '\\')
-
#define path__is_nt_namespace(p) \
(((p)[0] == '\\' && (p)[1] == '\\' && (p)[2] == '?' && (p)[3] == '\\') || \
((p)[0] == '/' && (p)[1] == '/' && (p)[2] == '?' && (p)[3] == '/'))
@@ -56,7 +54,7 @@ static wchar_t *path__skip_server(wchar_t *path)
wchar_t *c;
for (c = path; *c; c++) {
- if (path__is_dirsep(*c))
+ if (git_path_is_dirsep(*c))
return c + 1;
}