ruby-changes:16781
From: akr <ko1@a...>
Date: Wed, 28 Jul 2010 22:25:23 +0900 (JST)
Subject: [ruby-changes:16781] Ruby:r28776 (trunk): * ext/pathname/pathname.c (path_eq): Pathname#{==,===,eql?} translated
akr 2010-07-28 22:24:55 +0900 (Wed, 28 Jul 2010) New Revision: 28776 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28776 Log: * ext/pathname/pathname.c (path_eq): Pathname#{==,===,eql?} translated from pathname.rb. Modified files: trunk/ChangeLog trunk/ext/pathname/lib/pathname.rb trunk/ext/pathname/pathname.c Index: ChangeLog =================================================================== --- ChangeLog (revision 28775) +++ ChangeLog (revision 28776) @@ -1,3 +1,8 @@ +Wed Jul 28 22:23:59 2010 Tanaka Akira <akr@f...> + + * ext/pathname/pathname.c (path_eq): Pathname#{==,===,eql?} translated + from pathname.rb. + Wed Jul 28 19:37:33 2010 NAKAMURA Usaku <usa@r...> * win32/Makefile.sub (config.h): VC6 or later have stddef.h. Index: ext/pathname/lib/pathname.rb =================================================================== --- ext/pathname/lib/pathname.rb (revision 28775) +++ ext/pathname/lib/pathname.rb (revision 28776) @@ -208,18 +208,6 @@ # :startdoc: - # - # Compare this pathname with +other+. The comparison is string-based. - # Be aware that two different paths (<tt>foo.txt</tt> and <tt>./foo.txt</tt>) - # can refer to the same file. - # - def ==(other) - return false unless Pathname === other - other.to_s == @path - end - alias === == - alias eql? == - # Provides for comparing pathnames, case-sensitively. def <=>(other) return nil unless Pathname === other Index: ext/pathname/pathname.c =================================================================== --- ext/pathname/pathname.c (revision 28775) +++ ext/pathname/pathname.c (revision 28776) @@ -69,6 +69,19 @@ return self; } +/* + * Compare this pathname with +other+. The comparison is string-based. + * Be aware that two different paths (<tt>foo.txt</tt> and <tt>./foo.txt</tt>) + * can refer to the same file. + */ +static VALUE +path_eq(VALUE self, VALUE other) +{ + if (!rb_obj_is_kind_of(other, rb_cPathname)) + return Qfalse; + return rb_str_equal(get_strpath(self), get_strpath(other)); +} + void Init_pathname() { @@ -80,4 +93,7 @@ rb_define_method(rb_cPathname, "freeze", path_freeze, 0); rb_define_method(rb_cPathname, "taint", path_taint, 0); rb_define_method(rb_cPathname, "untaint", path_untaint, 0); + rb_define_method(rb_cPathname, "==", path_eq, 1); + rb_define_method(rb_cPathname, "===", path_eq, 1); + rb_define_method(rb_cPathname, "eql?", path_eq, 1); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/