summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-01-17 08:24:22 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-01-17 08:24:22 +0000
commit3b992de6c0c96f0dcf8931c1f0baa561f9b9538a (patch)
treeffe44e7d3725919c2d14e3addcf98eaea957710b
parent037b710e18fe1101428ef235ec80b831c1e0d081 (diff)
2000-01-17
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog17
-rw-r--r--array.c2
-rw-r--r--class.c2
-rw-r--r--compar.c2
-rw-r--r--dir.c2
-rw-r--r--dln.c2
-rw-r--r--enum.c2
-rw-r--r--error.c2
-rw-r--r--eval.c7
-rw-r--r--ext/dbm/extconf.rb7
-rw-r--r--ext/tk/lib/tk.rb196
-rw-r--r--ext/tk/lib/tkcanvas.rb18
-rw-r--r--ext/tk/lib/tktext.rb53
-rw-r--r--file.c7
-rw-r--r--gc.c2
-rw-r--r--hash.c2
-rw-r--r--inits.c2
-rw-r--r--io.c7
-rw-r--r--lib/complex.rb32
-rw-r--r--lib/parsedate.rb2
-rw-r--r--lib/timeout.rb2
-rw-r--r--math.c2
-rw-r--r--missing/isnan.c13
-rw-r--r--node.h2
-rw-r--r--numeric.c2
-rw-r--r--object.c2
-rw-r--r--pack.c2
-rw-r--r--parse.y7
-rw-r--r--prec.c2
-rw-r--r--process.c2
-rw-r--r--random.c50
-rw-r--r--range.c2
-rw-r--r--re.c2
-rw-r--r--re.h2
-rw-r--r--ruby.c2
-rw-r--r--ruby.h2
-rw-r--r--rubyio.h2
-rw-r--r--sprintf.c2
-rw-r--r--string.c4
-rw-r--r--time.c2
-rw-r--r--util.c2
-rw-r--r--util.h2
-rw-r--r--version.c4
-rw-r--r--version.h4
-rw-r--r--win32/win32.c62
45 files changed, 357 insertions, 189 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a6d800d38..0944f96644 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Sat Jan 15 22:21:08 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (search_method): argument klass may be 0.
+
+Fri Jan 14 12:22:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_replace): use memmove instead of memcpy for
+ overwrapping strings (e.g. a[1] = a).
+
+Fri Jan 7 00:59:29 2000 Masahiro Tomita <tommy@tmtm.org>
+
+ * io.c (io_fread): TRAP_BEG/TRAP_END added around getc().
+
Wed Jan 5 02:14:46 2000 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* parse.y: Fix SEGV on empty parens with UMINUS or UPLUS.
@@ -44,6 +57,10 @@ Tue Dec 21 17:21:28 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
* ext/socket/socket.c (sock_finalize): mswin32: fix FILE* leak.
+Mon Dec 20 19:08:12 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (rb_file_s_expand_path): handle dir separetor correctly.
+
Sun Dec 19 22:56:31 1999 KANEKO Naoshi <wbs01621@mail.wbs.ne.jp>
* lib/find.rb: support dosish root directory.
diff --git a/array.c b/array.c
index f3bd553872..633e261dcc 100644
--- a/array.c
+++ b/array.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Aug 6 09:46:12 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/class.c b/class.c
index 32dc0e1372..a8a20b14fa 100644
--- a/class.c
+++ b/class.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Aug 10 15:05:44 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/compar.c b/compar.c
index 677b6a3cbd..6046a70ce3 100644
--- a/compar.c
+++ b/compar.c
@@ -6,7 +6,7 @@
$Date$
created at: Thu Aug 26 14:39:48 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/dir.c b/dir.c
index a771534155..780f269134 100644
--- a/dir.c
+++ b/dir.c
@@ -6,7 +6,7 @@
$Date$
created at: Wed Jan 5 09:51:01 JST 1994
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/dln.c b/dln.c
index 02ef484b36..a30c7c1251 100644
--- a/dln.c
+++ b/dln.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Jan 18 17:05:06 JST 1994
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/enum.c b/enum.c
index 2825855d53..3ad7e107e2 100644
--- a/enum.c
+++ b/enum.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Oct 1 15:15:19 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/error.c b/error.c
index ec66ba1b9a..f528eccacd 100644
--- a/error.c
+++ b/error.c
@@ -6,7 +6,7 @@
$Date$
created at: Mon Aug 9 16:11:34 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/eval.c b/eval.c
index 0962fc9723..3a684b484c 100644
--- a/eval.c
+++ b/eval.c
@@ -6,7 +6,7 @@
$Date$
created at: Thu Jun 10 14:22:17 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
@@ -147,6 +147,7 @@ search_method(klass, id, origin)
{
NODE *body;
+ if (!klass) return 0;
while (!st_lookup(RCLASS(klass)->m_tbl, id, &body)) {
klass = RCLASS(klass)->super;
if (!klass) return 0;
@@ -1704,6 +1705,7 @@ call_trace_func(event, file, line, self, id, klass)
struct FRAME *prev;
char *file_save = ruby_sourcefile;
int line_save = ruby_sourceline;
+ VALUE srcfile;
if (!trace_func) return;
@@ -1727,8 +1729,9 @@ call_trace_func(event, file, line, self, id, klass)
}
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
+ srcfile = rb_str_new2(ruby_sourcefile?ruby_sourcefile:"(ruby)");
proc_call(trace, rb_ary_new3(6, rb_str_new2(event),
- rb_str_new2(ruby_sourcefile),
+ srcfile,
INT2FIX(ruby_sourceline),
INT2FIX(id),
self?rb_f_binding(self):Qnil,
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 55dadc2601..f47287c03e 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -1,9 +1,10 @@
require 'mkmf'
dir_config("dbm")
-if have_library("gdbm", "dbm_open")
- gdbm = true
-end
+#if have_library("gdbm", "dbm_open")
+# gdbm = true
+#end
+ gdbm = false
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")
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index fd0a3bb2e4..931cb90819 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -235,7 +235,7 @@ module TkComm
return format("rb_out %s", id);
end
def uninstall_cmd(id)
- id = $1 if /rb_out (c\d+)/
+ id = $1 if /rb_out (c\d+)/ =~ id
Tk_CMDTBL[id] = nil
end
private :install_cmd, :uninstall_cmd
@@ -347,15 +347,6 @@ module TkComm
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(['bind', 'all'], context, cmd, args)
- end
-
- def bind_append_all(context, cmd=Proc.new, args=nil)
- _bind_append(['bind', 'all'], context, cmd, args)
- end
def _bindinfo(what, context=nil)
if context
@@ -372,11 +363,33 @@ module TkComm
}
end
end
+ private :install_bind, :tk_event_sequence,
+ :_bind_core, :_bind, :_bind_append, :_bindinfo
+
+ def bind(tagOrClass, context, cmd=Proc.new, args=nil)
+ _bind(["bind", tagOrClass], context, cmd, args)
+ end
+
+ def bind_append(tagOrClass, context, cmd=Proc.new, args=nil)
+ _bind_append(["bind", tagOrClass], context, cmd, args)
+ end
def bindinfo(tagOrClass, context=nil)
_bindinfo(['bind', tagOrClass], context)
end
+ def bind_all(context, cmd=Proc.new, args=nil)
+ _bind(['bind', 'all'], context, cmd, args)
+ end
+
+ def bind_append_all(context, cmd=Proc.new, args=nil)
+ _bind_append(['bind', 'all'], context, cmd, args)
+ end
+
+ def bindinfo_all(context=nil)
+ _bindinfo(['bind', 'all'], context)
+ end
+
def pack(*args)
TkPack.configure *args
end
@@ -401,7 +414,7 @@ module TkCore
INTERP = TclTkIp.new
- INTERP._invoke("proc", "rb_out", "args", "if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $args]} ret]] != 0} {return -code $st $ret} {return $ret}")
+ 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"
@@ -575,8 +588,8 @@ module Tk
module Wm
include TkComm
def aspect(*args)
- w = window(tk_call('wm', 'grid', path, *args))
- w.split.collect{|s|s.to_i} if args.length == 0
+ w = tk_call('wm', 'aspect', path, *args)
+ list(w) if args.length == 0
end
def client(name=None)
tk_call 'wm', 'client', path, name
@@ -594,17 +607,18 @@ module Tk
tk_call 'wm', 'focusmodel', path, *args
end
def frame
- tk_call 'wm', 'frame', path
+ tk_call('wm', 'frame', path)
end
def geometry(*args)
- list(tk_call('wm', 'geometry', path, *args))
+ tk_call('wm', 'geometry', path, *args)
end
def grid(*args)
w = tk_call('wm', 'grid', path, *args)
list(w) if args.size == 0
end
def group(*args)
- tk_call 'wm', 'group', path, *args
+ w = tk_call 'wm', 'group', path, *args
+ window(w) if args.size == 0
end
def iconbitmap(*args)
tk_call 'wm', 'iconbitmap', path, *args
@@ -628,7 +642,7 @@ module Tk
end
def maxsize(*args)
w = tk_call('wm', 'maxsize', path, *args)
- list(w) if not args.size == 0
+ list(w) if args.size == 0
end
def minsize(*args)
w = tk_call('wm', 'minsize', path, *args)
@@ -661,7 +675,7 @@ module Tk
end
end
def sizefrom(*args)
- list(tk_call('wm', 'sizefrom', path, *args))
+ tk_call('wm', 'sizefrom', path, *args)
end
def state
tk_call 'wm', 'state', path
@@ -670,7 +684,7 @@ module Tk
tk_call 'wm', 'title', path, *args
end
def transient(*args)
- tk_call 'wm', 'transient', path, *args
+ window(tk_call 'wm', 'transient', path, *args)
end
def withdraw
tk_call 'wm', 'withdraw', path
@@ -678,6 +692,46 @@ module Tk
end
end
+module TkBindCore
+ 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 TkBindTag
+ include TkBindCore
+
+ BTagID_TBL = {}
+ Tk_BINDTAG_ID = ["btag00000"]
+
+ def TkBindTag.id2obj(id)
+ BTagID_TBL[id]? BTagID_TBL[id]: id
+ end
+
+ def initialize(*args)
+ @id = Tk_BINDTAG_ID[0]
+ Tk_BINDTAG_ID[0] = Tk_BINDTAG_ID[0].succ
+ BTagID_TBL[@id] = self
+ bind(*args) if args != []
+ end
+
+ def to_eval
+ @id
+ end
+
+ def inspect
+ format "#<TkBindTag: %s>", @id
+ end
+end
+
class TkVariable
include Tk
extend TkCore
@@ -790,7 +844,7 @@ class TkVariable
end
def inspect
- format "<TkVariable: %s>", @id
+ format "#<TkVariable: %s>", @id
end
def ==(other)
@@ -1063,19 +1117,19 @@ module TkWinfo
include Tk
extend Tk
def TkWinfo.atom(name)
- tk_call 'winfo', name
+ number(tk_call 'winfo', 'atom', name)
end
def winfo_atom(name)
TkWinfo.atom name
end
def TkWinfo.atomname(id)
- tk_call 'winfo', id
+ tk_call 'winfo', 'atomname', id
end
def winfo_atomname(id)
TkWinfo.atomname id
end
def TkWinfo.cells(window)
- number(tk_call('winfo', window.path))
+ number(tk_call('winfo', 'cells', window.path))
end
def winfo_cells
TkWinfo.cells self
@@ -1093,6 +1147,12 @@ module TkWinfo
def winfo_classname
TkWinfo.classname self
end
+ def TkWinfo.colormapfull(window)
+ bool(tk_call('winfo', 'colormapfull', window.path))
+ end
+ def winfo_colormapfull
+ TkWinfo.colormapfull self
+ end
def TkWinfo.containing(rootX, rootY)
path = tk_call('winfo', 'containing', rootX, rootY)
window(path)
@@ -1119,7 +1179,7 @@ module TkWinfo
TkWinfo.fpixels self, number
end
def TkWinfo.geometry(window)
- list(tk_call('winfo', 'geometry', window.path))
+ tk_call('winfo', 'geometry', window.path)
end
def winfo_geometry
TkWinfo.geometry self
@@ -1131,15 +1191,15 @@ module TkWinfo
TkWinfo.height self
end
def TkWinfo.id(window)
- number(tk_call('winfo', 'id', window.path))
+ tk_call('winfo', 'id', window.path)
end
def winfo_id
TkWinfo.id self
end
def TkWinfo.interps(window=nil)
if window
- tk_split_simplelist(tk_call('winfo', '-displayof', window.path,
- 'interps'))
+ tk_split_simplelist(tk_call('winfo', 'interps',
+ '-displayof', window.path))
else
tk_split_simplelist(tk_call('winfo', 'interps'))
end
@@ -1153,8 +1213,14 @@ module TkWinfo
def winfo_mapped?
TkWinfo.mapped? self
end
+ def TkWinfo.manager(window)
+ tk_call('winfo', 'manager', window.path)
+ end
+ def winfo_manager
+ TkWinfo.manager self
+ end
def TkWinfo.appname(window)
- bool(tk_call('winfo', 'name', window.path))
+ tk_call('winfo', 'name', window.path)
end
def winfo_appname
TkWinfo.appname self
@@ -1255,6 +1321,12 @@ module TkWinfo
def winfo_screenwidth
TkWinfo.screenwidth self
end
+ def TkWinfo.server(window)
+ tk_call 'winfo', 'server', window.path
+ end
+ def winfo_server
+ TkWinfo.server self
+ end
def TkWinfo.toplevel(window)
window(tk_call('winfo', 'toplevel', window.path))
end
@@ -1267,7 +1339,24 @@ module TkWinfo
def winfo_visual
TkWinfo.visual self
end
- def TkWinfo.vrootheigh(window)
+ def TkWinfo.visualid(window)
+ tk_call 'winfo', 'visualid', window.path
+ end
+ def winfo_visualid
+ TkWinfo.visualid self
+ end
+ def TkWinfo.visualsavailable(window, includeids=false)
+ if includeids
+ v = tk_call('winfo', 'visualsavailable', window.path, "includeids")
+ else
+ v = tk_call('winfo', 'visualsavailable', window.path)
+ end
+ list(v)
+ end
+ def winfo_visualsavailable(includeids=false)
+ TkWinfo.visualsavailable self, includeids
+ end
+ def TkWinfo.vrootheight(window)
number(tk_call('winfo', 'vrootheight', window.path))
end
def winfo_vrootheight
@@ -1540,6 +1629,7 @@ end
class TkObject<TkKernel
include Tk
include TkTreatFont
+ include TkBindCore
def path
return @path
@@ -1636,18 +1726,6 @@ class TkObject<TkKernel
end
end
- def bind(context, cmd=Proc.new, args=nil)
- _bind(["bind", to_eval], context, cmd, args)
- end
-
- def bind_append(context, cmd=Proc.new, args=nil)
- _bind_append(["bind", to_eval], context, cmd, args)
- end
-
- def bindinfo(context=nil)
- _bindinfo(['bind', to_eval], context)
- end
-
def event_generate(context, keys=nil)
if keys
tk_call('event', 'generate', path,
@@ -1671,7 +1749,7 @@ class TkObject<TkKernel
end
class TkWindow<TkObject
-# extend TkClassBind
+ extend TkBindCore
def initialize(parent=nil, keys=nil)
install_win(if parent then parent.path end)
@@ -1819,11 +1897,15 @@ class TkWindow<TkObject
fail unless taglist.kind_of? Array
tk_call('bindtags', path, taglist)
else
- tk_split_list(tk_call('bindtags', path)).collect{|tag|
- if tag == nil
- '.'
- elsif tag.kind_of?(String) && (cls = WidgetClassNames[tag])
- cls
+ list(tk_call('bindtags', path)).collect{|tag|
+ if tag.kind_of?(String)
+ if cls = WidgetClassNames[tag]
+ cls
+ elsif btag = TkBindTag.id2obj(tag)
+ btag
+ else
+ tag
+ end
else
tag
end
@@ -1874,12 +1956,12 @@ class TkToplevel<TkWindow
@classname = classname
if keys.kind_of? Hash
keys = keys.dup
- @classname = keys.delete('classname')
- @colormap = keys.delete('colormap')
- @container = keys.delete('container')
- @screen = keys.delete('screen')
- @use = keys.delete('use')
- @visual = keys.delete('visual')
+ @classname = keys.delete('classname') if keys.key?('classname')
+ @colormap = keys.delete('colormap') if keys.key?('colormap')
+ @container = keys.delete('container') if keys.key?('container')
+ @screen = keys.delete('screen') if keys.key?('screen')
+ @use = keys.delete('use') if keys.key?('use')
+ @visual = keys.delete('visual') if keys.key?('visual')
end
super(parent, keys)
end
@@ -1910,10 +1992,10 @@ class TkFrame<TkWindow
def initialize(parent=nil, keys=nil)
if keys.kind_of? Hash
keys = keys.dup
- @classname = keys.delete('classname')
- @colormap = keys.delete('colormap')
- @container = keys.delete('container')
- @visual = keys.delete('visual')
+ @classname = keys.delete('classname') if keys.key?('classname')
+ @colormap = keys.delete('colormap') if keys.key?('colormap')
+ @container = keys.delete('container') if keys.key?('container')
+ @visual = keys.delete('visual') if keys.key?('visual')
end
super(parent, keys)
end
diff --git a/ext/tk/lib/tkcanvas.rb b/ext/tk/lib/tkcanvas.rb
index 5f03b0f3a9..80c36f6ed8 100644
--- a/ext/tk/lib/tkcanvas.rb
+++ b/ext/tk/lib/tkcanvas.rb
@@ -489,15 +489,15 @@ class TkcTag<TkObject
CTagID_TBL[id]? CTagID_TBL[id]: id
end
- $tk_canvas_tag = 'ctag0000'
+ Tk_CanvasTag_ID = ['ctag0000']
def initialize(parent, mode=nil, *args)
if not parent.kind_of?(TkCanvas)
fail format("%s need to be TkCanvas", parent.inspect)
end
@c = parent
- @path = @id = $tk_canvas_tag
+ @path = @id = Tk_CanvasTag_ID[0]
CTagID_TBL[@id] = self
- $tk_canvas_tag = $tk_canvas_tag.succ
+ Tk_CanvasTag_ID[0] = Tk_CanvasTag_ID[0].succ
if mode
tk_call @c.path, "addtag", @id, mode, *args
end
@@ -572,15 +572,15 @@ class TkcTagCurrent<TkcTag
end
class TkcGroup<TkcTag
- $tk_group_id = 'tkg00000'
+ Tk_cGroup_ID = ['tkcg00000']
def create_self(parent, *args)
if not parent.kind_of?(TkCanvas)
fail format("%s need to be TkCanvas", parent.inspect)
end
@c = parent
- @path = @id = $tk_group_id
+ @path = @id = Tk_cGroup_ID[0]
CTagID_TBL[@id] = self
- $tk_group_id = $tk_group_id.succ
+ Tk_cGroup_ID[0] = Tk_cGroup_ID[0].succ
add(*args) if args != []
end
@@ -702,10 +702,10 @@ class TkImage<TkObject
Tk_IMGTBL = {}
- $tk_image_id = 'i00000'
+ Tk_Image_ID = ['i00000']
def initialize(keys=nil)
- @path = $tk_image_id
- $tk_image_id = $tk_image_id.succ
+ @path = Tk_Image_ID[0]
+ Tk_Image_ID[0] = Tk_Image_ID[0].succ
tk_call 'image', 'create', @type, @path, *hash_kv(keys)
Tk_IMGTBL[@path] = self
end
diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb
index 9d5037e4e2..7872e6a078 100644
--- a/ext/tk/lib/tktext.rb
+++ b/ext/tk/lib/tktext.rb
@@ -123,30 +123,48 @@ end
class TkText<TkTextWin
include TkTreatTextTagFont
+ include Scrollable
WidgetClassName = 'Text'.freeze
WidgetClassNames[WidgetClassName] = self
+
def self.to_eval
WidgetClassName
end
- include Scrollable
+
+ def self.new(*args)
+ obj = super(*args){}
+ obj.init_instance_variable
+ obj.instance_eval &block if defined? yield
+ obj
+ end
+
+ def init_instance_variable
+ @tags = {}
+ end
+
def create_self
tk_call 'text', @path
- @tags = {}
+ init_instance_variable
end
+
def index(index)
tk_send 'index', index
end
+
def value
tk_send 'get', "1.0", "end - 1 char"
end
+
def value= (val)
tk_send 'delete', "1.0", 'end'
tk_send 'insert', "1.0", val
end
+
def _addcmd(cmd)
@cmdtbl.push cmd
end
+
def _addtag(name, obj)
@tags[name] = obj
end
@@ -164,11 +182,19 @@ class TkText<TkTextWin
tagid2obj(elt)
}
end
+
+ def mark_names
+ tk_split_list(tk_send('mark', 'names')).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
def window_names
tk_send('window', 'names').collect{|elt|
tagid2obj(elt)
}
end
+
def image_names
tk_send('image', 'names').collect{|elt|
tagid2obj(elt)
@@ -178,6 +204,7 @@ class TkText<TkTextWin
def set_insert(index)
tk_send 'mark', 'set', 'insert', index
end
+
def set_current(index)
tk_send 'mark', 'set', 'current', index
end
@@ -187,6 +214,7 @@ class TkText<TkTextWin
end
def destroy
+ @tags = {} unless @tags
@tags.each_value do |t|
t.destroy
end
@@ -404,14 +432,15 @@ end
class TkTextTag<TkObject
include TkTreatTagFont
- $tk_text_tag = 'tag0000'
+ Tk_TextTag_ID = ['tag0000']
+
def initialize(parent, *args)
if not parent.kind_of?(TkText)
fail format("%s need to be TkText", parent.inspect)
end
@parent = @t = parent
- @path = @id = $tk_text_tag
- $tk_text_tag = $tk_text_tag.succ
+ @path = @id = Tk_TextTag_ID[0]
+ Tk_TextTag_ID[0] = Tk_TextTag_ID[0].succ
#tk_call @t.path, "tag", "configure", @id, *hash_kv(keys)
if args != [] then
keys = args.pop
@@ -537,14 +566,14 @@ class TkTextTagSel<TkTextTag
end
class TkTextMark<TkObject
- $tk_text_mark = 'mark0000'
+ Tk_TextMark_ID = ['mark0000']
def initialize(parent, index)
if not parent.kind_of?(TkText)
fail format("%s need to be TkText", parent.inspect)
end
@t = parent
- @path = @id = $tk_text_mark
- $tk_text_mark = $tk_text_mark.succ
+ @path = @id = Tk_TextMark_ID[0]
+ Tk_TextMark_ID[0] = Tk_TextMark_ID[0].succ
tk_call @t.path, 'mark', 'set', @id, index
@t._addtag id, self
end
@@ -568,6 +597,14 @@ class TkTextMark<TkObject
def gravity=(direction)
tk_call @t.path, 'mark', 'gravity', @id, direction
end
+
+ def next(index)
+ @t.tagid2obj(tk_call(@t.path, 'mark', 'next', index))
+ end
+
+ def previous(index)
+ @t.tagid2obj(tk_call(@t.path, 'mark', 'previous', index))
+ end
end
class TkTextMarkInsert<TkTextMark
diff --git a/file.c b/file.c
index 543448a315..e22f9b2f6c 100644
--- a/file.c
+++ b/file.c
@@ -6,7 +6,7 @@
$Date$
created at: Mon Nov 15 12:24:34 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
@@ -1126,7 +1126,7 @@ rb_file_s_expand_path(argc, argv)
p = &buf[strlen(buf)];
while (p > buf && *(p - 1) == '/') p--;
}
- else if (isdirsep(*s)) {
+ else {
while (*s && isdirsep(*s)) {
*p++ = '/';
s++;
@@ -1148,7 +1148,8 @@ rb_file_s_expand_path(argc, argv)
}
else {
*++p = '.';
- *++p = '.';
+ do *++p = '.'; while (*++s == '.');
+ --s;
}
break;
case '/':
diff --git a/gc.c b/gc.c
index 7291e4ad41..a649a20e84 100644
--- a/gc.c
+++ b/gc.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Oct 5 09:44:46 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/hash.c b/hash.c
index da31fb3b47..f3be774e67 100644
--- a/hash.c
+++ b/hash.c
@@ -6,7 +6,7 @@
$Date$
created at: Mon Nov 22 18:51:18 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/inits.c b/inits.c
index fdc49f0f4b..5c2dba552c 100644
--- a/inits.c
+++ b/inits.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Dec 28 16:01:58 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/io.c b/io.c
index 2dce9501ba..3d70b3b870 100644
--- a/io.c
+++ b/io.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Oct 15 18:08:59 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
@@ -455,7 +455,9 @@ io_fread(ptr, len, f)
if (!READ_DATA_PENDING(f)) {
rb_thread_wait_fd(fileno(f));
}
+ TRAP_BEG;
c = getc(f);
+ TRAP_END;
if (c == EOF) {
*ptr = '\0';
break;
@@ -1451,7 +1453,8 @@ pipe_open(pname, mode)
pipe_add_fptr(fptr);
if (modef & FMODE_READABLE) fptr->f = f;
if (modef & FMODE_WRITABLE) {
- fptr->f2 = f;
+ if (fptr->f) fptr->f2 = f;
+ else fptr->f = f;
rb_io_synchronized(fptr);
}
return (VALUE)port;
diff --git a/lib/complex.rb b/lib/complex.rb
index 0af8c20b89..56dd040ac1 100644
--- a/lib/complex.rb
+++ b/lib/complex.rb
@@ -20,7 +20,7 @@
# Complex::/
# Complex::**
# Complex::%
-# Complex::divmod
+# Complex::divmod -- obsolete
# Complex::abs
# Complex::abs2
# Complex::arg
@@ -51,6 +51,12 @@
def Complex(a, b = 0)
if a.kind_of?(Complex) and b == 0
a
+ elsif b.kind_of?(Complex)
+ if a.kind_of?(Complex)
+ Complex(a.real-b.image, a.image + b.real)
+ else
+ Complex(a-b.image, b.real)
+ end
elsif b == 0 and defined? Complex::Unify
a
else
@@ -181,18 +187,18 @@ class Complex < Numeric
end
end
- def divmod(other)
- if other.kind_of?(Complex)
- rdiv, rmod = @real.divmod(other.real)
- idiv, imod = @image.divmod(other.image)
- return Complex(rdiv, idiv), Complex(rmod, rdiv)
- elsif Complex.generic?(other)
- Complex(@real.divmod(other), @image.divmod(other))
- else
- x , y = other.coerce(self)
- x.divmod(y)
- end
- end
+# def divmod(other)
+# if other.kind_of?(Complex)
+# rdiv, rmod = @real.divmod(other.real)
+# idiv, imod = @image.divmod(other.image)
+# return Complex(rdiv, idiv), Complex(rmod, rmod)
+# elsif Complex.generic?(other)
+# Complex(@real.divmod(other), @image.divmod(other))
+# else
+# x , y = other.coerce(self)
+# x.divmod(y)
+# end
+# end
def abs
Math.sqrt!((@real*@real + @image*@image).to_f)
diff --git a/lib/parsedate.rb b/lib/parsedate.rb
index 29b3fa43b9..7bf1affb42 100644
--- a/lib/parsedate.rb
+++ b/lib/parsedate.rb
@@ -27,7 +27,7 @@ module ParseDate
if date.sub!(/(#{DAYPAT})[a-z]*,?/i, ' ')
wday = DAYS[$1.downcase]
end
- if date.sub!(/(\d+):(\d+)(?::(\d+))?(?:\s*(am|pm))?(?:\s+([a-z]{1,4}(?:\s+[a-z]{1,4})?|[-+]\d{4}))?/i, ' ')
+ if date.sub!(/(\d+):(\d+)(?::(\d+))?(?:\s*(am|pm))?(?:\s+([a-z]{1,4}(?:\s+[a-z]{1,4}|[-+]\d{4})?))?/i, ' ')
hour = $1.to_i
min = $2.to_i
if $3
diff --git a/lib/timeout.rb b/lib/timeout.rb
index d4ea758acd..cc2ab5bac5 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -25,8 +25,6 @@
class TimeoutError<StandardError
end
-Thread.abort_on_exception = true
-
def timeout(sec)
begin
x = Thread.current
diff --git a/math.c b/math.c
index 978a23c73c..39bc48aa1c 100644
--- a/math.c
+++ b/math.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Jan 25 14:12:56 JST 1994
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/missing/isnan.c b/missing/isnan.c
index 96bb93ba6a..3c56765807 100644
--- a/missing/isnan.c
+++ b/missing/isnan.c
@@ -1,3 +1,15 @@
+#ifdef _MSC_VER
+
+#include <float.h>
+int
+isnan(n)
+ double n;
+{
+ return _isnan(n);
+}
+
+#else
+
static int double_ne();
int
@@ -14,3 +26,4 @@ double_ne(n1, n2)
{
return n1 != n2;
}
+#endif
diff --git a/node.h b/node.h
index ea44a454d5..358a27003d 100644
--- a/node.h
+++ b/node.h
@@ -6,7 +6,7 @@
$Date$
created at: Fri May 28 15:14:02 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/numeric.c b/numeric.c
index f3e5d55379..4b394f434b 100644
--- a/numeric.c
+++ b/numeric.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Aug 13 18:33:09 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/object.c b/object.c
index 9c5163a248..b1a2d248c4 100644
--- a/object.c
+++ b/object.c
@@ -6,7 +6,7 @@
$Date$
created at: Thu Jul 15 12:01:24 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/pack.c b/pack.c
index 999f93a0e7..83b83fbc41 100644
--- a/pack.c
+++ b/pack.c
@@ -6,7 +6,7 @@
$Date$
created at: Thu Feb 10 15:17:05 JST 1994
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/parse.y b/parse.y
index 6d9616df71..3b23c32af2 100644
--- a/parse.y
+++ b/parse.y
@@ -6,7 +6,7 @@
$Date$
created at: Fri May 28 18:02:42 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
@@ -583,8 +583,7 @@ undef_list : fitem
$$ = block_append($1, NEW_UNDEF($4));
}
-op : tDOT2 { $$ = tDOT2; }
- | '|' { $$ = '|'; }
+op : '|' { $$ = '|'; }
| '^' { $$ = '^'; }
| '&' { $$ = '&'; }
| tCMP { $$ = tCMP; }
@@ -3780,7 +3779,7 @@ arg_add(node1, node2)
return list_append(node1, node2);
}
else {
- return NEW_ARGSCAT(node1, node2);
+ return NEW_ARGSCAT(node1, NEW_LIST(node2));
}
}
diff --git a/prec.c b/prec.c
index e4e116c347..43739bd9bd 100644
--- a/prec.c
+++ b/prec.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Jan 26 02:40:41 1999
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
*************************************************/
diff --git a/process.c b/process.c
index 211445b88d..e569ef5f6e 100644
--- a/process.c
+++ b/process.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Aug 10 14:30:50 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/random.c b/random.c
index 67c752d0f7..e8c9d1cb28 100644
--- a/random.c
+++ b/random.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Dec 24 16:39:21 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
@@ -81,6 +81,30 @@ static int first = 1;
static char state[256];
#endif
+static int
+rand_init(seed)
+ long seed;
+{
+ int old;
+ static unsigned int saved_seed;
+
+#ifdef HAVE_RANDOM
+ if (first == 1) {
+ initstate(1, state, sizeof state);
+ first = 0;
+ }
+ else {
+ setstate(state);
+ }
+#endif
+
+ SRANDOM(seed);
+ old = saved_seed;
+ saved_seed = seed;
+
+ return old;
+}
+
static VALUE
rb_f_srand(argc, argv, obj)
int argc;
@@ -89,7 +113,6 @@ rb_f_srand(argc, argv, obj)
{
VALUE a;
unsigned int seed, old;
- static unsigned int saved_seed;
if (rb_scan_args(argc, argv, "01", &a) == 0) {
static int n = 0;
@@ -101,20 +124,7 @@ rb_f_srand(argc, argv, obj)
else {
seed = NUM2UINT(a);
}
-
-#ifdef HAVE_RANDOM
- if (first == 1) {
- initstate(1, state, sizeof state);
- first = 0;
- }
- else {
- setstate(state);
- }
-#endif
-
- SRANDOM(seed);
- old = saved_seed;
- saved_seed = seed;
+ old = rand_init(seed);
return rb_uint2inum(old);
}
@@ -125,6 +135,14 @@ rb_f_rand(obj, vmax)
{
long val, max;
+ static initialized = 0;
+
+ if (first) {
+ struct timeval tv;
+
+ gettimeofday(&tv, 0);
+ rand_init(tv.tv_sec ^ tv.tv_usec ^ getpid());
+ }
switch (TYPE(vmax)) {
case T_FLOAT:
if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN)
diff --git a/range.c b/range.c
index b1925e9929..ff455e4a96 100644
--- a/range.c
+++ b/range.c
@@ -6,7 +6,7 @@
$Date$
created at: Thu Aug 19 17:46:47 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/re.c b/re.c
index c038f2c1c6..8052189e08 100644
--- a/re.c
+++ b/re.c
@@ -5,7 +5,7 @@
$Author$
created at: Mon Aug 9 18:24:49 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/re.h b/re.h
index 9d3b77f519..c4a63e1ff0 100644
--- a/re.h
+++ b/re.h
@@ -6,7 +6,7 @@
$Date$
created at: Thu Sep 30 14:18:32 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/ruby.c b/ruby.c
index a923408942..ab7357529b 100644
--- a/ruby.c
+++ b/ruby.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Aug 10 12:47:31 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/ruby.h b/ruby.h
index 1f56f7a67b..fe24da344d 100644
--- a/ruby.h
+++ b/ruby.h
@@ -5,7 +5,7 @@
$Author$
created at: Thu Jun 10 14:26:32 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
*************************************************/
diff --git a/rubyio.h b/rubyio.h
index f4b72781e5..145b420696 100644
--- a/rubyio.h
+++ b/rubyio.h
@@ -6,7 +6,7 @@
$Date$
created at: Fri Nov 12 16:47:09 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/sprintf.c b/sprintf.c
index 346cf2b643..40d2e04535 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Oct 15 10:39:26 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/string.c b/string.c
index 1f357efdd5..ae2ba20f62 100644
--- a/string.c
+++ b/string.c
@@ -6,7 +6,7 @@
$Date$
created at: Mon Aug 9 17:12:58 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
@@ -860,7 +860,7 @@ rb_str_replace(str, beg, len, val)
if (RSTRING(str)->len < beg && len < 0) {
MEMZERO(RSTRING(str)->ptr + RSTRING(str)->len, char, -len);
}
- memcpy(RSTRING(str)->ptr+beg, RSTRING(val)->ptr, RSTRING(val)->len);
+ memmove(RSTRING(str)->ptr+beg, RSTRING(val)->ptr, RSTRING(val)->len);
RSTRING(str)->len += RSTRING(val)->len - len;
RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
}
diff --git a/time.c b/time.c
index dd22c499dd..5da0a69673 100644
--- a/time.c
+++ b/time.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Dec 28 14:31:59 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/util.c b/util.c
index 04b3dd6dbe..6a792fe4f4 100644
--- a/util.c
+++ b/util.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Mar 10 17:22:34 JST 1995
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
diff --git a/util.h b/util.h
index 41ce2a5a19..84ad5fcc5f 100644
--- a/util.h
+++ b/util.h
@@ -6,7 +6,7 @@
$Date$
created at: Thu Mar 9 11:55:53 JST 1995
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
#ifndef UTIL_H
diff --git a/version.c b/version.c
index 6cd9943430..fa27427c67 100644
--- a/version.c
+++ b/version.c
@@ -6,7 +6,7 @@
$Date$
created at: Thu Sep 30 20:08:01 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
@@ -40,6 +40,6 @@ ruby_show_version()
void
ruby_show_copyright()
{
- printf("ruby - Copyright (C) 1993-1999 Yukihiro Matsumoto\n");
+ printf("ruby - Copyright (C) 1993-2000 Yukihiro Matsumoto\n");
exit(0);
}
diff --git a/version.h b/version.h
index 2d1af6448f..514a3feba8 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.4.4"
-#define RUBY_RELEASE_DATE "1999-12-14"
+#define RUBY_RELEASE_DATE "2000-01-17"
#define RUBY_VERSION_CODE 144
-#define RUBY_RELEASE_CODE 19991214
+#define RUBY_RELEASE_CODE 20000117
diff --git a/win32/win32.c b/win32/win32.c
index cd33fe1fd2..877978db58 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -229,7 +229,6 @@ char *getlogin()
struct {
int inuse;
int pid;
- HANDLE oshandle;
FILE *pipe;
} MyPopenRecord[MYPOPENSIZE];
@@ -509,23 +508,11 @@ mypopen (char *cmd, char *mode)
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
- if (!reading) {
- FILE *fp;
-
- fp = (_popen)(cmd, mode);
-
- MyPopenRecord[slot].inuse = TRUE;
- MyPopenRecord[slot].pipe = fp;
- MyPopenRecord[slot].pid = -1;
-
- if (!fp)
- rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno));
- return fp;
- }
-
fRet = CreatePipe(&hInFile, &hOutFile, &sa, 2048L);
- if (!fRet)
- rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno));
+ if (!fRet) {
+ errno = GetLastError();
+ rb_sys_fail("mypopen: CreatePipe");
+ }
memset(&aStartupInfo, 0, sizeof (STARTUPINFO));
memset(&aProcessInformation, 0, sizeof (PROCESS_INFORMATION));
@@ -547,46 +534,50 @@ mypopen (char *cmd, char *mode)
lpCommandLine = cmd;
if (NtHasRedirection(cmd) || isInternalCmd(cmd)) {
lpApplicationName = getenv("COMSPEC");
- lpCmd2 = malloc(strlen(lpApplicationName) + 1 + strlen(cmd) + sizeof (" /c "));
- if (lpCmd2 == NULL)
- rb_fatal("Mypopen: malloc failed");
+ lpCmd2 = xmalloc(strlen(lpApplicationName) + 1 + strlen(cmd) + sizeof (" /c "));
sprintf(lpCmd2, "%s %s%s", lpApplicationName, " /c ", cmd);
lpCommandLine = lpCmd2;
}
fRet = CreateProcess(lpApplicationName, lpCommandLine, &sa, &sa,
sa.bInheritHandle, dwCreationFlags, NULL, NULL, &aStartupInfo, &aProcessInformation);
+ errno = GetLastError();
+
+ if (lpCmd2)
+ free(lpCmd2);
+
+ CloseHandle(aProcessInformation.hThread);
if (!fRet) {
CloseHandle(hInFile);
CloseHandle(hOutFile);
- rb_fatal("cannot fork for \"%s\" (%s)", cmd, strerror(errno));
+ CloseHandle(aProcessInformation.hProcess);
+ return NULL;
}
- CloseHandle(aProcessInformation.hThread);
-
if (reading) {
fd = _open_osfhandle((long)hInFile, (_O_RDONLY | pipemode));
CloseHandle(hOutFile);
}
else {
- fd = _open_osfhandle((long)hOutFile, (_O_WRONLY | pipemode));
+ fd = _open_osfhandle((long)hOutFile, (_O_WRONLY | pipemode));
CloseHandle(hInFile);
}
- if (fd == -1)
- rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno));
-
-
- if ((fp = (FILE *) fdopen(fd, mode)) == NULL)
- return NULL;
+ if (fd == -1) {
+ CloseHandle(reading ? hInFile : hOutFile);
+ CloseHandle(aProcessInformation.hProcess);
+ rb_sys_fail("mypopen: _open_osfhandle");
+ }
- if (lpCmd2)
- free(lpCmd2);
+ if ((fp = (FILE *) fdopen(fd, mode)) == NULL) {
+ _close(fd);
+ CloseHandle(aProcessInformation.hProcess);
+ rb_sys_fail("mypopen: fdopen");
+ }
MyPopenRecord[slot].inuse = TRUE;
MyPopenRecord[slot].pipe = fp;
- MyPopenRecord[slot].oshandle = (reading ? hInFile : hOutFile);
MyPopenRecord[slot].pid = (int)aProcessInformation.hProcess;
return fp;
}
@@ -638,14 +629,13 @@ mypclose(FILE *fp)
}
}
}
+ CloseHandle((HANDLE)MyPopenRecord[i].pid);
#endif
-
//
// close the pipe
//
- // Closehandle() is done by fclose().
- //CloseHandle(MyPopenRecord[i].oshandle);
+
fflush(fp);
fclose(fp);