summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-06 10:30:23 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-06 10:30:23 +0000
commit23a434b3630b05781dc48e07582ed180d9661a6a (patch)
tree83bde2edb6f31506b8c262c07351691d0aa5e030
parent2cb931f2b270f10baeb1cadca9e1d31092f8529c (diff)
* file.c (file_expand_path): fix for non-existent files and SFN of
symlinks. [ruby-talk:303736] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--file.c33
-rw-r--r--version.h2
3 files changed, 21 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 1fd8f51325..822844e4e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jun 6 19:23:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (file_expand_path): fix for non-existent files and SFN of
+ symlinks. [ruby-talk:303736]
+
Fri Jun 6 18:25:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/iconv: Tests fixed.
diff --git a/file.c b/file.c
index 8d54961ec3..eacf06644b 100644
--- a/file.c
+++ b/file.c
@@ -2742,57 +2742,54 @@ file_expand_path(fname, dname, result)
#if USE_NTFS
*p = '\0';
- if (1 &&
-#ifdef __CYGWIN__
- !(buf[0] == '/' && !buf[1]) &&
-#endif
- !strpbrk(b = buf, "*?")) {
+ if (*(s = skipprefix(b = buf)) && !strpbrk(s, "*?")) {
size_t len;
WIN32_FIND_DATA wfd;
#ifdef __CYGWIN__
int lnk_added = 0, is_symlink = 0;
struct stat st;
- char w32buf[MAXPATHLEN], sep = 0;
- p = 0;
+ char w32buf[MAXPATHLEN];
+ p = strrdirsep(s);
if (lstat(buf, &st) == 0 && S_ISLNK(st.st_mode)) {
is_symlink = 1;
- p = strrdirsep(buf);
- if (!p) p = skipprefix(buf);
- if (p) {
- sep = *p;
- *p = '\0';
- }
+ *p = '\0';
}
- if (cygwin_conv_to_win32_path(buf, w32buf) == 0) {
+ if (cygwin_conv_to_win32_path((*buf ? buf : "/"), w32buf) == 0) {
b = w32buf;
}
- if (p) *p = sep;
- else p = buf;
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));
}
}
+ *p = '/';
#endif
HANDLE h = FindFirstFile(b, &wfd);
if (h != INVALID_HANDLE_VALUE) {
FindClose(h);
- p = strrdirsep(buf);
len = strlen(wfd.cFileName);
#ifdef __CYGWIN__
if (lnk_added && len > 4 &&
strcasecmp(wfd.cFileName + len - 4, ".lnk") == 0) {
wfd.cFileName[len -= 4] = '\0';
}
+#else
+ p = strrdirsep(s);
#endif
- if (!p) p = buf;
++p;
BUFCHECK(bdiff + len >= buflen);
memcpy(p, wfd.cFileName, len + 1);
p += len;
}
+#ifdef __CYGWIN__
+ else {
+ p += strlen(p);
+ }
+#endif
}
#endif
diff --git a/version.h b/version.h
index 90101f28c5..929bae5494 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2008-06-06"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20080606
-#define RUBY_PATCHLEVEL 7
+#define RUBY_PATCHLEVEL 8
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8