зеркало из https://github.com/github/ruby.git
* eval.c (is_defined): defined?(Foo::Baz) should check constants
only, no methods. * eval.c (is_defined): should not dump core on defined?(a::b) where a is not a class nor a module. * object.c (Init_Object): remove dup and clone from TrueClass, FalseClass, and NilClass. * array.c (rb_ary_fill): Array#fill takes block to get the value to fill. * string.c (rb_str_to_i): to_i(0) auto-detects base radix. * array.c (rb_ary_initialize): fill by the block evaluation value if block is given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ae6afaaedb
Коммит
4f38c453b4
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
Mon Jan 28 13:29:41 2002 K.Kosako <kosako@sofnec.co.jp>
|
||||
|
||||
* eval.c (is_defined): defined?(Foo::Baz) should check constants
|
||||
only, no methods.
|
||||
|
||||
* eval.c (is_defined): should not dump core on defined?(a::b)
|
||||
where a is not a class nor a module.
|
||||
|
||||
Mon Jan 28 02:50:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* object.c (Init_Object): remove dup and clone from TrueClass,
|
||||
FalseClass, and NilClass.
|
||||
|
||||
* array.c (rb_ary_fill): Array#fill takes block to get the value to
|
||||
fill.
|
||||
|
||||
Sat Jan 26 20:05:18 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_to_i): to_i(0) auto-detects base radix.
|
||||
|
||||
* array.c (rb_ary_initialize): fill by the block evaluation value
|
||||
if block is given.
|
||||
|
||||
Fri Jan 25 17:48:43 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||
|
||||
* configure.in (solaris): add '-shared' only for GNU ld.
|
||||
|
|
54
array.c
54
array.c
|
@ -228,12 +228,18 @@ rb_ary_initialize(argc, argv, ary)
|
|||
rb_ary_modify(ary);
|
||||
if (rb_scan_args(argc, argv, "02", &size, &val) == 0) {
|
||||
RARRAY(ary)->len = 0;
|
||||
if (rb_block_given_p()) {
|
||||
rb_warning("given block not used");
|
||||
}
|
||||
return ary;
|
||||
}
|
||||
|
||||
if (argc == 1 && !FIXNUM_P(size) && rb_respond_to(size, rb_intern("to_ary"))) {
|
||||
rb_ary_replace(ary, rb_convert_type(size, T_ARRAY, "Array", "to_ary"));
|
||||
return ary;
|
||||
if (argc == 1 && !FIXNUM_P(size)) {
|
||||
val = rb_check_convert_type(size, T_ARRAY, "Array", "to_ary");
|
||||
if (!NIL_P(val)) {
|
||||
rb_ary_replace(ary, val);
|
||||
return ary;
|
||||
}
|
||||
}
|
||||
|
||||
len = NUM2LONG(size);
|
||||
|
@ -247,8 +253,21 @@ rb_ary_initialize(argc, argv, ary)
|
|||
RARRAY(ary)->aux.capa = len;
|
||||
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->aux.capa);
|
||||
}
|
||||
memfill(RARRAY(ary)->ptr, len, val);
|
||||
RARRAY(ary)->len = len;
|
||||
if (rb_block_given_p()) {
|
||||
long i;
|
||||
|
||||
if (argc > 1) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
for (i=0; i<len; i++) {
|
||||
RARRAY(ary)->ptr[i] = rb_yield(INT2NUM(i));
|
||||
RARRAY(ary)->len = i+1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
memfill(RARRAY(ary)->ptr, len, val);
|
||||
RARRAY(ary)->len = len;
|
||||
}
|
||||
|
||||
return ary;
|
||||
}
|
||||
|
@ -1343,6 +1362,7 @@ static VALUE
|
|||
rb_ary_replace(ary, ary2)
|
||||
VALUE ary, ary2;
|
||||
{
|
||||
if (ary == ary2) return ary;
|
||||
ary2 = to_ary(ary2);
|
||||
rb_ary_update(ary, 0, RARRAY(ary)->len, ary2);
|
||||
return ary;
|
||||
|
@ -1370,12 +1390,20 @@ rb_ary_fill(argc, argv, ary)
|
|||
VALUE item, arg1, arg2;
|
||||
long beg, end, len;
|
||||
VALUE *p, *pend;
|
||||
int block_p;
|
||||
|
||||
rb_scan_args(argc, argv, "12", &item, &arg1, &arg2);
|
||||
if (rb_block_given_p()) {
|
||||
block_p = Qtrue;
|
||||
rb_scan_args(argc, argv, "02", &arg1, &arg2);
|
||||
argc += 1; /* hackish */
|
||||
}
|
||||
else {
|
||||
rb_scan_args(argc, argv, "12", &item, &arg1, &arg2);
|
||||
}
|
||||
switch (argc) {
|
||||
case 1:
|
||||
beg = 0;
|
||||
len = RARRAY(ary)->len - beg;
|
||||
len = RARRAY(ary)->len;
|
||||
break;
|
||||
case 2:
|
||||
if (rb_range_beg_len(arg1, &beg, &len, RARRAY(ary)->len, 1)) {
|
||||
|
@ -1405,8 +1433,16 @@ rb_ary_fill(argc, argv, ary)
|
|||
}
|
||||
p = RARRAY(ary)->ptr + beg; pend = p + len;
|
||||
|
||||
while (p < pend) {
|
||||
*p++ = item;
|
||||
if (block_p) {
|
||||
while (p < pend) {
|
||||
*p++ = rb_yield(INT2NUM(beg));
|
||||
beg++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (p < pend) {
|
||||
*p++ = item;
|
||||
}
|
||||
}
|
||||
return ary;
|
||||
}
|
||||
|
|
8
doc/NEWS
8
doc/NEWS
|
@ -1,3 +1,11 @@
|
|||
: Array#fill
|
||||
|
||||
takes block to get the values to fill.
|
||||
|
||||
: Array#new
|
||||
|
||||
takes block to get the values to fill.
|
||||
|
||||
: Array#fetch
|
||||
|
||||
takes block to get the default value.
|
||||
|
|
5
eval.c
5
eval.c
|
@ -1934,8 +1934,9 @@ is_defined(self, node, buf)
|
|||
case T_MODULE:
|
||||
if (rb_const_defined_at(val, node->nd_mid))
|
||||
return "constant";
|
||||
break;
|
||||
default:
|
||||
if (rb_method_boundp(val, node->nd_mid, 1)) {
|
||||
if (rb_method_boundp(CLASS_OF(val), node->nd_mid, 1)) {
|
||||
return "method";
|
||||
}
|
||||
}
|
||||
|
@ -2937,7 +2938,7 @@ rb_eval(self, n)
|
|||
default:
|
||||
return rb_funcall(klass, node->nd_mid, 0, 0);
|
||||
}
|
||||
result = rb_const_get_at(klass, node->nd_mid);
|
||||
result = rb_const_get(klass, node->nd_mid);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -433,7 +433,7 @@ pty_getpty(argc, argv, self)
|
|||
rfptr->f = fdopen(info.fd, "r");
|
||||
rfptr->path = strdup(SlaveName);
|
||||
|
||||
wfptr->mode = rb_io_mode_flags("w");
|
||||
wfptr->mode = rb_io_mode_flags("w") | FMODE_SYNC;
|
||||
wfptr->f = fdopen(dup(info.fd), "w");
|
||||
wfptr->path = strdup(SlaveName);
|
||||
|
||||
|
|
|
@ -93,7 +93,6 @@ module TkComm
|
|||
brace -= 1 if c == ?}
|
||||
break if brace == 0
|
||||
}
|
||||
p str[0,i]
|
||||
if str[0, i] == ' '
|
||||
list.push ' '
|
||||
else
|
||||
|
@ -1318,7 +1317,7 @@ class TkVariable
|
|||
opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
|
||||
idx = -1
|
||||
newopts = ''
|
||||
@trace_var.each_with_index{|i,e|
|
||||
@trace_var.each_with_index{|e,i|
|
||||
if idx < 0 && e[0] == opts && e[1] == cmd
|
||||
idx = i
|
||||
next
|
||||
|
@ -1352,7 +1351,7 @@ class TkVariable
|
|||
return unless @trace_elem[elem].kind_of? Array
|
||||
opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
|
||||
idx = -1
|
||||
@trace_elem[elem].each_with_index{|i,e|
|
||||
@trace_elem[elem].each_with_index{|e,i|
|
||||
if idx < 0 && e[0] == opts && e[1] == cmd
|
||||
idx = i
|
||||
next
|
||||
|
|
|
@ -173,8 +173,8 @@ class TkFont
|
|||
TkFont.new(nil, nil).call_font_configure(path, *(args + [{}]))
|
||||
else
|
||||
begin
|
||||
compound = Hash[*list(tk_call('font', 'configure',
|
||||
fnt))].collect{|key,value|
|
||||
compound = Hash[*tk_split_simplelist(tk_call('font', 'configure',
|
||||
fnt))].collect{|key,value|
|
||||
[key[1..-1], value]
|
||||
}.assoc('compound')[1]
|
||||
rescue
|
||||
|
|
|
@ -813,12 +813,20 @@ class TkTextMark<TkObject
|
|||
tk_call @t.path, 'mark', 'gravity', @id, direction
|
||||
end
|
||||
|
||||
def next(index)
|
||||
@t.tagid2obj(tk_call(@t.path, 'mark', 'next', index))
|
||||
def next(index = nil)
|
||||
if index
|
||||
@t.tagid2obj(tk_call(@t.path, 'mark', 'next', index))
|
||||
else
|
||||
@t.tagid2obj(tk_call(@t.path, 'mark', 'next', @id))
|
||||
end
|
||||
end
|
||||
|
||||
def previous(index)
|
||||
@t.tagid2obj(tk_call(@t.path, 'mark', 'previous', index))
|
||||
def previous(index = nil)
|
||||
if index
|
||||
@t.tagid2obj(tk_call(@t.path, 'mark', 'previous', index))
|
||||
else
|
||||
@t.tagid2obj(tk_call(@t.path, 'mark', 'previous', @id))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
4
hash.c
4
hash.c
|
@ -201,8 +201,8 @@ rb_hash_initialize(argc, argv, hash)
|
|||
|
||||
rb_hash_modify(hash);
|
||||
if (rb_block_given_p()) {
|
||||
if (argc > 1) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments", argc);
|
||||
if (argc > 0) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
RHASH(hash)->ifnone = rb_f_lambda();
|
||||
FL_SET(hash, HASH_PROC_DEFAULT);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
# that the Singleton pattern is properly inherited.
|
||||
#
|
||||
# In addition Klass is provided with the class methods
|
||||
# * Klass.instance() - returning ``the instance''
|
||||
# * Klass.instance() - returning ``the instance''
|
||||
# * Klass._load(str) - returning ``the instance''
|
||||
# * Klass._wait() - a hook method putting a second (or n-th)
|
||||
# thread calling Klass.instance on a waiting loop if the first call
|
||||
|
@ -43,6 +43,7 @@
|
|||
# _dump(depth) and _load(str) method allows the (partial) resurrection
|
||||
# of a previous state of ``the instance'' - see third example.
|
||||
#
|
||||
|
||||
module Singleton
|
||||
def Singleton.included (klass)
|
||||
# should this be checked?
|
||||
|
|
6
object.c
6
object.c
|
@ -1239,6 +1239,8 @@ Init_Object()
|
|||
rb_define_method(rb_cNilClass, "&", false_and, 1);
|
||||
rb_define_method(rb_cNilClass, "|", false_or, 1);
|
||||
rb_define_method(rb_cNilClass, "^", false_xor, 1);
|
||||
rb_undef_method(rb_cNilClass, "clone");
|
||||
rb_undef_method(rb_cNilClass, "dup");
|
||||
|
||||
rb_define_method(rb_cNilClass, "nil?", rb_true, 0);
|
||||
rb_undef_method(CLASS_OF(rb_cNilClass), "allocate");
|
||||
|
@ -1314,6 +1316,8 @@ Init_Object()
|
|||
rb_define_method(rb_cTrueClass, "^", true_xor, 1);
|
||||
rb_undef_method(CLASS_OF(rb_cTrueClass), "allocate");
|
||||
rb_undef_method(CLASS_OF(rb_cTrueClass), "new");
|
||||
rb_undef_method(rb_cTrueClass, "clone");
|
||||
rb_undef_method(rb_cTrueClass, "dup");
|
||||
rb_define_global_const("TRUE", Qtrue);
|
||||
|
||||
rb_cFalseClass = rb_define_class("FalseClass", rb_cObject);
|
||||
|
@ -1323,6 +1327,8 @@ Init_Object()
|
|||
rb_define_method(rb_cFalseClass, "^", false_xor, 1);
|
||||
rb_undef_method(CLASS_OF(rb_cFalseClass), "allocate");
|
||||
rb_undef_method(CLASS_OF(rb_cFalseClass), "new");
|
||||
rb_undef_method(rb_cFalseClass, "clone");
|
||||
rb_undef_method(rb_cFalseClass, "dup");
|
||||
rb_define_global_const("FALSE", Qfalse);
|
||||
|
||||
eq = rb_intern("==");
|
||||
|
|
2
parse.y
2
parse.y
|
@ -1142,7 +1142,7 @@ call_args2 : arg ',' args opt_block_arg
|
|||
{
|
||||
value_expr($1);
|
||||
value_expr($6);
|
||||
$$ = list_append(list_concat($1,$3), NEW_HASH($5));
|
||||
$$ = list_append(list_concat(NEW_LIST($1),$3), NEW_HASH($5));
|
||||
$$ = arg_blk_pass($$, $6);
|
||||
}
|
||||
| arg ',' assocs ',' tSTAR arg opt_block_arg
|
||||
|
|
2
string.c
2
string.c
|
@ -1761,7 +1761,7 @@ rb_str_to_i(argc, argv, str)
|
|||
else base = NUM2INT(b);
|
||||
|
||||
switch (base) {
|
||||
case 2: case 8: case 10: case 16:
|
||||
case 0: case 2: case 8: case 10: case 16:
|
||||
break;
|
||||
default:
|
||||
rb_raise(rb_eArgError, "illegal radix %d", base);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define RUBY_VERSION "1.7.2"
|
||||
#define RUBY_RELEASE_DATE "2002-01-25"
|
||||
#define RUBY_RELEASE_DATE "2002-01-28"
|
||||
#define RUBY_VERSION_CODE 172
|
||||
#define RUBY_RELEASE_CODE 20020125
|
||||
#define RUBY_RELEASE_CODE 20020128
|
||||
|
|
Загрузка…
Ссылка в новой задаче