From dfe0aab04f7039660f4f567988accbf8ce0d6e7b Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 26 Sep 2003 09:35:44 +0000 Subject: [PATCH] * lib/resolv-replace.rb: 1.8 compliance. [ruby-talk:82946] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ defines.h | 2 +- lib/resolv-replace.rb | 31 ++++++++++++++++++++----------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index e89c6ecb4a..ed6e0c04c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Sep 26 18:35:40 2003 Nobuyoshi Nakada + + * lib/resolv-replace.rb: 1.8 compliance. [ruby-talk:82946] + Mon Sep 26 17:39:27 2003 NAKAMURA, Hiroshi * test/ruby/test_marshal.rb: add test for ruby's objects. diff --git a/defines.h b/defines.h index 2744b1650f..1cc659a8c6 100644 --- a/defines.h +++ b/defines.h @@ -144,7 +144,7 @@ flush_register_windows(void) volatile #endif # if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__) - ("flushw" : :) + ("flushw") # elif defined(linux) || defined(__linux__) ("ta 0x83") # else /* Solaris, OpenBSD, NetBSD, etc. */ diff --git a/lib/resolv-replace.rb b/lib/resolv-replace.rb index ad5c97bfdf..560a813d66 100644 --- a/lib/resolv-replace.rb +++ b/lib/resolv-replace.rb @@ -1,9 +1,10 @@ +require 'socket' require 'resolv' class BasicSocket alias original_resolv_send send def send(mesg, flags, *rest) - rest[0] = Resolv.getaddress(rest[0]).to_s if 0 < rest.length + rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty? original_resolv_send(mesg, flags, *rest) end end @@ -15,19 +16,20 @@ class << IPSocket end end -class << TCPSocket - alias original_resolv_new new - def new(host, service) - original_resolv_new(Resolv.getaddress(host).to_s, service) - end - - alias original_resolv_open open - def open(host, service) - original_resolv_open(Resolv.getaddress(host).to_s, service) +class TCPSocket + alias original_resolv_initialize initialize + def initialize(host, serv, *rest) + rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty? + original_resolv_initialize(Resolv.getaddress(host).to_s, serv, *rest) end end class UDPSocket + alias original_resolv_bind bind + def bind(host, port) + original_resolv_bind(Resolv.getaddress(host).to_s, port) + end + alias original_resolv_connect connect def connect(host, port) original_resolv_connect(Resolv.getaddress(host).to_s, port) @@ -35,7 +37,14 @@ class UDPSocket alias original_resolv_send send def send(mesg, flags, *rest) - rest[0] = Resolv.getaddress(rest[0]).to_s if 0 < rest.length + rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty? original_resolv_send(mesg, flags, *rest) end end + +class SOCKSSocket + alias original_resolv_initialize initialize + def initialize(host, serv) + original_resolv_initialize(Resolv.getaddress(host).to_s, port) + end +end if defined? SOCKSSocket