summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-08-24 08:21:56 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-08-24 08:21:56 +0000
commita1b57d0add85a248666fb55c58aa8c0c772136fc (patch)
tree3d30e530b29103ce2884dff782592ddf7292f4df /ext
parenta281c996689240dc204f0c534cfe21ee6cbb6863 (diff)
1.4.1 to be
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/dbm/extconf.rb10
-rw-r--r--ext/etc/extconf.rb2
-rw-r--r--ext/extmk.rb.in73
-rw-r--r--ext/gdbm/gdbm.c3
-rw-r--r--ext/pty/script.rb8
-rw-r--r--ext/socket/extconf.rb6
-rw-r--r--ext/tk/lib/tk.rb99
-rw-r--r--ext/tk/lib/tkcanvas.rb30
-rw-r--r--ext/tk/lib/tkentry.rb2
-rw-r--r--ext/tk/lib/tktext.rb65
10 files changed, 69 insertions, 229 deletions
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 22198910ccf..55dadc2601d 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -1,10 +1,12 @@
require 'mkmf'
+
dir_config("dbm")
-have_library("gdbm", "dbm_open") or
- have_library("db", "dbm_open") or
- have_library("dbm", "dbm_open")
+if have_library("gdbm", "dbm_open")
+ gdbm = true
+end
+gdbm or have_library("db", "dbm_open") or have_library("dbm", "dbm_open")
have_header("cdefs.h")
if have_header("ndbm.h") and have_func("dbm_open")
- have_func("dbm_clearerr")
+ have_func("dbm_clearerr") unless gdbm
create_makefile("dbm")
end
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index 4cf04a3ec36..6fe8810464e 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -25,7 +25,7 @@ if a or b or c
etc_grep_header("pw_quota")
etc_grep_header("pw_age")
etc_grep_header("pw_class")
- etc_grep_header("pw_comment")
+ etc_grep_header("pw_comment") unless /cygwin/ === RUBY_PLATFORM
etc_grep_header("pw_expire")
create_makefile("etc")
end
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index 66f5e9267c0..3e3ec3992e6 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -19,10 +19,6 @@ $extlist = []
$includedir = "@includedir@".gsub(/\$\{prefix\}|\$\(prefix\)/,'@prefix@')
-$cache_mod = false
-$lib_cache = {}
-$func_cache = {}
-$hdr_cache = {}
$top_srcdir = "@top_srcdir@"
if $top_srcdir !~ "^/"
# get absolute path
@@ -36,21 +32,6 @@ $:.push $top_srcdir+"/lib"
require 'find'
-if File.exist?("config.cache") then
- f = open("config.cache", "r")
- while f.gets
- case $_
- when /^lib: (.+) (yes|no)/
- $lib_cache[$1] = $2
- when /^func: ([\w_]+) (yes|no)/
- $func_cache[$1] = $2
- when /^hdr: (.+) (yes|no)/
- $hdr_cache[$1] = $2
- end
- end
- f.close
-end
-
def older(file1, file2)
if !File.exist?(file1) then
return true
@@ -175,15 +156,6 @@ def append_library(libs, lib)
end
def have_library(lib, func="main")
- if $lib_cache[lib]
- if $lib_cache[lib] == "yes"
- $libs = append_library($libs, lib)
- return true
- else
- return false
- end
- end
-
if func && func != ""
libs = append_library($libs, lib)
if /mswin32/ =~ RUBY_PLATFORM
@@ -208,8 +180,6 @@ int t() { #{func}(); return 0; }
SRC
end
unless r
- $lib_cache[lib] = 'no'
- $cache_mod = true
return false
end
else
@@ -217,8 +187,6 @@ SRC
end
$libs = libs
- $lib_cache[lib] = 'yes'
- $cache_mod = true
return true
end
@@ -240,15 +208,6 @@ SRC
end
def have_func(func)
- if $func_cache[func]
- if $func_cache[func] == "yes"
- $defs.push(format("-DHAVE_%s", func.upcase))
- return true
- else
- return false
- end
- end
-
libs = $libs
if /mswin32/ =~ RUBY_PLATFORM
@@ -273,38 +232,20 @@ int t() { #{func}(); return 0; }
SRC
end
unless r
- $func_cache[func] = 'no'
- $cache_mod = true
return false
end
$defs.push(format("-DHAVE_%s", func.upcase))
- $func_cache[func] = 'yes'
- $cache_mod = true
return true
end
def have_header(header)
- if $hdr_cache[header]
- if $hdr_cache[header] == "yes"
- header.tr!("a-z./\055", "A-Z___")
- $defs.push(format("-DHAVE_%s", header))
- return true
- else
- return false
- end
- end
-
unless try_cpp(<<"SRC")
#include <#{header}>
SRC
- $hdr_cache[header] = 'no'
- $cache_mod = true
return false
end
- $hdr_cache[header] = 'yes'
header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header))
- $cache_mod = true
return true
end
@@ -676,20 +617,6 @@ for d in Dir["#{$top_srcdir}/ext/*"]
extmake(d)
end
-if $cache_mod
- f = open("config.cache", "w")
- for k,v in $lib_cache
- f.printf "lib: %s %s\n", k, v
- end
- for k,v in $func_cache
- f.printf "func: %s %s\n", k, v
- end
- for k,v in $hdr_cache
- f.printf "hdr: %s %s\n", k, v
- end
- f.close
-end
-
if $install or $clean
Dir.chdir ".."
exit
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index a9c2c64ef6d..b38bb8ef486 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -334,9 +334,6 @@ fgdbm_store(obj, keystr, valstr)
dbmp->di_size = -1;
dbm = dbmp->di_dbm;
if (gdbm_store(dbm, key, val, GDBM_REPLACE)) {
-#ifdef HAVE_DBM_CLAERERR
- gdbm_clearerr(dbm);
-#endif
if (errno == EPERM) rb_sys_fail(0);
rb_raise(rb_eRuntimeError, "dbm_store failed");
}
diff --git a/ext/pty/script.rb b/ext/pty/script.rb
index 6aaafec0615..3084935637b 100644
--- a/ext/pty/script.rb
+++ b/ext/pty/script.rb
@@ -22,11 +22,11 @@ PTY.spawn("/bin/csh") do
begin
while true
- c = r_pty.getc
- next if c.nil?
- print c.chr
+ c = r_pty.sysread(512)
+ break if c.nil?
+ print c
STDOUT.flush
- logfile.print c.chr
+ logfile.print c
end
rescue
# print $@,':',$!,"\n"
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index da1a2a6b059..191abf09a6d 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -7,10 +7,10 @@ when /mswin32/
test_func = "WSACleanup"
have_library("wsock32", "WSACleanup")
when /cygwin/
- $LDFLAGS << " -L/usr/lib" if File.directory?("/usr/lib")
- $CFLAGS << " -I/usr/include"
+# $LDFLAGS << " -L/usr/lib" if File.directory?("/usr/lib")
+# $CFLAGS << " -I/usr/include"
test_func = "socket"
- have_library("bind", "gethostbyaddr")
+# have_library("bind", "gethostbyaddr")
when /beos/
test_func = "socket"
have_library("net", "socket")
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index 2b4b504b0a1..f831dbc78ae 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -8,6 +8,8 @@ require "tcltklib"
require "tkutil"
module TkComm
+ WidgetClassNames = {}
+
None = Object.new
def None.to_s
'None'
@@ -34,7 +36,7 @@ module TkComm
return path
end
- ruby_class = TkClassBind::WidgetClassNameTBL[tk_class]
+ ruby_class = WidgetClassNames[tk_class]
gen_class_name = ruby_class.name + 'GeneratedOnTk'
unless Object.const_defined? gen_class_name
eval "class #{gen_class_name}<#{ruby_class.name}
@@ -328,45 +330,36 @@ module TkComm
end
end
- def _bind_core(mode, path, context, cmd, args=nil)
- id = install_bind(cmd, args)
+ def _bind_core(mode, what, context, cmd, args=nil)
+ id = install_bind(cmd, args) if cmd
begin
- tk_call 'bind', path, "<#{tk_event_sequence(context)}>", mode + id
+ tk_call(*(what + ["<#{tk_event_sequence(context)}>", mode + id]))
rescue
- uninstall_cmd(id)
+ uninstall_cmd(id) if cmd
fail
end
end
- def _bind(path, context, cmd, args=nil)
- _bind_core('', path, context, cmd, args)
+ def _bind(what, context, cmd, args=nil)
+ _bind_core('', what, context, cmd, args)
end
- def _bind_append(path, context, cmd, args=nil)
- _bind_core('+', path, context, cmd, args)
+ def _bind_append(what, context, cmd, args=nil)
+ _bind_core('+', what, context, cmd, args)
end
private :install_bind, :tk_event_sequence, :_bind_core, :_bind, :_bind_append
def bind_all(context, cmd=Proc.new, args=nil)
- _bind 'all', context, cmd, args
+ _bind(['bind', 'all'], context, cmd, args)
end
def bind_append_all(context, cmd=Proc.new, args=nil)
- _bind_append 'all', context, cmd, args
- end
-
- def bind(tagOrClass, context, cmd=Proc.new, args=nil)
- _bind tagOrClass, context, cmd, args
- end
-
- def bind_append(tagOrClass, context, cmd=Proc.new, args=nil)
- _bind_append tagOrClass, context, cmd, args
+ _bind_append(['bind', 'all'], context, cmd, args)
end
- def _bindinfo(tagOrClass, context=nil)
+ def _bindinfo(what, context=nil)
if context
- (tk_call('bind', tagOrClass,
- "<#{tk_event_sequence(context)}>")).collect{|cmdline|
+ tk_call(*what+["<#{tk_event_sequence(context)}>"]).collect {|cmdline|
if cmdline =~ /^rb_out (c\d+)\s+(.*)$/
[Tk_CMDTBL[$1], $2]
else
@@ -374,14 +367,14 @@ module TkComm
end
}
else
- tk_split_list(tk_call 'bind', tagOrClass).collect{|seq|
+ tk_split_list(tk_call(*what)).collect{|seq|
seq[1..-2].gsub(/></,',')
}
end
end
def bindinfo(tagOrClass, context=nil)
- _bindinfo tagOrClass, context
+ _bindinfo(['bind', tagOrClass], context)
end
def pack(*args)
@@ -971,7 +964,7 @@ class TkVarAccess<TkVariable
def initialize(varname, val=nil)
@id = varname
if val
- s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"'
+ s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"' #"
INTERP._eval(format('global %s; set %s %s', @id, @id, s))
end
end
@@ -1648,15 +1641,15 @@ class TkObject<TkKernel
end
def bind(context, cmd=Proc.new, args=nil)
- _bind path, context, cmd, args
+ _bind(["bind", to_eval], context, cmd, args)
end
def bind_append(context, cmd=Proc.new, args=nil)
- _bind_append path, context, cmd, args
+ _bind_append(["bind", to_eval], context, cmd, args)
end
def bindinfo(context=nil)
- _bindinfo path, context
+ _bindinfo(['bind', to_eval], context)
end
def event_generate(context, keys=nil)
@@ -1681,28 +1674,8 @@ class TkObject<TkKernel
end
end
-module TkClassBind
- WidgetClassNameTBL = {}
-
- def TkClassBind.name2class(name)
- WidgetClassNameTBL[name]
- end
-
- def bind(context, cmd=Proc.new, args=nil)
- Tk.bind to_eval, context, cmd, args
- end
-
- def bind_append(context, cmd=Proc.new, args=nil)
- Tk.bind_append to_eval, context, cmd, args
- end
-
- def bindinfo(context=nil)
- Tk.bindinfo to_eval, context
- end
-end
-
class TkWindow<TkObject
- extend TkClassBind
+# extend TkClassBind
def initialize(parent=nil, keys=nil)
install_win(if parent then parent.path end)
@@ -1853,7 +1826,7 @@ class TkWindow<TkObject
tk_split_list(tk_call('bindtags', path)).collect{|tag|
if tag == nil
'.'
- elsif tag.kind_of?(String) && (cls = TkClassBind.name2class(tag))
+ elsif tag.kind_of?(String) && (cls = WidgetClassNames[tag])
cls
else
tag
@@ -1874,7 +1847,7 @@ class TkRoot<TkWindow
end
WidgetClassName = 'Tk'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ WidgetClassNames[WidgetClassName] = self
def self.to_eval
WidgetClassName
end
@@ -1891,7 +1864,7 @@ class TkToplevel<TkWindow
include Wm
WidgetClassName = 'Toplevel'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ WidgetClassNames[WidgetClassName] = self
def self.to_eval
WidgetClassName
end
@@ -1951,7 +1924,7 @@ end
class TkFrame<TkWindow
WidgetClassName = 'Frame'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ WidgetClassNames[WidgetClassName] = self
def self.to_eval
WidgetClassName
end
@@ -1991,7 +1964,7 @@ end
class TkLabel<TkWindow
WidgetClassName = 'Label'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ WidgetClassNames[WidgetClassName] = self
def self.to_eval
WidgetClassName
end
@@ -2004,7 +1977,7 @@ class TkLabel<TkWindow
end
class TkButton<TkLabel
- TkClassBind::WidgetClassNameTBL['Button'] = self
+ WidgetClassNames['Button'] = self
def TkButton.to_eval
'Button'
end
@@ -2020,7 +1993,7 @@ class TkButton<TkLabel
end
class TkRadioButton<TkButton
- TkClassBind::WidgetClassNameTBL['Radiobutton'] = self
+ WidgetClassNames['Radiobutton'] = self
def TkRadioButton.to_eval
'Radiobutton'
end
@@ -2039,7 +2012,7 @@ class TkRadioButton<TkButton
end
class TkCheckButton<TkRadioButton
- TkClassBind::WidgetClassNameTBL['Checkbutton'] = self
+ WidgetClassNames['Checkbutton'] = self
def TkCheckButton.to_eval
'Checkbutton'
end
@@ -2052,7 +2025,7 @@ class TkCheckButton<TkRadioButton
end
class TkMessage<TkLabel
- TkClassBind::WidgetClassNameTBL['Message'] = self
+ WidgetClassNames['Message'] = self
def TkMessage.to_eval
'Message'
end
@@ -2063,7 +2036,7 @@ end
class TkScale<TkWindow
WidgetClassName = 'Scale'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ WidgetClassNames[WidgetClassName] = self
def self.to_eval
WidgetClassName
end
@@ -2091,7 +2064,7 @@ end
class TkScrollbar<TkWindow
WidgetClassName = 'Scrollbar'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ WidgetClassNames[WidgetClassName] = self
def self.to_eval
WidgetClassName
end
@@ -2158,7 +2131,7 @@ class TkTextWin<TkWindow
end
class TkListbox<TkTextWin
- TkClassBind::WidgetClassNameTBL['Listbox'] = self
+ WidgetClassNames['Listbox'] = self
def TkListbox.to_eval
'Listbox'
end
@@ -2315,7 +2288,7 @@ class TkMenu<TkWindow
include TkTreatMenuEntryFont
WidgetClassName = 'Menu'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ WidgetClassNames[WidgetClassName] = self
def self.to_eval
WidgetClassName
end
@@ -2395,7 +2368,7 @@ class TkMenu<TkWindow
end
class TkMenubutton<TkLabel
- TkClassBind::WidgetClassNameTBL['Menubutton'] = self
+ WidgetClassNames['Menubutton'] = self
def TkMenubutton.to_eval
'Menubutton'
end
diff --git a/ext/tk/lib/tkcanvas.rb b/ext/tk/lib/tkcanvas.rb
index 1cf24eeb7b5..40bfa548465 100644
--- a/ext/tk/lib/tkcanvas.rb
+++ b/ext/tk/lib/tkcanvas.rb
@@ -131,7 +131,7 @@ class TkCanvas<TkWindow
include TkTreatCItemFont
WidgetClassName = 'Canvas'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ WidgetClassNames[WidgetClassName] = self
def self.to_eval
WidgetClassName
end
@@ -179,31 +179,15 @@ class TkCanvas<TkWindow
end
def itembind(tag, context, cmd=Proc.new, args=nil)
- id = install_bind(cmd, args)
- begin
- tk_send 'bind', tagid(tag), "<#{tk_event_sequence(context)}>", id
- rescue
- uninstall_cmd(cmd)
- fail
- end
- # @cmdtbl.push id
+ _bind([path, "bind", tagid(tag)], context, cmd, args)
+ end
+
+ def itembind_append(tag, context, cmd=Proc.new, args=nil)
+ _bind_append([path, "bind", tagid(tag)], context, cmd, args)
end
def itembindinfo(tag, context=nil)
- if context
- (tk_send('bind', tagid(tag),
- "<#{tk_event_sequence(context)}>")).collect{|cmdline|
- if cmdline =~ /^rb_out (c\d+)\s+(.*)$/
- [Tk_CMDTBL[$1], $2]
- else
- cmdline
- end
- }
- else
- tk_split_list(tk_send 'bind', tagid(tag)).filter{|seq|
- seq[1..-2].gsub(/></,',')
- }
- end
+ _bindinfo([path, "bind", tagid(tag)], context)
end
def canvasx(x, *args)
diff --git a/ext/tk/lib/tkentry.rb b/ext/tk/lib/tkentry.rb
index b834c455c6c..5822c00e537 100644
--- a/ext/tk/lib/tkentry.rb
+++ b/ext/tk/lib/tkentry.rb
@@ -7,7 +7,7 @@ require 'tk.rb'
class TkEntry<TkLabel
WidgetClassName = 'Entry'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ WidgetClassNames[WidgetClassName] = self
def self.to_eval
WidgetClassName
end
diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb
index 324af90f85c..83999cb3e24 100644
--- a/ext/tk/lib/tktext.rb
+++ b/ext/tk/lib/tktext.rb
@@ -129,7 +129,7 @@ class TkText<TkTextWin
include TkTreatTextTagFont
WidgetClassName = 'Text'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ WidgetClassNames[WidgetClassName] = self
def self.to_eval
WidgetClassName
end
@@ -235,40 +235,20 @@ class TkText<TkTextWin
tk_send 'xview', '-pickplace', *what
end
- def tag_add(tag,index1,index2=None)
+ def tag_add(tag, index1, index2=None)
tk_send 'tag', 'add', tag, index1, index2
end
- def _tag_bind_core(mode, tag, seq, cmd=Proc.new, args=nil)
- id = install_bind(cmd, args)
- tk_send 'tag', 'bind', tag, "<#{tk_event_sequence(seq)}>", mode + id
- # _addcmd cmd
- end
- private :_tag_bind_core
-
def tag_bind(tag, seq, cmd=Proc.new, args=nil)
- _tag_bind_core('', tag, seq, cmd, args=nil)
+ _bind(['tag', 'bind', tag], seq, cmd, args)
end
def tag_bind_append(tag, seq, cmd=Proc.new, args=nil)
- _tag_bind_core('+', tag, seq, cmd, args=nil)
+ _bind_append(['tag', 'bind', tag], seq, cmd, args)
end
def tag_bindinfo(tag, context=nil)
- if context
- (tk_send('tag', 'bind', tag,
- "<#{tk_event_sequence(context)}>")).collect{|cmdline|
- if cmdline =~ /^rb_out (c\d+)\s+(.*)$/
- [Tk_CMDTBL[$1], $2]
- else
- cmdline
- end
- }
- else
- tk_split_list(tk_send('tag', 'bind', tag)).filter{|seq|
- seq[1..-2].gsub(/></,',')
- }
- end
+ _bindinfo(['tag', 'bind', tag], context)
end
def tag_cget(tag, key)
@@ -521,40 +501,17 @@ class TkTextTag<TkObject
def configinfo(key=nil)
@t.tag_configinfo @id, key
end
-# def configinfo(key=nil)
-# if key
-# conf = tk_split_list(tk_call(@t.path, 'tag','configure',@id,"-#{key}"))
-# conf[0] = conf[0][1..-1]
-# conf
-# else
-# tk_split_list(tk_call(@t.path, 'tag', 'configure', @id)).collect{|conf|
-# conf[0] = conf[0][1..-1]
-# conf
-# }
-# end
-# end
def bind(seq, cmd=Proc.new, args=nil)
- id = install_bind(cmd, args)
- tk_call @t.path, 'tag', 'bind', @id, "<#{tk_event_sequence(seq)}>", id
- # @t._addcmd cmd
+ _bind([@t.path, 'tag', 'bind', @id], seq, cmd, args)
+ end
+
+ def bind_append(seq, cmd=Proc.new, args=nil)
+ _bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args)
end
def bindinfo(context=nil)
- if context
- (tk_call(@t.path, 'tag', 'bind', @id,
- "<#{tk_event_sequence(context)}>")).collect{|cmdline|
- if cmdline =~ /^rb_out (c\d+)\s+(.*)$/
- [Tk_CMDTBL[$1], $2]
- else
- cmdline
- end
- }
- else
- tk_split_list(tk_call(@t.path, 'tag', 'bind', @id)).filter{|seq|
- seq[1..-2].gsub(/></,',')
- }
- end
+ _bindinfo([@t.path, 'tag', 'bind', @id], context)
end
def raise(above=None)