diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-28 20:38:04 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-28 20:38:04 +0000 |
commit | e7d2f303b737a33b99c9f93a093dad029bc1c24e (patch) | |
tree | 25305d59eda8cc6de9a1cc4868ada06941b51a6d | |
parent | 78b5fdd5a88b001c7576f23df49ed6cdd030229e (diff) | |
download | ruby-e7d2f303b737a33b99c9f93a093dad029bc1c24e.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | file.c | 24 |
2 files changed, 23 insertions, 6 deletions
@@ -1,3 +1,8 @@ +Tue Jul 29 05:37:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (rb_find_file_ext, rb_find_file): converts Windows style path + to Cygwin path. [ruby-dev:35647] + Tue Jul 29 02:39:46 2008 NARUSE, Yui <naruse@ruby-lang.org> * math.c (math_atanh): raise EDOM on FreeBSD when atanh(1). @@ -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) { |