* 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
This commit is contained in:
nobu 2008-07-28 20:38:04 +00:00
Родитель 78b5fdd5a8
Коммит e7d2f303b7
2 изменённых файлов: 23 добавлений и 6 удалений

Просмотреть файл

@ -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).

24
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) {