summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-06-08 14:08:34 -0700
committerRussell Belfer <rb@github.com>2012-06-08 14:08:34 -0700
commitac971ecfdb11af8fa36c15eb9afb0fd8545daf08 (patch)
tree11e245f0a0ef17dc043029575f1594d1ca558156
parentd17db71b6f8343204683542538416ec87e06261e (diff)
downloadlibgit2-ac971ecfdb11af8fa36c15eb9afb0fd8545daf08.tar.gz
Better fix for isalpha in drive letter detection
Missed a place that used this and missed git__isalpha
-rw-r--r--src/path.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/path.c b/src/path.c
index c61f18c9d..1d85559a9 100644
--- a/src/path.c
+++ b/src/path.c
@@ -17,6 +17,10 @@
#include <stdio.h>
#include <ctype.h>
+#ifdef GIT_WIN32
+#define LOOKS_LIKE_DRIVE_PREFIX(S) (git__isalpha((S)[0]) && (S)[1] == ':')
+#endif
+
/*
* Based on the Android implementation, BSD licensed.
* Check http://android.git.kernel.org/
@@ -105,7 +109,7 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
/* Mimic unix behavior where '/.git' returns '/': 'C:/.git' will return
'C:/' here */
- if (len == 2 && isalpha(path[0]) && path[1] == ':') {
+ if (len == 2 && LOOKS_LIKE_DRIVE_PREFIX(path)) {
len = 3;
goto Exit;
}
@@ -170,8 +174,7 @@ int git_path_root(const char *path)
#ifdef GIT_WIN32
/* Does the root of the path look like a windows drive ? */
- if (((path[0] >= 'a' && path[0] <= 'z') ||
- (path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':')
+ if (LOOKS_LIKE_DRIVE_PREFIX(path))
offset += 2;
/* Are we dealing with a windows network path? */
@@ -211,7 +214,7 @@ int git_path_prettify(git_buf *path_out, const char *path, const char *base)
giterr_set(GITERR_OS, "Failed to resolve path '%s'", path);
git_buf_clear(path_out);
-
+
return error;
}