diff options
| -rw-r--r-- | src/path.h | 7 | ||||
| -rw-r--r-- | src/win32/path_w32.c | 11 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/path.h b/src/path.h index 360372cfb..d674b1b94 100644 --- a/src/path.h +++ b/src/path.h @@ -105,6 +105,9 @@ GIT_INLINE(int) git_path_is_dot_or_dotdotW(const wchar_t *name) (name[1] == L'.' && name[2] == L'\0'))); } +#define git_path_is_absolute(p) \ + (git__isalpha((p)[0]) && (p)[1] == ':' && ((p)[2] == '\\' || (p)[2] == '/')) + /** * Convert backslashes in path to forward slashes. */ @@ -119,6 +122,10 @@ GIT_INLINE(void) git_path_mkposix(char *path) } #else # define git_path_mkposix(p) /* blank */ + +#define git_path_is_absolute(p) \ + ((p)[0] == '/') + #endif /** diff --git a/src/win32/path_w32.c b/src/win32/path_w32.c index f8416b848..8cea48b58 100644 --- a/src/win32/path_w32.c +++ b/src/win32/path_w32.c @@ -20,9 +20,6 @@ #define path__is_dirsep(p) ((p) == '/' || (p) == '\\') -#define path__is_absolute(p) \ - (git__isalpha((p)[0]) && (p)[1] == ':' && ((p)[2] == '\\' || (p)[2] == '/')) - #define path__is_nt_namespace(p) \ (((p)[0] == '\\' && (p)[1] == '\\' && (p)[2] == '?' && (p)[3] == '\\') || \ ((p)[0] == '/' && (p)[1] == '/' && (p)[2] == '?' && (p)[3] == '/')) @@ -73,9 +70,9 @@ static wchar_t *path__skip_prefix(wchar_t *path) if (wcsncmp(path, L"UNC\\", 4) == 0) path = path__skip_server(path + 4); - else if (path__is_absolute(path)) + else if (git_path_is_absolute(path)) path += PATH__ABSOLUTE_LEN; - } else if (path__is_absolute(path)) { + } else if (git_path_is_absolute(path)) { path += PATH__ABSOLUTE_LEN; } else if (path__is_unc(path)) { path = path__skip_server(path + 2); @@ -196,7 +193,7 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src) dest += PATH__NT_NAMESPACE_LEN; /* See if this is an absolute path (beginning with a drive letter) */ - if (path__is_absolute(src)) { + if (git_path_is_absolute(src)) { if (git__utf8_to_16(dest, MAX_PATH, src) < 0) goto on_error; } @@ -220,7 +217,7 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src) if (path__cwd(dest, MAX_PATH) < 0) goto on_error; - if (!path__is_absolute(dest)) { + if (!git_path_is_absolute(dest)) { errno = ENOENT; goto on_error; } |
