summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-28 20:38:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-28 20:38:04 +0000
commite7d2f303b737a33b99c9f93a093dad029bc1c24e (patch)
tree25305d59eda8cc6de9a1cc4868ada06941b51a6d /file.c
parent78b5fdd5a88b001c7576f23df49ed6cdd030229e (diff)
* file.c (rb_find_file_ext, rb_find_file): converts Windows style path
to Cygwin path. [ruby-dev:35647] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/file.c b/file.c
index 8ea0c65bae..78e7a14591 100644
--- a/file.c
+++ b/file.c
@@ -4447,6 +4447,14 @@ file_load_ok(const char *path)
return eaccess(path, R_OK) == 0;
}
+static int
+is_explicit_relative(const char *path)
+{
+ if (*path++ != '.') return 0;
+ if (*path == '.') path++;
+ return isdirsep(*path);
+}
+
VALUE rb_get_load_path(void);
int
@@ -4468,15 +4476,18 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
*filep = fname;
}
- if (is_absolute_path(f)) {
+ if (is_absolute_path(f) || is_explicit_relative(f)) {
+ fname = rb_str_dup(*filep);
+ fnlen = RSTRING_LEN(fname);
for (i=0; ext[i]; i++) {
- fname = rb_str_dup(*filep);
rb_str_cat2(fname, ext[i]);
- OBJ_FREEZE(fname);
if (file_load_ok(StringValueCStr(fname))) {
+ if (!is_absolute_path(f)) fname = rb_file_expand_path(fname, Qnil);
+ OBJ_FREEZE(fname);
*filep = fname;
return i+1;
}
+ rb_str_set_len(fname, fnlen);
}
return 0;
}
@@ -4534,12 +4545,13 @@ rb_find_file(VALUE path)
}
#endif
- if (is_absolute_path(f)) {
+ if (is_absolute_path(f) || is_explicit_relative(f)) {
if (rb_safe_level() >= 1 && !fpath_check(f)) {
rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
}
- if (file_load_ok(f)) return path;
- return 0;
+ if (!file_load_ok(f)) return 0;
+ if (!is_absolute_path(f)) path = rb_file_expand_path(path, Qnil);
+ return path;
}
if (rb_safe_level() >= 4) {