From d0f784a071bbca9c2fbc4dc1ff7a2027fc8004c8 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 15 Nov 2005 07:16:46 +0000 Subject: * file.c (file_load_ok): use eaccess() instead of actually opening the file. [ruby-talk:156378] * lib/jcode.rb (String::reverse): add new methods. [ruby-list:41245] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ file.c | 10 ++-------- lib/jcode.rb | 9 +++++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0fee90f0fb..d96d72ea9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Nov 15 16:15:23 2005 Yukihiro Matsumoto + + * file.c (file_load_ok): use eaccess() instead of actually opening + the file. [ruby-talk:156378] + + * lib/jcode.rb (String::reverse): add new methods. + [ruby-list:41245] + Tue Nov 15 15:49:34 2005 Hirokazu Yamamoto * array.c (rb_ary_fill): tail elements were vanished when the middle diff --git a/file.c b/file.c index 41f2c10550..d41c2f48ae 100644 --- a/file.c +++ b/file.c @@ -3954,15 +3954,9 @@ is_macos_native_path(const char *path) #endif static int -file_load_ok(const char *file) +file_load_ok(const char *path) { - FILE *f; - - if (!file) return 0; - f = fopen(file, "r"); - if (f == NULL) return 0; - fclose(f); - return 1; + return eaccess(path, R_OK); } extern VALUE rb_load_path; diff --git a/lib/jcode.rb b/lib/jcode.rb index 8cd770be26..ea90871572 100644 --- a/lib/jcode.rb +++ b/lib/jcode.rb @@ -188,6 +188,15 @@ class String (str = self.dup).tr_s!(from,to) or str end + def reverse + self.split(//).reverse.join + end + + def reverse! + self.replace(self.reverse) + self + end + def chop! self.gsub!(/(?:.|\r?\n)\z/, '') end -- cgit v1.2.3