* 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
This commit is contained in:
nobu 2010-11-11 12:24:41 +00:00
parent fe9f1e8cf8
commit 41cae1744f
4 changed files with 49 additions and 13 deletions

View File

@ -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

View File

@ -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"

43
file.c
View File

@ -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 (cygwin_conv_to_win32_path((*buf ? buf : "/"), w32buf) == 0) {
b = w32buf;
}
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));
}
}
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, bufsize);
if (lnk_added) {
strlcat(w32buf, ".lnk", bufsize);
}
}
else {
lnk_added = 0;
}
*p = '/';
#endif
HANDLE h = FindFirstFile(b, &wfd);

11
ruby.c
View File

@ -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