summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-11 12:24:41 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-11 12:24:41 +0000
commit41cae1744fcc9d7dd0c6d332ab3b94eaf954d1dd (patch)
treeed0cecfdf5bc010c59666daa9ca8df84f74489bf /file.c
parentfe9f1e8cf8a1d49c7d4d6baff2f1797ff89e7956 (diff)
downloadbundler-41cae1744fcc9d7dd0c6d332ab3b94eaf954d1dd.tar.gz
* file.c (file_expand_path): use cygwin_conv_path on cygwin 1.7 or
later. * ruby.c (push_include_cygwin): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/file.c b/file.c
index 9cca3d01b7..dc9f830fc7 100644
--- a/file.c
+++ b/file.c
@@ -3088,26 +3088,47 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result)
size_t len;
WIN32_FIND_DATA wfd;
#ifdef __CYGWIN__
+ ssize_t bufsize;
int lnk_added = 0, is_symlink = 0;
struct stat st;
- char w32buf[MAXPATHLEN];
p = (char *)s;
+ len = strlen(p);
if (lstat(buf, &st) == 0 && S_ISLNK(st.st_mode)) {
is_symlink = 1;
- *p = '\0';
+ if (len > 4 && STRCASECMP(p + len - 4, ".lnk") != 0) {
+ lnk_added = 1;
+ }
}
- if (cygwin_conv_to_win32_path((*buf ? buf : "/"), w32buf) == 0) {
+ const char *path = *buf ? buf : "/";
+#ifdef HAVE_CYGWIN_CONV_PATH
+ char *w32buf = NULL;
+ const int flags = CCP_POSIX_TO_WIN_A | CCP_RELATIVE;
+ bufsize = cygwin_conv_path(flags, path, NULL, 0);
+ if (bufsize > 0) {
+ bufsize += len;
+ if (lnk_added) bufsize += 4;
+ w32buf = ALLOCA_N(char, bufsize);
+ if (cygwin_conv_path(flags, path, w32buf, bufsize) == 0) {
+ b = w32buf;
+ }
+ }
+#else
+ char w32buf[MAXPATHLEN];
+ bufsize = MAXPATHLEN;
+ if (cygwin_conv_to_win32_path(path, w32buf) == 0) {
b = w32buf;
}
+#endif
if (is_symlink && b == w32buf) {
*p = '\\';
- strlcat(w32buf, p, sizeof(w32buf));
- len = strlen(p);
- if (len > 4 && STRCASECMP(p + len - 4, ".lnk") != 0) {
- lnk_added = 1;
- strlcat(w32buf, ".lnk", sizeof(w32buf));
+ strlcat(w32buf, p, bufsize);
+ if (lnk_added) {
+ strlcat(w32buf, ".lnk", bufsize);
}
}
+ else {
+ lnk_added = 0;
+ }
*p = '/';
#endif
HANDLE h = FindFirstFile(b, &wfd);