ruby-changes:11417
From: shyouhei <ko1@a...>
Date: Mon, 23 Mar 2009 17:46:38 +0900 (JST)
Subject: [ruby-changes:11417] Ruby:r23040 (ruby_1_8_7): merge revision(s) 22654:22661:
shyouhei 2009-03-23 17:44:31 +0900 (Mon, 23 Mar 2009) New Revision: 23040 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23040 Log: merge revision(s) 22654:22661: * file.c (file_load_ok): checks if regular file, except for the platform disallows to open directories, e.g. dosish. [ruby-dev:38097], [Bug #1221] Modified files: branches/ruby_1_8_7/ChangeLog branches/ruby_1_8_7/file.c branches/ruby_1_8_7/version.h Index: ruby_1_8_7/ChangeLog =================================================================== --- ruby_1_8_7/ChangeLog (revision 23039) +++ ruby_1_8_7/ChangeLog (revision 23040) @@ -1,3 +1,9 @@ +Mon Mar 23 17:41:49 2009 Nobuyoshi Nakada <nobu@r...> + + * file.c (file_load_ok): checks if regular file, except for the + platform disallows to open directories, e.g. dosish. + [ruby-dev:38097], [Bug #1221] + Mon Mar 9 20:59:24 2009 Shugo Maeda <shugo@r...> * ext/openssl/ossl_ocsp.c (ossl_ocspbres_verify): OCSP_basic_verify Index: ruby_1_8_7/version.h =================================================================== --- ruby_1_8_7/version.h (revision 23039) +++ ruby_1_8_7/version.h (revision 23040) @@ -1,15 +1,15 @@ #define RUBY_VERSION "1.8.7" -#define RUBY_RELEASE_DATE "2009-03-09" +#define RUBY_RELEASE_DATE "2009-03-23" #define RUBY_VERSION_CODE 187 -#define RUBY_RELEASE_CODE 20090309 -#define RUBY_PATCHLEVEL 150 +#define RUBY_RELEASE_CODE 20090323 +#define RUBY_PATCHLEVEL 151 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_TEENY 7 #define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 9 +#define RUBY_RELEASE_DAY 23 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; Index: ruby_1_8_7/file.c =================================================================== --- ruby_1_8_7/file.c (revision 23039) +++ ruby_1_8_7/file.c (revision 23040) @@ -288,7 +288,6 @@ #endif } - /* * call-seq: * stat.ino => fixnum @@ -353,7 +352,6 @@ return UINT2NUM(get_stat(self)->st_nlink); } - /* * call-seq: * stat.uid => fixnum @@ -388,7 +386,6 @@ return UINT2NUM(get_stat(self)->st_gid); } - /* * call-seq: * stat.rdev => fixnum or nil @@ -518,7 +515,6 @@ #endif } - /* * call-seq: * stat.atime => time @@ -784,7 +780,6 @@ #endif } - /* * call-seq: * file.lstat => stat @@ -914,7 +909,6 @@ * */ - /* * call-seq: * File.directory?(file_name) => true or false @@ -1103,7 +1097,6 @@ return Qfalse; } - /* * call-seq: * File.exist?(file_name) => true or false @@ -1156,7 +1149,6 @@ return Qtrue; } - /* * call-seq: * File.writable?(file_name) => true or false @@ -1934,7 +1926,6 @@ rb_sys_fail(path); } - /* * call-seq: * file.lchown(owner_int, group_int, file_name,..) => integer @@ -3630,7 +3621,6 @@ } - /* * Document-class: File::Stat * @@ -3948,8 +3938,6 @@ return Qtrue; } - - /* * call-seq: * stat.readable_real? -> true or false @@ -4098,7 +4086,6 @@ * the process. */ - static VALUE rb_stat_X(obj) VALUE obj; @@ -4162,7 +4149,6 @@ return Qfalse; } - /* * call-seq: * state.size => integer @@ -4379,13 +4365,19 @@ file_load_ok(file) const char *file; { - FILE *f; - - if (!file) return 0; - f = fopen(file, "r"); - if (f == NULL) return 0; - fclose(f); - return 1; + int ret = 1; + int fd = open(file, O_RDONLY); + if (fd == -1) return 0; +#if !defined DOSISH + { + struct stat st; + if (fstat(fd, &st) || !S_ISREG(st.st_mode)) { + ret = 0; + } + } +#endif + (void)close(fd); + return ret; } extern VALUE rb_load_path; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/