summaryrefslogtreecommitdiff
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
parentfe9f1e8cf8a1d49c7d4d6baff2f1797ff89e7956 (diff)
* 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
-rw-r--r--ChangeLog7
-rw-r--r--configure.in1
-rw-r--r--file.c37
-rw-r--r--ruby.c11
4 files changed, 46 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index ac46654a75..347db71c7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Nov 11 21:24:36 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (file_expand_path): use cygwin_conv_path on cygwin 1.7 or
+ later.
+
+ * ruby.c (push_include_cygwin): ditto.
+
Thu Nov 11 20:49:48 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/ruby.h (PRI_LL_PREFIX): format type specifier for
diff --git a/configure.in b/configure.in
index 3346a91194..8f5bc1d54f 100644
--- a/configure.in
+++ b/configure.in
@@ -989,6 +989,7 @@ main()
LIBS="$LIBS" # m lib is include in root under BeOS/Haiku
],
[cygwin*], [ ac_cv_header_langinfo_h=yes
+ AC_CHECK_FUNCS(cygwin_conv_path)
AC_LIBOBJ([langinfo])
],
[mingw*], [ LIBS="-lshell32 -lws2_32 -limagehlp $LIBS"
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);
diff --git a/ruby.c b/ruby.c
index 61e8dcc443..ecce05afe4 100644
--- a/ruby.c
+++ b/ruby.c
@@ -255,7 +255,14 @@ push_include_cygwin(const char *path, VALUE (*filter)(VALUE))
p = strncpy(RSTRING_PTR(buf), p, len);
}
}
- if (cygwin_conv_to_posix_path(p, rubylib) == 0)
+#ifdef HAVE_CYGWIN_CONV_PATH
+#define CONV_TO_POSIX_PATH(p, lib) \
+ cygwin_conv_path(CCP_WIN_A_TO_POSIX|CCP_RELATIVE, p, lib, sizeof(lib))
+#else
+#define CONV_TO_POSIX_PATH(p, lib) \
+ cygwin_conv_to_posix_path(p, lib)
+#endif
+ if (CONV_TO_POSIX_PATH(p, rubylib) == 0)
p = rubylib;
push_include(p, filter);
if (!*s) break;
@@ -343,7 +350,7 @@ ruby_init_loadpath_safe(int safe_level)
extern const char ruby_initial_load_paths[];
const char *paths = ruby_initial_load_paths;
#if defined LOAD_RELATIVE
-# if defined HAVE_DLADDR || (defined __CYGWIN__ && defined CCP_WIN_A_TO_POSIX)
+# if defined HAVE_DLADDR || defined HAVE_CYGWIN_CONV_PATH
# define VARIABLE_LIBPATH 1
# else
# define VARIABLE_LIBPATH 0