mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c: RDoc update for =~ method. a patch from Alex Young
<alex at blackkettle.org>. [ruby-core:08068] * io.c (pipe_open): backout unnecessary fix on 2006-06-26. [ruby-dev:28865] * eval.c (rb_yield_0): exact argument number check now done only for lambda Proc. * eval.c (rb_yield_0): add check for number of arguments, if there's one lambda block parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3b989706df
commit
471e41ec70
5 changed files with 51 additions and 31 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Jun 27 23:03:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c: RDoc update for =~ method. a patch from Alex Young
|
||||||
|
<alex at blackkettle.org>. [ruby-core:08068]
|
||||||
|
|
||||||
Tue Jun 27 22:47:18 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
Tue Jun 27 22:47:18 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
* ext/tk/tcltklib.c: forgot to update TCLTKLIB_RELEASE_DATE.
|
* ext/tk/tcltklib.c: forgot to update TCLTKLIB_RELEASE_DATE.
|
||||||
|
@ -5,6 +10,17 @@ Tue Jun 27 22:47:18 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
* ext/tk/lib/tk.rb (tk_tcl2ruby): [bug fix] somtimes fail to convert
|
* ext/tk/lib/tk.rb (tk_tcl2ruby): [bug fix] somtimes fail to convert
|
||||||
a tcl string to a ruby object if the tcl string includes "\n".
|
a tcl string to a ruby object if the tcl string includes "\n".
|
||||||
|
|
||||||
|
Tue Jun 27 20:05:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (pipe_open): backout unnecessary fix on 2006-06-26.
|
||||||
|
[ruby-dev:28865]
|
||||||
|
|
||||||
|
* eval.c (rb_yield_0): exact argument number check now done only
|
||||||
|
for lambda Proc.
|
||||||
|
|
||||||
|
* eval.c (rb_yield_0): add check for number of arguments, if
|
||||||
|
there's one lambda block parameter.
|
||||||
|
|
||||||
Tue Jun 27 16:04:05 2006 WATANABE Hirofumi <eban@ruby-lang.org>
|
Tue Jun 27 16:04:05 2006 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* win32/win32.h: define isascii on MinGW for msvcrt compatibility.
|
* win32/win32.h: define isascii on MinGW for msvcrt compatibility.
|
||||||
|
|
47
eval.c
47
eval.c
|
@ -1047,7 +1047,7 @@ static NODE *compile(VALUE, const char*, int);
|
||||||
|
|
||||||
static VALUE rb_yield_0(VALUE, VALUE, VALUE, int);
|
static VALUE rb_yield_0(VALUE, VALUE, VALUE, int);
|
||||||
|
|
||||||
#define YIELD_EXACT_ARGS 1
|
#define YIELD_ARY_ARGS 1
|
||||||
#define YIELD_PUBLIC_DEF 4
|
#define YIELD_PUBLIC_DEF 4
|
||||||
#define YIELD_FUNC_AVALUE 1
|
#define YIELD_FUNC_AVALUE 1
|
||||||
#define YIELD_FUNC_SVALUE 2
|
#define YIELD_FUNC_SVALUE 2
|
||||||
|
@ -4667,7 +4667,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags)
|
||||||
int old_vmode;
|
int old_vmode;
|
||||||
struct FRAME frame;
|
struct FRAME frame;
|
||||||
NODE *cnode = ruby_current_node;
|
NODE *cnode = ruby_current_node;
|
||||||
int pcall = flags & YIELD_EXACT_ARGS, lambda;
|
int ary_args = flags & YIELD_ARY_ARGS, lambda;
|
||||||
int state, broken = 0;
|
int state, broken = 0;
|
||||||
|
|
||||||
rb_need_block();
|
rb_need_block();
|
||||||
|
@ -4701,16 +4701,20 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags)
|
||||||
node = block->body;
|
node = block->body;
|
||||||
var = block->var;
|
var = block->var;
|
||||||
lambda = block->flags & BLOCK_LAMBDA;
|
lambda = block->flags & BLOCK_LAMBDA;
|
||||||
|
|
||||||
if (var) {
|
if (var) {
|
||||||
PUSH_TAG(PROT_NONE);
|
PUSH_TAG(PROT_NONE);
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
NODE *bvar = NULL;
|
NODE *bvar = NULL;
|
||||||
block_var:
|
block_var:
|
||||||
if (var == (NODE*)1) { /* no parameter || */
|
if (var == (NODE*)1) { /* no parameter || */
|
||||||
if (pcall && RARRAY(val)->len != 0) {
|
if (lambda && val != Qundef) {
|
||||||
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
|
if (TYPE(val) != T_ARRAY) {
|
||||||
RARRAY(val)->len);
|
rb_raise(rb_eArgError, "wrong number of arguments (1 for 0)");
|
||||||
|
}
|
||||||
|
else if (RARRAY(val)->len != 0) {
|
||||||
|
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
|
||||||
|
RARRAY(val)->len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (var == (NODE*)2) {
|
else if (var == (NODE*)2) {
|
||||||
|
@ -4725,7 +4729,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags)
|
||||||
goto block_var;
|
goto block_var;
|
||||||
}
|
}
|
||||||
else if (nd_type(var) == NODE_ARGS) {
|
else if (nd_type(var) == NODE_ARGS) {
|
||||||
val = svalue_to_avalue(val);
|
if (!ary_args) val = svalue_to_avalue(val);
|
||||||
formal_assign(self, var, RARRAY(val)->len, RARRAY(val)->ptr, 0);
|
formal_assign(self, var, RARRAY(val)->len, RARRAY(val)->ptr, 0);
|
||||||
}
|
}
|
||||||
else if (nd_type(var) == NODE_BLOCK) {
|
else if (nd_type(var) == NODE_BLOCK) {
|
||||||
|
@ -4736,16 +4740,25 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags)
|
||||||
goto block_var;
|
goto block_var;
|
||||||
}
|
}
|
||||||
else if (nd_type(var) == NODE_MASGN) {
|
else if (nd_type(var) == NODE_MASGN) {
|
||||||
massign(self, var, val, pcall);
|
massign(self, var, val, lambda);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (pcall) {
|
if (lambda) {
|
||||||
if (RARRAY(val)->len == 0)
|
if (val == Qundef) {
|
||||||
val = Qnil;
|
rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
|
||||||
else
|
}
|
||||||
val = RARRAY(val)->ptr[0];
|
if (TYPE(val) == T_ARRAY && RARRAY(val)->len != 1) {
|
||||||
|
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 1)",
|
||||||
|
RARRAY(val)->len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assign(self, var, val, pcall);
|
if (ary_args) {
|
||||||
|
if (RARRAY(val)->len == 0)
|
||||||
|
val = Qnil;
|
||||||
|
else
|
||||||
|
val = RARRAY(val)->ptr[0];
|
||||||
|
}
|
||||||
|
assign(self, var, val, lambda);
|
||||||
}
|
}
|
||||||
if (bvar) {
|
if (bvar) {
|
||||||
VALUE blk;
|
VALUE blk;
|
||||||
|
@ -4759,7 +4772,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags)
|
||||||
POP_TAG();
|
POP_TAG();
|
||||||
if (state) goto pop_state;
|
if (state) goto pop_state;
|
||||||
}
|
}
|
||||||
else if (pcall && RARRAY(val)->len != 0 &&
|
else if (lambda && RARRAY(val)->len != 0 &&
|
||||||
(!node || nd_type(node) != NODE_IFUNC ||
|
(!node || nd_type(node) != NODE_IFUNC ||
|
||||||
node->nd_cfnc != bmcall)) {
|
node->nd_cfnc != bmcall)) {
|
||||||
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
|
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
|
||||||
|
@ -8357,7 +8370,7 @@ proc_invoke(VALUE proc, VALUE args /* OK */, VALUE self, VALUE klass, int call)
|
||||||
VALUE bvar = Qnil;
|
VALUE bvar = Qnil;
|
||||||
|
|
||||||
Data_Get_Struct(proc, struct BLOCK, data);
|
Data_Get_Struct(proc, struct BLOCK, data);
|
||||||
pcall = call ? YIELD_EXACT_ARGS : 0;
|
pcall = call ? YIELD_ARY_ARGS : 0;
|
||||||
lambda = data->flags & BLOCK_LAMBDA;
|
lambda = data->flags & BLOCK_LAMBDA;
|
||||||
if (rb_block_given_p() && ruby_frame->callee) {
|
if (rb_block_given_p() && ruby_frame->callee) {
|
||||||
if (klass != ruby_frame->this_class)
|
if (klass != ruby_frame->this_class)
|
||||||
|
@ -8481,7 +8494,7 @@ rb_proc_yield(int argc, VALUE *argv, VALUE proc)
|
||||||
{
|
{
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 0:
|
case 0:
|
||||||
return proc_invoke(proc, Qnil, Qundef, 0, 0);
|
return proc_invoke(proc, Qundef, Qundef, 0, 0);
|
||||||
case 1:
|
case 1:
|
||||||
return proc_invoke(proc, argv[0], Qundef, 0, 0);
|
return proc_invoke(proc, argv[0], Qundef, 0, 0);
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2927,8 +2927,7 @@ sock_accept_nonblock(sock)
|
||||||
* * Socket#accept
|
* * Socket#accept
|
||||||
*/
|
*/
|
||||||
static VALUE
|
static VALUE
|
||||||
sock_sysaccept(sock)
|
sock_sysaccept(VALUE sock)
|
||||||
VALUE sock;
|
|
||||||
{
|
{
|
||||||
OpenFile *fptr;
|
OpenFile *fptr;
|
||||||
VALUE sock2;
|
VALUE sock2;
|
||||||
|
|
10
io.c
10
io.c
|
@ -3029,14 +3029,8 @@ pipe_open(int argc, VALUE *argv, const char *mode)
|
||||||
/* parent */
|
/* parent */
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
int e = errno;
|
int e = errno;
|
||||||
if ((modef & FMODE_READABLE)) {
|
close(arg.pair[0]);
|
||||||
close(arg.pair[0]);
|
close(arg.pair[1]);
|
||||||
close(arg.pair[1]);
|
|
||||||
}
|
|
||||||
if ((modef & FMODE_WRITABLE)) {
|
|
||||||
close(arg.pair[0]);
|
|
||||||
close(arg.pair[1]);
|
|
||||||
}
|
|
||||||
errno = e;
|
errno = e;
|
||||||
rb_sys_fail(cmd);
|
rb_sys_fail(cmd);
|
||||||
}
|
}
|
||||||
|
|
6
string.c
6
string.c
|
@ -1241,13 +1241,11 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
|
||||||
* str =~ obj => fixnum or nil
|
* str =~ obj => fixnum or nil
|
||||||
*
|
*
|
||||||
* Match---If <i>obj</i> is a <code>Regexp</code>, use it as a pattern to match
|
* Match---If <i>obj</i> is a <code>Regexp</code>, use it as a pattern to match
|
||||||
* against <i>str</i>. If <i>obj</i> is a <code>String</code>, look for it in
|
* against <i>str</i>,and returns the position the match starts, or
|
||||||
* <i>str</i> (similar to <code>String#index</code>). Returns the position the
|
* <code>nil</code> if there is no match. Otherwise, invokes
|
||||||
* match starts, or <code>nil</code> if there is no match. Otherwise, invokes
|
|
||||||
* <i>obj.=~</i>, passing <i>str</i> as an argument. The default
|
* <i>obj.=~</i>, passing <i>str</i> as an argument. The default
|
||||||
* <code>=~</code> in <code>Object</code> returns <code>false</code>.
|
* <code>=~</code> in <code>Object</code> returns <code>false</code>.
|
||||||
*
|
*
|
||||||
* "cat o' 9 tails" =~ '\d' #=> nil
|
|
||||||
* "cat o' 9 tails" =~ /\d/ #=> 7
|
* "cat o' 9 tails" =~ /\d/ #=> 7
|
||||||
* "cat o' 9 tails" =~ 9 #=> false
|
* "cat o' 9 tails" =~ 9 #=> false
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue