diff --git a/ChangeLog b/ChangeLog index faeccaef17..cf98d7db3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Aug 19 10:06:08 2010 Tanaka Akira + + * ext/pathname/pathname.c (path_extname): Pathname#extname translated + from pathname.rb. + Thu Aug 19 06:03:27 2010 Nobuyoshi Nakada * vm_insnhelper.c (vm_push_frame): initialize block_iseq. a patch diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index 487402c21b..54b06eefbc 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -512,9 +512,6 @@ end class Pathname # * File * - # See File.extname. Returns the file's extension. - def extname() File.extname(@path) end - # See File.expand_path. def expand_path(*args) self.class.new(File.expand_path(@path, *args)) end diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index e548ac56f5..834fa446da 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -449,6 +449,16 @@ path_dirname(VALUE self) return rb_class_new_instance(1, &str, rb_obj_class(self)); } +/* + * See File.extname. Returns the file's extension. + */ +static VALUE +path_extname(VALUE self) +{ + VALUE str = get_strpath(self); + return rb_funcall(rb_cFile, rb_intern("extname"), 1, str); +} + /* * == Pathname * @@ -670,4 +680,5 @@ Init_pathname() rb_define_method(rb_cPathname, "utime", path_utime, 2); rb_define_method(rb_cPathname, "basename", path_basename, -1); rb_define_method(rb_cPathname, "dirname", path_dirname, 0); + rb_define_method(rb_cPathname, "extname", path_extname, 0); }