* lib/pathname.rb (Pathname#+): return the argument if self is `.'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2003-11-07 02:08:04 +00:00
parent e7688cebe5
commit dc592364e6
2 changed files with 8 additions and 2 deletions

View File

@ -1,3 +1,7 @@
Fri Nov 7 11:06:57 2003 Tanaka Akira <akr@m17n.org>
* lib/pathname.rb (Pathname#+): return the argument if self is `.'.
Fri Nov 7 10:23:24 2003 Nobuyoshi Nakada <nobu@ruby-lang.org> Fri Nov 7 10:23:24 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/socket/socket.c (make_hostent): get rid of SEGV on aliases * ext/socket/socket.c (make_hostent): get rid of SEGV on aliases

View File

@ -213,10 +213,12 @@ class Pathname
# Pathname#+ return new pathname which is concatenated with self and # Pathname#+ return new pathname which is concatenated with self and
# an argument. # an argument.
# If the argument is absolute pathname, it is just returned. # If self is the current working directory `.' or
# the argument is absolute pathname,
# the argument is just returned.
def +(other) def +(other)
other = Pathname.new(other) unless Pathname === other other = Pathname.new(other) unless Pathname === other
if other.absolute? if @path == '.' || other.absolute?
other other
elsif %r{/\z} =~ @path elsif %r{/\z} =~ @path
Pathname.new(@path + other.to_s) Pathname.new(@path + other.to_s)