ruby-changes:17044
From: akr <ko1@a...>
Date: Thu, 19 Aug 2010 10:13:23 +0900 (JST)
Subject: [ruby-changes:17044] Ruby:r29042 (trunk): * ext/pathname/pathname.c (path_extname): Pathname#extname translated
akr 2010-08-19 10:06:49 +0900 (Thu, 19 Aug 2010) New Revision: 29042 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29042 Log: * ext/pathname/pathname.c (path_extname): Pathname#extname translated from pathname.rb. Modified files: trunk/ChangeLog trunk/ext/pathname/lib/pathname.rb trunk/ext/pathname/pathname.c Index: ChangeLog =================================================================== --- ChangeLog (revision 29041) +++ ChangeLog (revision 29042) @@ -1,3 +1,8 @@ +Thu Aug 19 10:06:08 2010 Tanaka Akira <akr@f...> + + * ext/pathname/pathname.c (path_extname): Pathname#extname translated + from pathname.rb. + Thu Aug 19 06:03:27 2010 Nobuyoshi Nakada <nobu@r...> * vm_insnhelper.c (vm_push_frame): initialize block_iseq. a patch Index: ext/pathname/lib/pathname.rb =================================================================== --- ext/pathname/lib/pathname.rb (revision 29041) +++ ext/pathname/lib/pathname.rb (revision 29042) @@ -512,9 +512,6 @@ class Pathname # * File * - # See <tt>File.extname</tt>. Returns the file's extension. - def extname() File.extname(@path) end - # See <tt>File.expand_path</tt>. def expand_path(*args) self.class.new(File.expand_path(@path, *args)) end Index: ext/pathname/pathname.c =================================================================== --- ext/pathname/pathname.c (revision 29041) +++ ext/pathname/pathname.c (revision 29042) @@ -450,6 +450,16 @@ } /* + * See <tt>File.extname</tt>. 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 * * Pathname represents a pathname which locates a file in a filesystem. @@ -670,4 +680,5 @@ 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); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/