Commit f38ce9b61dee1bb2d3ba495937c685311f196574

Patrick Steinhardt 2017-05-24T11:09:38

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.

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;
 	}