summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-19 09:08:39 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-19 09:08:39 +0000
commitc03edd092ab6d67f5263406d26000bce0ce80dc5 (patch)
treeac55e2b19d8e2b7fd62adf65d138011f305cd910
parenta450d8c6d145bba59da2a550d38d35082c63066a (diff)
downloadruby-c03edd092ab6d67f5263406d26000bce0ce80dc5.tar.gz
ruby-c03edd092ab6d67f5263406d26000bce0ce80dc5.tar.xz
ruby-c03edd092ab6d67f5263406d26000bce0ce80dc5.zip
* lib/ipaddr.rb (to_s, test_to_s): too many colons with some cases.
(backported from CVS HEAD) git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--lib/ipaddr.rb6
2 files changed, 12 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e45e477c..48fdbc29d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
+Wed Jan 19 18:06:40 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * lib/ipaddr.rb (to_s, test_to_s): too many colons with some cases.
+ (backported from CVS HEAD)
+
Wed Jan 19 01:16:30 2005 Tanaka Akira <akr@m17n.org>
- * lib/resolv.rb (Resolv::DNS::Config.parse_resolv_conf): ignore
- domain and search directive without an argument.
+ * lib/resolv.rb (Resolv::DNS::Config.parse_resolv_conf): ignore
+ domain and search directive without an argument.
reported by Sam Roberts. [ruby-talk:126781]
Tue Jan 18 15:03:05 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index 24543ce09..c011676c1 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -207,6 +207,7 @@ class IPAddr
break if str.sub!(/\b0:0\b/, ':')
break
end
+ str.sub!(/:{3,}/, '::')
if /\A::(ffff:)?([\da-f]{1,4}):([\da-f]{1,4})\Z/i =~ str
str = sprintf('::%s%d.%d.%d.%d', $1, $2.hex / 256, $2.hex % 256, $3.hex / 256, $3.hex % 256)
@@ -602,7 +603,6 @@ class TC_IPAddr < Test::Unit::TestCase
IPAddr.new(*args)
}
}
- end
def test_s_new_ntoh
addr = ''
@@ -674,6 +674,10 @@ class TC_IPAddr < Test::Unit::TestCase
}
end
+ def test_to_s
+ assert_equal("3ffe:0505:0002:0000:0000:0000:0000:0001", IPAddr.new("3ffe:505:2::1").to_string)
+ assert_equal("3ffe:505:2::1", IPAddr.new("3ffe:505:2::1").to_s)
+ end
end
class TC_Operator < Test::Unit::TestCase