From e7d2f303b737a33b99c9f93a093dad029bc1c24e Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 28 Jul 2008 20:38:04 +0000 Subject: * 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 --- ChangeLog | 5 +++++ file.c | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4ef3e2f28f..1081a83bf6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jul 29 05:37:53 2008 Nobuyoshi Nakada + + * 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 * math.c (math_atanh): raise EDOM on FreeBSD when atanh(1). 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) { -- cgit v1.2.3