summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-14 22:33:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-14 22:33:09 +0000
commitb24c8e4dd63b7cfc4b8c83db6552a0ed8301533d (patch)
tree380bbf11fc210bc727c65ff1ff00a10b590282b5 /file.c
parent980a954f11396afc082875684037505c846d54ab (diff)
* file.c (file_alt_separator): commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/file.c b/file.c
index 557e232c84..203e7c2029 100644
--- a/file.c
+++ b/file.c
@@ -2495,6 +2495,7 @@ rb_file_s_umask(int argc, VALUE *argv)
#endif
#ifdef FILE_ALT_SEPARATOR
#define isdirsep(x) ((x) == '/' || (x) == FILE_ALT_SEPARATOR)
+static const char file_alt_separator[] = {FILE_ALT_SEPARATOR, '\0'};
#else
#define isdirsep(x) ((x) == '/')
#endif
@@ -3174,9 +3175,9 @@ realpath_internal(VALUE basedir, VALUE path, int strict)
volatile VALUE unresolved_path;
VALUE loopcheck;
volatile VALUE curdir = Qnil;
-
+
char *path_names = NULL, *basedir_names = NULL, *curdir_names = NULL;
- char *ptr;
+ char *ptr, *prefixptr = NULL;
rb_secure(2);
@@ -3210,11 +3211,21 @@ realpath_internal(VALUE basedir, VALUE path, int strict)
resolved = rb_str_new(ptr, curdir_names - ptr);
root_found:
- ptr = chompdirsep(RSTRING_PTR(resolved));
+ prefixptr = RSTRING_PTR(resolved);
+ prefixlen = RSTRING_LEN(resolved);
+ ptr = chompdirsep(prefixptr);
if (*ptr) {
- rb_str_set_len(resolved, ptr - RSTRING_PTR(resolved) + 1);
+ prefixlen = ++ptr - prefixptr;
+ rb_str_set_len(resolved, prefixlen);
}
- prefixlen = RSTRING_LEN(resolved);
+#ifdef FILE_ALT_SEPARATOR
+ while (prefixptr < ptr) {
+ if (*prefixptr == FILE_ALT_SEPARATOR) {
+ *prefixptr = '/';
+ }
+ prefixptr = CharNext(prefixptr);
+ }
+#endif
loopcheck = rb_hash_new();
if (curdir_names)