mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
2000-01-17
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e43877719b
commit
dde62bcd2e
21 changed files with 391 additions and 256 deletions
41
ChangeLog
41
ChangeLog
|
@ -1,3 +1,40 @@
|
|||
Sat Jan 15 22:21:08 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* eval.c (search_method): argument klass may be 0.
|
||||
|
||||
Sat Jan 15 15:03:46 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* enum.c (enum_index): remove this method.
|
||||
|
||||
* enum.c: remove use of pointers to local variables. find,
|
||||
find_all, min, max, index, member?, each_with_index,
|
||||
|
||||
* eval.c (massign): multiple assignment does not use to_a anymore.
|
||||
experimental.
|
||||
|
||||
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).
|
||||
|
||||
Thu Jan 13 11:12:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* parse.y (arg_add): use new node, ARGSPUSH.
|
||||
|
||||
Mon Jan 10 18:32:28 2000 Koji Arai <JCA02266@nifty.ne.jp>
|
||||
|
||||
* marshal.c (w_object): forgot an argument to call w_ivar().
|
||||
|
||||
Sun Jan 9 18:13:51 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
|
||||
|
||||
* random.c: first was not defined unless HAVE_RANDOM.
|
||||
|
||||
Sat Jan 8 19:02:49 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* io.c (rb_io_sysread): raise IOError for buffered IO.
|
||||
|
||||
* ext/socket/socket.c (s_recv): ditto.
|
||||
|
||||
Fri Jan 7 00:59:29 2000 Masahiro Tomita <tommy@tmtm.org>
|
||||
|
||||
* io.c (io_fread): TRAP_BEG/TRAP_END added around getc().
|
||||
|
@ -123,6 +160,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.
|
||||
|
|
1
ToDo
1
ToDo
|
@ -34,6 +34,7 @@ Hacking Interpreter
|
|||
* syntax tree -> bytecode ???
|
||||
* scrambled script, or script filter
|
||||
* setuid ruby
|
||||
* freeze all object
|
||||
|
||||
Standard Libraries
|
||||
|
||||
|
|
165
enum.c
165
enum.c
|
@ -11,6 +11,7 @@
|
|||
************************************************/
|
||||
|
||||
#include "ruby.h"
|
||||
#include "node.h"
|
||||
|
||||
VALUE rb_mEnumerable;
|
||||
static ID id_each, id_eqq, id_cmp;
|
||||
|
@ -58,19 +59,14 @@ enum_grep(obj, pat)
|
|||
return tmp;
|
||||
}
|
||||
|
||||
struct find_arg {
|
||||
int found;
|
||||
VALUE val;
|
||||
};
|
||||
|
||||
static VALUE
|
||||
find_i(i, arg)
|
||||
find_i(i, memo)
|
||||
VALUE i;
|
||||
struct find_arg *arg;
|
||||
NODE *memo;
|
||||
{
|
||||
if (RTEST(rb_yield(i))) {
|
||||
arg->found = Qtrue;
|
||||
arg->val = i;
|
||||
memo->u2.value = Qtrue;
|
||||
memo->u1.value = i;
|
||||
rb_iter_break();
|
||||
}
|
||||
return Qnil;
|
||||
|
@ -82,18 +78,19 @@ enum_find(argc, argv, obj)
|
|||
VALUE* argv;
|
||||
VALUE obj;
|
||||
{
|
||||
struct find_arg arg;
|
||||
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, Qfalse, 0);
|
||||
VALUE if_none;
|
||||
|
||||
rb_scan_args(argc, argv, "01", &if_none);
|
||||
arg.found = Qfalse;
|
||||
rb_iterate(rb_each, obj, find_i, (VALUE)&arg);
|
||||
if (arg.found) {
|
||||
return arg.val;
|
||||
rb_iterate(rb_each, obj, find_i, (VALUE)memo);
|
||||
if (memo->u2.value) {
|
||||
rb_gc_force_recycle((VALUE)memo);
|
||||
return memo->u1.value;
|
||||
}
|
||||
if (!NIL_P(if_none)) {
|
||||
rb_eval_cmd(if_none, Qnil);
|
||||
}
|
||||
rb_gc_force_recycle((VALUE)memo);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
@ -189,33 +186,35 @@ enum_sort(obj)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
min_i(i, min)
|
||||
VALUE i, *min;
|
||||
min_i(i, memo)
|
||||
VALUE i;
|
||||
NODE *memo;
|
||||
{
|
||||
VALUE cmp;
|
||||
|
||||
if (NIL_P(*min))
|
||||
*min = i;
|
||||
if (NIL_P(memo->u1.value))
|
||||
memo->u1.value = i;
|
||||
else {
|
||||
cmp = rb_funcall(i, id_cmp, 1, *min);
|
||||
cmp = rb_funcall(i, id_cmp, 1, memo->u1.value);
|
||||
if (NUM2LONG(cmp) < 0)
|
||||
*min = i;
|
||||
memo->u1.value = i;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
min_ii(i, min)
|
||||
VALUE i, *min;
|
||||
min_ii(i, memo)
|
||||
VALUE i;
|
||||
NODE *memo;
|
||||
{
|
||||
VALUE cmp;
|
||||
|
||||
if (NIL_P(*min))
|
||||
*min = i;
|
||||
if (NIL_P(memo->u1.value))
|
||||
memo->u1.value = i;
|
||||
else {
|
||||
cmp = rb_yield(rb_assoc_new(i, *min));
|
||||
cmp = rb_yield(rb_assoc_new(i, memo->u1.value));
|
||||
if (NUM2LONG(cmp) < 0)
|
||||
*min = i;
|
||||
memo->u1.value = i;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -224,40 +223,43 @@ static VALUE
|
|||
enum_min(obj)
|
||||
VALUE obj;
|
||||
{
|
||||
VALUE min = Qnil;
|
||||
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
|
||||
|
||||
rb_iterate(rb_each, obj, rb_iterator_p()?min_ii:min_i, (VALUE)&min);
|
||||
return min;
|
||||
rb_iterate(rb_each, obj, rb_iterator_p()?min_ii:min_i, (VALUE)memo);
|
||||
rb_gc_force_recycle((VALUE)memo);
|
||||
return memo->u1.value;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
max_i(i, max)
|
||||
VALUE i, *max;
|
||||
max_i(i, memo)
|
||||
VALUE i;
|
||||
NODE *memo;
|
||||
{
|
||||
VALUE cmp;
|
||||
|
||||
if (NIL_P(*max))
|
||||
*max = i;
|
||||
if (NIL_P(memo->u1.value))
|
||||
memo->u1.value = i;
|
||||
else {
|
||||
cmp = rb_funcall(i, id_cmp, 1, *max);
|
||||
cmp = rb_funcall(i, id_cmp, 1, memo->u1.value);
|
||||
if (NUM2LONG(cmp) > 0)
|
||||
*max = i;
|
||||
memo->u1.value = i;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
max_ii(i, max)
|
||||
VALUE i, *max;
|
||||
max_ii(i, memo)
|
||||
VALUE i;
|
||||
NODE *memo;
|
||||
{
|
||||
VALUE cmp;
|
||||
|
||||
if (NIL_P(*max))
|
||||
*max = i;
|
||||
if (NIL_P(memo->u1.value))
|
||||
memo->u1.value = i;
|
||||
else {
|
||||
cmp = rb_yield(rb_assoc_new(i, *max));
|
||||
cmp = rb_yield(rb_assoc_new(i, memo->u1.value));
|
||||
if (NUM2LONG(cmp) > 0)
|
||||
*max = i;
|
||||
memo->u1.value = i;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -266,54 +268,20 @@ static VALUE
|
|||
enum_max(obj)
|
||||
VALUE obj;
|
||||
{
|
||||
VALUE max = Qnil;
|
||||
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
|
||||
|
||||
rb_iterate(rb_each, obj, rb_iterator_p()?max_ii:max_i, (VALUE)&max);
|
||||
return max;
|
||||
rb_iterate(rb_each, obj, rb_iterator_p()?max_ii:max_i, (VALUE)memo);
|
||||
rb_gc_force_recycle((VALUE)memo);
|
||||
return memo->u1.value;
|
||||
}
|
||||
|
||||
struct i_v_pair {
|
||||
int i;
|
||||
VALUE v;
|
||||
int found;
|
||||
};
|
||||
|
||||
static VALUE
|
||||
index_i(item, iv)
|
||||
member_i(item, memo)
|
||||
VALUE item;
|
||||
struct i_v_pair *iv;
|
||||
NODE *memo;
|
||||
{
|
||||
if (rb_equal(item, iv->v)) {
|
||||
iv->found = 1;
|
||||
rb_iter_break();
|
||||
}
|
||||
else {
|
||||
iv->i++;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
enum_index(obj, val)
|
||||
VALUE obj, val;
|
||||
{
|
||||
struct i_v_pair iv;
|
||||
|
||||
iv.i = 0;
|
||||
iv.v = val;
|
||||
iv.found = 0;
|
||||
rb_iterate(rb_each, obj, index_i, (VALUE)&iv);
|
||||
if (iv.found) return INT2FIX(iv.i);
|
||||
return Qnil; /* not found */
|
||||
}
|
||||
|
||||
static VALUE
|
||||
member_i(item, iv)
|
||||
VALUE item;
|
||||
struct i_v_pair *iv;
|
||||
{
|
||||
if (rb_equal(item, iv->v)) {
|
||||
iv->i = 1;
|
||||
if (rb_equal(item, memo->u1.value)) {
|
||||
memo->u2.value = Qtrue;
|
||||
rb_iter_break();
|
||||
}
|
||||
return Qnil;
|
||||
|
@ -323,26 +291,23 @@ static VALUE
|
|||
enum_member(obj, val)
|
||||
VALUE obj, val;
|
||||
{
|
||||
struct i_v_pair iv;
|
||||
VALUE result;
|
||||
|
||||
iv.i = 0;
|
||||
iv.v = val;
|
||||
rb_iterate(rb_each, obj, member_i, (VALUE)&iv);
|
||||
if (iv.i) return Qtrue;
|
||||
return Qfalse;
|
||||
NODE *memo = rb_node_newnode(NODE_MEMO, val, Qfalse, 0);
|
||||
|
||||
rb_iterate(rb_each, obj, member_i, (VALUE)memo);
|
||||
result = memo->u2.value;
|
||||
rb_gc_force_recycle((VALUE)memo);
|
||||
return result;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
each_with_index_i(val, indexp)
|
||||
each_with_index_i(val, memo)
|
||||
VALUE val;
|
||||
int *indexp;
|
||||
NODE *memo;
|
||||
{
|
||||
#if 1
|
||||
rb_yield(rb_assoc_new(val, INT2FIX(*indexp)));
|
||||
#else
|
||||
rb_yield(rb_ary_concat(rb_Array(val), INT2FIX(*indexp)));
|
||||
#endif
|
||||
(*indexp)++;
|
||||
rb_yield(rb_assoc_new(val, INT2FIX(memo->u3.cnt)));
|
||||
memo->u3.cnt++;
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
@ -350,9 +315,10 @@ static VALUE
|
|||
enum_each_with_index(obj)
|
||||
VALUE obj;
|
||||
{
|
||||
int index = 0;
|
||||
NODE *memo = rb_node_newnode(NODE_MEMO, 0, 0, 0);
|
||||
|
||||
rb_iterate(rb_each, obj, each_with_index_i, (VALUE)&index);
|
||||
rb_iterate(rb_each, obj, each_with_index_i, (VALUE)memo);
|
||||
rb_gc_force_recycle((VALUE)memo);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
@ -374,7 +340,6 @@ Init_Enumerable()
|
|||
rb_define_method(rb_mEnumerable,"collect", enum_collect, 0);
|
||||
rb_define_method(rb_mEnumerable,"min", enum_min, 0);
|
||||
rb_define_method(rb_mEnumerable,"max", enum_max, 0);
|
||||
rb_define_method(rb_mEnumerable,"index", enum_index, 1);
|
||||
rb_define_method(rb_mEnumerable,"member?", enum_member, 1);
|
||||
rb_define_method(rb_mEnumerable,"include?", enum_member, 1);
|
||||
rb_define_method(rb_mEnumerable,"each_with_index", enum_each_with_index, 0);
|
||||
|
|
18
eval.c
18
eval.c
|
@ -239,6 +239,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;
|
||||
|
@ -2284,6 +2285,11 @@ rb_eval(self, node)
|
|||
rb_eval(self, node->nd_body));
|
||||
break;
|
||||
|
||||
case NODE_ARGSPUSH:
|
||||
result = rb_ary_push(rb_eval(self, node->nd_head),
|
||||
rb_eval(self, node->nd_body));
|
||||
break;
|
||||
|
||||
case NODE_CALL:
|
||||
{
|
||||
VALUE recv;
|
||||
|
@ -3333,10 +3339,13 @@ rb_yield_0(val, self, klass, acheck)
|
|||
!FL_TEST(ruby_dyna_vars, DVAR_DONT_RECYCLE)) {
|
||||
struct RVarmap *vars = ruby_dyna_vars;
|
||||
|
||||
do {
|
||||
while (vars && vars->id != 0) {
|
||||
rb_gc_force_recycle((VALUE)vars);
|
||||
vars = vars->next;
|
||||
} while (vars && vars->id != 0);
|
||||
}
|
||||
if (ruby_dyna_vars->id == 0) {
|
||||
rb_gc_force_recycle((VALUE)ruby_dyna_vars);
|
||||
}
|
||||
}
|
||||
POP_VARS();
|
||||
ruby_block = block;
|
||||
|
@ -3379,7 +3388,10 @@ massign(self, node, val, check)
|
|||
|
||||
if (val) {
|
||||
if (TYPE(val) != T_ARRAY) {
|
||||
val = rb_Array(val);
|
||||
if (NIL_P(val))
|
||||
val = rb_ary_new2(0);
|
||||
else
|
||||
val = rb_ary_new3(1, val);
|
||||
}
|
||||
len = RARRAY(val)->len;
|
||||
for (i=0; list && i<len; i++) {
|
||||
|
|
|
@ -373,10 +373,14 @@ s_recv(sock, argc, argv, from)
|
|||
if (flg == Qnil) flags = 0;
|
||||
else flags = NUM2INT(flg);
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
if (rb_read_pending(fptr->f)) {
|
||||
rb_raise(rb_eIOError, "recv for buffered IO");
|
||||
}
|
||||
fd = fileno(fptr->f);
|
||||
|
||||
str = rb_str_new(0, NUM2INT(len));
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
fd = fileno(fptr->f);
|
||||
rb_thread_wait_fd(fd);
|
||||
TRAP_BEG;
|
||||
retry:
|
||||
|
|
194
ext/tk/lib/tk.rb
194
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])
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 create_self
|
||||
tk_call 'text', @path
|
||||
|
||||
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
|
||||
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
|
||||
|
|
5
file.c
5
file.c
|
@ -1245,7 +1245,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++;
|
||||
|
@ -1267,7 +1267,8 @@ rb_file_s_expand_path(argc, argv)
|
|||
}
|
||||
else {
|
||||
*++p = '.';
|
||||
*++p = '.';
|
||||
do *++p = '.'; while (*++s == '.');
|
||||
--s;
|
||||
}
|
||||
break;
|
||||
case '/':
|
||||
|
|
11
io.c
11
io.c
|
@ -160,13 +160,11 @@ rb_io_check_writable(fptr)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
rb_read_check(fp)
|
||||
int
|
||||
rb_read_pending(fp)
|
||||
FILE *fp;
|
||||
{
|
||||
if (!READ_DATA_PENDING(fp)) {
|
||||
rb_thread_wait_fd(fileno(fp));
|
||||
}
|
||||
return READ_DATA_PENDING(fp);
|
||||
}
|
||||
|
||||
/* writing functions */
|
||||
|
@ -1076,6 +1074,9 @@ rb_io_sysread(io, len)
|
|||
GetOpenFile(io, fptr);
|
||||
rb_io_check_readable(fptr);
|
||||
|
||||
if (READ_DATA_PENDING(fptr->f)) {
|
||||
rb_raise(rb_eIOError, "sysread for buffered IO");
|
||||
}
|
||||
str = rb_str_new(0, ilen);
|
||||
|
||||
rb_thread_wait_fd(fileno(fptr->f));
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
class TimeoutError<StandardError
|
||||
end
|
||||
|
||||
Thread.abort_on_exception = true
|
||||
|
||||
def timeout(sec)
|
||||
begin
|
||||
x = Thread.current
|
||||
|
|
|
@ -224,7 +224,7 @@ w_object(obj, arg, limit)
|
|||
int limit;
|
||||
{
|
||||
struct dump_call_arg c_arg;
|
||||
st_table *ivtbl = 0;;
|
||||
st_table *ivtbl = 0;
|
||||
|
||||
if (limit == 0) {
|
||||
rb_raise(rb_eRuntimeError, "exceed depth limit");
|
||||
|
@ -397,7 +397,7 @@ w_object(obj, arg, limit)
|
|||
}
|
||||
path = rb_class2name(klass);
|
||||
w_unique(path, arg);
|
||||
w_ivar(ROBJECT(obj)->iv_tbl);
|
||||
w_ivar(ROBJECT(obj)->iv_tbl, &c_arg);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
3
node.h
3
node.h
|
@ -84,6 +84,7 @@ enum node_type {
|
|||
NODE_DREGX_ONCE,
|
||||
NODE_ARGS,
|
||||
NODE_ARGSCAT,
|
||||
NODE_ARGSPUSH,
|
||||
NODE_RESTARGS,
|
||||
NODE_BLOCK_ARG,
|
||||
NODE_BLOCK_PASS,
|
||||
|
@ -114,6 +115,7 @@ enum node_type {
|
|||
#ifdef C_ALLOCA
|
||||
NODE_ALLOCA,
|
||||
#endif
|
||||
NODE_MEMO,
|
||||
};
|
||||
|
||||
typedef struct RNode {
|
||||
|
@ -290,6 +292,7 @@ typedef struct RNode {
|
|||
#define NEW_ZSUPER() rb_node_newnode(NODE_ZSUPER,0,0,0)
|
||||
#define NEW_ARGS(f,o,r) rb_node_newnode(NODE_ARGS,o,r,f)
|
||||
#define NEW_ARGSCAT(a,b) rb_node_newnode(NODE_ARGSCAT,a,b,0)
|
||||
#define NEW_ARGSPUSH(a,b) rb_node_newnode(NODE_ARGSPUSH,a,b,0)
|
||||
#define NEW_RESTARGS(a) rb_node_newnode(NODE_RESTARGS,a,0,0)
|
||||
#define NEW_BLOCK_ARG(v) rb_node_newnode(NODE_BLOCK_ARG,v,0,local_cnt(v))
|
||||
#define NEW_BLOCK_PASS(b) rb_node_newnode(NODE_BLOCK_PASS,0,b,0)
|
||||
|
|
25
parse.y
25
parse.y
|
@ -3007,11 +3007,8 @@ yylex()
|
|||
case ':':
|
||||
c = nextc();
|
||||
if (c == ':') {
|
||||
if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
|
||||
lex_state = EXPR_BEG;
|
||||
return tCOLON3;
|
||||
}
|
||||
if (lex_state == EXPR_ARG && space_seen) {
|
||||
if (lex_state == EXPR_BEG || lex_state == EXPR_MID ||
|
||||
(lex_state == EXPR_ARG && space_seen)) {
|
||||
lex_state = EXPR_BEG;
|
||||
return tCOLON3;
|
||||
}
|
||||
|
@ -3284,7 +3281,7 @@ yylex()
|
|||
tokfix();
|
||||
|
||||
{
|
||||
int result;
|
||||
int result = 0;
|
||||
|
||||
switch (tok()[0]) {
|
||||
case '$':
|
||||
|
@ -3312,22 +3309,25 @@ yylex()
|
|||
}
|
||||
}
|
||||
|
||||
if (ISUPPER(tok()[0])) {
|
||||
result = tCONSTANT;
|
||||
}
|
||||
else if (toklast() == '!' || toklast() == '?') {
|
||||
if (toklast() == '!' || toklast() == '?') {
|
||||
result = tFID;
|
||||
}
|
||||
else {
|
||||
result = tIDENTIFIER;
|
||||
if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) {
|
||||
if ((c = nextc()) == '=' && !peek('=')) {
|
||||
result = tIDENTIFIER;
|
||||
tokadd(c);
|
||||
}
|
||||
else {
|
||||
pushback(c);
|
||||
}
|
||||
}
|
||||
if (result == 0 && ISUPPER(tok()[0])) {
|
||||
result = tCONSTANT;
|
||||
}
|
||||
else {
|
||||
result = tIDENTIFIER;
|
||||
}
|
||||
}
|
||||
if (lex_state == EXPR_BEG ||
|
||||
lex_state == EXPR_DOT ||
|
||||
|
@ -3841,6 +3841,7 @@ arg_concat(node1, node2)
|
|||
NODE *node1;
|
||||
NODE *node2;
|
||||
{
|
||||
if (!node2) return node1;
|
||||
return NEW_ARGSCAT(node1, node2);
|
||||
}
|
||||
|
||||
|
@ -3854,7 +3855,7 @@ arg_add(node1, node2)
|
|||
return list_append(node1, node2);
|
||||
}
|
||||
else {
|
||||
return NEW_ARGSCAT(node1, node2);
|
||||
return NEW_ARGSPUSH(node1, node2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
8
random.c
8
random.c
|
@ -76,8 +76,8 @@ void srand48 _((long));
|
|||
|
||||
#endif /* not HAVE_DRAND48 */
|
||||
|
||||
#ifdef HAVE_RANDOM
|
||||
static int first = 1;
|
||||
#if !defined HAVE_DRAND48 && defined HAVE_RANDOM
|
||||
static char state[256];
|
||||
#endif
|
||||
|
||||
|
@ -88,15 +88,15 @@ rand_init(seed)
|
|||
int old;
|
||||
static unsigned int saved_seed;
|
||||
|
||||
#ifdef HAVE_RANDOM
|
||||
#if !defined HAVE_DRAND48 && defined HAVE_RANDOM
|
||||
if (first == 1) {
|
||||
initstate(1, state, sizeof state);
|
||||
first = 0;
|
||||
}
|
||||
else {
|
||||
setstate(state);
|
||||
}
|
||||
#endif
|
||||
first = 0;
|
||||
|
||||
SRANDOM(seed);
|
||||
old = saved_seed;
|
||||
|
@ -135,8 +135,6 @@ rb_f_rand(obj, vmax)
|
|||
{
|
||||
long val, max;
|
||||
|
||||
static initialized = 0;
|
||||
|
||||
if (first) {
|
||||
struct timeval tv;
|
||||
|
||||
|
|
3
rubyio.h
3
rubyio.h
|
@ -58,6 +58,5 @@ void rb_io_synchronized _((OpenFile*));
|
|||
void rb_io_check_closed _((OpenFile*));
|
||||
void rb_eof_error _((void));
|
||||
|
||||
void rb_read_check _((FILE*)); /* thread aware check */
|
||||
|
||||
int rb_read_pending _((FILE*));
|
||||
#endif
|
||||
|
|
29
string.c
29
string.c
|
@ -863,7 +863,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';
|
||||
}
|
||||
|
@ -2193,32 +2193,6 @@ rb_str_each_line(argc, argv, str)
|
|||
return str;
|
||||
}
|
||||
|
||||
#ifdef STR_TO_A_USE_EACH
|
||||
static VALUE
|
||||
to_a_push(str, ary)
|
||||
VALUE str, ary;
|
||||
{
|
||||
return rb_ary_push(ary, str);
|
||||
}
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
rb_str_to_a(str)
|
||||
VALUE str;
|
||||
{
|
||||
#ifdef STR_TO_A_USE_EACH
|
||||
VALUE ary;
|
||||
|
||||
if (RSTRING(str)->len == 0) return rb_ary_new3(1, str);
|
||||
ary = rb_ary_new();
|
||||
rb_iterate(rb_each, str, to_a_push, ary);
|
||||
|
||||
return ary;
|
||||
#else
|
||||
return rb_ary_new3(1, str);
|
||||
#endif
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_each_byte(str)
|
||||
VALUE str;
|
||||
|
@ -2652,7 +2626,6 @@ Init_String()
|
|||
|
||||
rb_define_method(rb_cString, "to_i", rb_str_to_i, 0);
|
||||
rb_define_method(rb_cString, "to_f", rb_str_to_f, 0);
|
||||
rb_define_method(rb_cString, "to_a", rb_str_to_a, 0);
|
||||
rb_define_method(rb_cString, "to_s", rb_str_to_s, 0);
|
||||
rb_define_method(rb_cString, "to_str", rb_str_to_s, 0);
|
||||
rb_define_method(rb_cString, "inspect", rb_str_inspect, 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define RUBY_VERSION "1.5.0"
|
||||
#define RUBY_RELEASE_DATE "2000-01-08"
|
||||
#define RUBY_VERSION_CODE 150
|
||||
#define RUBY_RELEASE_CODE 20000108
|
||||
#define RUBY_VERSION "1.5.2"
|
||||
#define RUBY_RELEASE_DATE "2000-01-17"
|
||||
#define RUBY_VERSION_CODE 152
|
||||
#define RUBY_RELEASE_CODE 20000117
|
||||
|
|
Loading…
Reference in a new issue