mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/pathname/pathname.c (path_eq): Pathname#{==,===,eql?} translated
from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4b8f2ed7cc
commit
7996581a82
3 changed files with 21 additions and 12 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Jul 28 22:23:59 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/pathname/pathname.c (path_eq): Pathname#{==,===,eql?} translated
|
||||||
|
from pathname.rb.
|
||||||
|
|
||||||
Wed Jul 28 19:37:33 2010 NAKAMURA Usaku <usa@ruby-lang.org>
|
Wed Jul 28 19:37:33 2010 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* win32/Makefile.sub (config.h): VC6 or later have stddef.h.
|
* win32/Makefile.sub (config.h): VC6 or later have stddef.h.
|
||||||
|
|
|
@ -208,18 +208,6 @@ class Pathname
|
||||||
|
|
||||||
# :startdoc:
|
# :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.
|
# Provides for comparing pathnames, case-sensitively.
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
return nil unless Pathname === other
|
return nil unless Pathname === other
|
||||||
|
|
|
@ -69,6 +69,19 @@ path_untaint(VALUE self)
|
||||||
return self;
|
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
|
void
|
||||||
Init_pathname()
|
Init_pathname()
|
||||||
{
|
{
|
||||||
|
@ -80,4 +93,7 @@ Init_pathname()
|
||||||
rb_define_method(rb_cPathname, "freeze", path_freeze, 0);
|
rb_define_method(rb_cPathname, "freeze", path_freeze, 0);
|
||||||
rb_define_method(rb_cPathname, "taint", path_taint, 0);
|
rb_define_method(rb_cPathname, "taint", path_taint, 0);
|
||||||
rb_define_method(rb_cPathname, "untaint", path_untaint, 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue