diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-27 14:14:25 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-27 14:14:25 +0000 |
commit | 471e41ec70e18339f72539a6331dcf2fb80d2238 (patch) | |
tree | b14eab922eb09349c4016ee8e9591a3d8c7dbd3d | |
parent | 3b989706df0af7d7a3a042cd3470fcee90f208cf (diff) | |
download | ruby-471e41ec70e18339f72539a6331dcf2fb80d2238.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | eval.c | 47 | ||||
-rw-r--r-- | ext/socket/socket.c | 3 | ||||
-rw-r--r-- | io.c | 10 | ||||
-rw-r--r-- | string.c | 6 |
5 files changed, 51 insertions, 31 deletions
@@ -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> * 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 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> * win32/win32.h: define isascii on MinGW for msvcrt compatibility. @@ -1047,7 +1047,7 @@ static NODE *compile(VALUE, const char*, 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_FUNC_AVALUE 1 #define YIELD_FUNC_SVALUE 2 @@ -4667,7 +4667,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags) int old_vmode; struct FRAME frame; NODE *cnode = ruby_current_node; - int pcall = flags & YIELD_EXACT_ARGS, lambda; + int ary_args = flags & YIELD_ARY_ARGS, lambda; int state, broken = 0; rb_need_block(); @@ -4701,16 +4701,20 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags) node = block->body; var = block->var; lambda = block->flags & BLOCK_LAMBDA; - if (var) { PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { NODE *bvar = NULL; block_var: if (var == (NODE*)1) { /* no parameter || */ - if (pcall && RARRAY(val)->len != 0) { - rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)", - RARRAY(val)->len); + if (lambda && val != Qundef) { + if (TYPE(val) != T_ARRAY) { + 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) { @@ -4725,7 +4729,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags) goto block_var; } 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); } 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; } else if (nd_type(var) == NODE_MASGN) { - massign(self, var, val, pcall); + massign(self, var, val, lambda); } else { - if (pcall) { - if (RARRAY(val)->len == 0) - val = Qnil; - else - val = RARRAY(val)->ptr[0]; + if (lambda) { + if (val == Qundef) { + rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)"); + } + if (TYPE(val) == T_ARRAY && RARRAY(val)->len != 1) { + rb_raise(rb_eArgError, "wrong number of arguments (%ld for 1)", + RARRAY(val)->len); + } + } + if (ary_args) { + if (RARRAY(val)->len == 0) + val = Qnil; + else + val = RARRAY(val)->ptr[0]; } - assign(self, var, val, pcall); + assign(self, var, val, lambda); } if (bvar) { VALUE blk; @@ -4759,7 +4772,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags) POP_TAG(); 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_cfnc != bmcall)) { 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; Data_Get_Struct(proc, struct BLOCK, data); - pcall = call ? YIELD_EXACT_ARGS : 0; + pcall = call ? YIELD_ARY_ARGS : 0; lambda = data->flags & BLOCK_LAMBDA; if (rb_block_given_p() && ruby_frame->callee) { if (klass != ruby_frame->this_class) @@ -8481,7 +8494,7 @@ rb_proc_yield(int argc, VALUE *argv, VALUE proc) { switch (argc) { case 0: - return proc_invoke(proc, Qnil, Qundef, 0, 0); + return proc_invoke(proc, Qundef, Qundef, 0, 0); case 1: return proc_invoke(proc, argv[0], Qundef, 0, 0); default: diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 48f6cd033a..113b60c0cd 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -2927,8 +2927,7 @@ sock_accept_nonblock(sock) * * Socket#accept */ static VALUE -sock_sysaccept(sock) - VALUE sock; +sock_sysaccept(VALUE sock) { OpenFile *fptr; VALUE sock2; @@ -3029,14 +3029,8 @@ pipe_open(int argc, VALUE *argv, const char *mode) /* parent */ if (pid == -1) { int e = errno; - if ((modef & FMODE_READABLE)) { - close(arg.pair[0]); - close(arg.pair[1]); - } - if ((modef & FMODE_WRITABLE)) { - close(arg.pair[0]); - close(arg.pair[1]); - } + close(arg.pair[0]); + close(arg.pair[1]); errno = e; rb_sys_fail(cmd); } @@ -1241,13 +1241,11 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str) * str =~ obj => fixnum or nil * * 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 - * <i>str</i> (similar to <code>String#index</code>). Returns the position the - * match starts, or <code>nil</code> if there is no match. Otherwise, invokes + * against <i>str</i>,and returns the position the 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 * <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" =~ 9 #=> false */ |