diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-02-01 03:12:21 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-02-01 03:12:21 +0000 |
commit | e4b53b22228d935847b72e8f9ab0f49a15b54215 (patch) | |
tree | ae6cd78921bf626d54145b5485474bf59c3dceb4 /ext | |
parent | 005f12582975d8382851b740690f97dba35aaa2a (diff) |
2000-02-01
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/socket/extconf.rb | 21 | ||||
-rw-r--r-- | ext/socket/socket.c | 25 | ||||
-rw-r--r-- | ext/tcltklib/tcltklib.c | 6 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 62 | ||||
-rw-r--r-- | ext/tk/lib/tkentry.rb | 8 |
5 files changed, 90 insertions, 32 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 6975994ef8..b7aee1cc36 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -41,6 +41,7 @@ end $ipv6type = nil $ipv6lib = nil $ipv6libdir = nil +$ipv6trylibc = nil if $ipv6 if egrep_cpp("yes", <<EOF) #include <netinet/in.h> @@ -59,6 +60,7 @@ EOF $ipv6type = "kame" $ipv6lib="inet6" $ipv6libdir="/usr/local/v6/lib" + $ipv6trylibc=true $CFLAGS="-DINET6 "+$CFLAGS elsif File.directory? "/usr/inet6" $ipv6type = "linux" @@ -100,7 +102,7 @@ EOF if $ipv6lib if File.directory? $ipv6libdir and File.exist? "#{$ipv6libdir}/lib#{$ipv6lib}.a" $LOCAL_LIBS = " -L#$ipv6libdir -l#$ipv6lib" - else + elsif !$ipv6trylibc print <<EOS Fatal: no #$ipv6lib library found. cannot continue. @@ -135,6 +137,23 @@ end #include <netdb.h> #include <string.h> #include <sys/socket.h> +int +main() +{ + struct sockaddr_storage ss; + + ss.ss_family; + return 0; +} +EOF + $CFLAGS="-DHAVE_SOCKADDR_STORAGE "+$CFLAGS +end + + if try_link(<<EOF) +#include <sys/types.h> +#include <netdb.h> +#include <string.h> +#include <sys/socket.h> #include <netinet/in.h> int main() diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 37094026e4..d680adc325 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -81,10 +81,27 @@ int Rconnect(); #define INET_SERVER 1 #define INET_SOCKS 2 -#ifndef INET6 -# undef ss_family -# define sockaddr_storage sockaddr -# define ss_family sa_family +#ifndef HAVE_SOCKADDR_STORAGE +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128 +#define _SS_ALIGNSIZE (sizeof(long long)) +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2) +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \ + _SS_PAD1SIZE - _SS_ALIGNSIZE) + +struct sockaddr_storage { +#ifdef HAVE_SA_LEN + unsigned char ss_len; /* address length */ + unsigned char ss_family; /* address family */ +#else + unsigned short ss_family; +#endif + char __ss_pad1[_SS_PAD1SIZE]; + long long __ss_align; /* force desired structure storage alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; #endif #ifdef NT diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c index 314246869e..e846e1f038 100644 --- a/ext/tcltklib/tcltklib.c +++ b/ext/tcltklib/tcltklib.c @@ -69,8 +69,7 @@ _timer_for_tcl(clientData) VALUE thread; Tk_DeleteTimerHandler(timer_token); - timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl, - (ClientData)0); + timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl, (ClientData)0); CHECK_INTS; q = iqueue; @@ -93,8 +92,7 @@ static VALUE lib_mainloop(self) VALUE self; { - timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl, - (ClientData)0); + timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl, (ClientData)0); DUMP1("start Tk_Mainloop"); Tk_MainLoop(); DUMP1("stop Tk_Mainloop"); diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 931cb90819..c344a2bf8e 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -196,7 +196,9 @@ module TkComm def _get_eval_string(str) return nil if str == None - if str.kind_of?(Hash) + if str.kind_of?(String) + # do nothing + elsif str.kind_of?(Hash) str = hash_kv(str).join(" ") elsif str.kind_of?(Array) str = array2tk_list(str) @@ -417,11 +419,11 @@ module TkCore INTERP._invoke("proc", "rb_out", "args", "if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $args]} ret]] != 0} {if {[regsub -all {!} $args {\\!} newargs] == 0} {return -code $st $ret} {if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $newargs]} ret]] != 0} {return -code $st $ret} {return $ret}}} {return $ret}") def callback_break - raise TkCallbackBreak, "Tk callback returns 'break' status" + fail TkCallbackBreak, "Tk callback returns 'break' status" end def callback_continue - raise TkCallbackContinue, "Tk callback returns 'continue' status" + fail TkCallbackContinue, "Tk callback returns 'continue' status" end def after(ms, cmd=Proc.new) @@ -527,8 +529,8 @@ module TkCore args.unshift "unknown" res = INTERP._invoke(*args) rescue - raise unless /^invalid command/ =~ $! - raise err + fail unless /^invalid command/ =~ $! + fail err end end if INTERP._return_value() != 0 @@ -583,6 +585,32 @@ module Tk def yscrollcommand(cmd=Proc.new) configure_cmd 'yscrollcommand', cmd end + def xview(*index) + v = tk_send('xview', *index) + list(v) if index.size == 0 + end + def yview(*index) + v = tk_send('yview', *index) + list(v) if index.size == 0 + end + def xscrollbar(bar=nil) + if bar + @xscrollbar = bar + @xscrollbar.orient 'horizontal' + self.xscrollcommand {|arg| @xscrollbar.set *arg} + @xscrollbar.command {|arg| self.xview *arg} + end + @xscrollbar + end + def yscrollbar(bar=nil) + if bar + @yscrollbar = bar + @yscrollbar.orient 'vertical' + self.yscrollcommand {|arg| @yscrollbar.set *arg} + @yscrollbar.command {|arg| self.yview *arg} + end + @yscrollbar + end end module Wm @@ -784,7 +812,7 @@ class TkVariable INTERP._eval(format('global %s; set %s', @id, @id)) rescue if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1" - raise + fail else Hash[*tk_split_simplelist(INTERP._eval(format('global %s; array get %s', @id, @id)))] @@ -798,7 +826,7 @@ class TkVariable INTERP._eval(format('global %s; set %s %s', @id, @id, s)) rescue if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1" - raise + fail else if val == [] INTERP._eval(format('global %s; unset %s; set %s(0) 0; unset %s(0)', @@ -815,7 +843,7 @@ class TkVariable INTERP._eval(format('global %s; unset %s; array set %s %s', @id, @id, @id, s)) else - raise + fail end end end @@ -2149,7 +2177,7 @@ end class TkTextWin<TkWindow def create_self - raise TypeError, "TkTextWin is abstract class" + fail TypeError, "TkTextWin is abstract class" end def bbox(index) @@ -2195,6 +2223,14 @@ class TkListbox<TkTextWin def curselection list(tk_send('curselection')) end + def get(*index) + v = tk_send('get', *index) + if index.size == 1 + v + else + tk_split_simplelist(v) + end + end def nearest(y) tk_send('nearest', y).to_i end @@ -2213,14 +2249,6 @@ class TkListbox<TkTextWin def selection_set(first, last=None) tk_send 'selection', 'set', first, last end - def xview(cmd, *more) - v = tk_send('xview', cmd, *more) - v.to_i if more.size == 0 - end - def yview(cmd, *more) - v = tk_send('yview', cmd, *more) - v.to_i if more.size == 0 - end end module TkTreatMenuEntryFont diff --git a/ext/tk/lib/tkentry.rb b/ext/tk/lib/tkentry.rb index 90d5fe3b43..f35d2eef00 100644 --- a/ext/tk/lib/tkentry.rb +++ b/ext/tk/lib/tkentry.rb @@ -6,6 +6,8 @@ require 'tk.rb' class TkEntry<TkLabel + include Scrollable + WidgetClassName = 'Entry'.freeze WidgetClassNames[WidgetClassName] = self def self.to_eval @@ -15,9 +17,6 @@ class TkEntry<TkLabel def create_self tk_call 'entry', @path end - def xscrollcommand(cmd=Proc.new) - configure_cmd 'xscrollcommand', cmd - end def delete(s, e=None) tk_send 'delete', s, e @@ -59,9 +58,6 @@ class TkEntry<TkLabel def selection_to(index) tk_send 'selection', 'to', index end - def xview(*index) - tk_send 'xview', *index - end def value tk_send 'get' |