From f6348ca0eac1eb3fd89f1bce233204b096de3e98 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 29 Nov 2004 06:13:52 +0000 Subject: * object.c (convert_type): [ruby-core:03845] * eval.c (rb_funcall_rescue): new function. * object.c (rb_Array): avoid using rb_respond_to(). * object.c (rb_Integer): ditto. * eval.c (get_backtrace): no conversion for nil. * parse.y (reduce_nodes): empty body should return nil. * lib/cgi/session.rb (CGI::Session::initialize): [ruby-core:03832] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 18 +++++++++++++ eval.c | 69 ++++++++++++++++++++++++++++++++++++++--------- intern.h | 1 + lib/cgi/session.rb | 4 +-- lib/jcode.rb | 5 +++- object.c | 29 +++++++++----------- parse.y | 1 + string.c | 3 ++- test/ruby/beginmainend.rb | 5 ---- 9 files changed, 97 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3052d3e7c..7f3f78d7c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Mon Nov 29 03:08:30 2004 Yukihiro Matsumoto + + * object.c (convert_type): [ruby-core:03845] + + * eval.c (rb_funcall_rescue): new function. + + * object.c (rb_Array): avoid using rb_respond_to(). + + * object.c (rb_Integer): ditto. + + * parse.y (reduce_nodes): empty body should return nil. + + * string.c (rb_str_aset): [ruby-dev:24981] + Mon Nov 29 13:57:38 2004 NAKAMURA Usaku * win32/win32.c (CreateChild): search executable file if no program @@ -28,6 +42,10 @@ Sat Nov 27 21:43:39 2004 Tanaka Akira (rb_io_fwrite): wrapper for io_fwrite now. (io_write): call io_fwrite instead of rb_io_fwrite. +Sat Nov 27 14:44:15 2004 Kent Sibilev + + * lib/cgi/session.rb (CGI::Session::initialize): [ruby-core:03832] + Sat Nov 27 09:41:21 2004 Yukihiro Matsumoto * io.c (io_fread): old rb_io_fread with file closing checking. diff --git a/eval.c b/eval.c index a0c8e7b5fc..0e7059c39a 100644 --- a/eval.c +++ b/eval.c @@ -1077,7 +1077,9 @@ get_backtrace(info) VALUE info; { if (NIL_P(info)) return Qnil; - return rb_check_array_type(rb_funcall(info, rb_intern("backtrace"), 0)); + info = rb_funcall(info, rb_intern("backtrace"), 0); + if (NIL_P(info)) return Qnil; + return rb_check_array_type(info); } static void @@ -5789,18 +5791,13 @@ rb_f_send(argc, argv, recv) return vid; } -VALUE -#ifdef HAVE_STDARG_PROTOTYPES -rb_funcall(VALUE recv, ID mid, int n, ...) -#else -rb_funcall(recv, mid, n, va_alist) +static VALUE +vafuncall(recv, mid, n, ar) VALUE recv; ID mid; int n; - va_dcl -#endif + va_list *ar; { - va_list ar; VALUE *argv; if (n > 0) { @@ -5808,11 +5805,10 @@ rb_funcall(recv, mid, n, va_alist) argv = ALLOCA_N(VALUE, n); - va_init_list(ar, n); for (i=0;ivalue <= (double)FIXNUM_MAX @@ -2134,10 +2136,11 @@ rb_Integer(val) default: break; } - if (rb_respond_to(val, rb_intern("to_int"))) { - return rb_to_integer(val, "to_int"); + tmp = convert_type(val, "Integer", "to_int", Qfalse); + if (NIL_P(tmp)) { + return rb_to_integer(val, "to_i"); } - return rb_to_integer(val, "to_i"); + return tmp; } /* @@ -2379,18 +2382,10 @@ rb_Array(val) VALUE val; { VALUE tmp = rb_check_array_type(val); - ID to_a; if (NIL_P(tmp)) { - to_a = rb_intern("to_a"); - if (rb_respond_to(val, to_a)) { - val = rb_funcall(val, to_a, 0); - if (TYPE(val) != T_ARRAY) { - rb_raise(rb_eTypeError, "`to_a' did not return Array"); - } - return val; - } - else { + tmp = rb_check_convert_type(val, T_ARRAY, "Array", "to_a"); + if (NIL_P(tmp)) { return rb_ary_new3(1, val); } } diff --git a/parse.y b/parse.y index c4179fdc8b..a96c6fc006 100644 --- a/parse.y +++ b/parse.y @@ -1651,6 +1651,7 @@ primary : literal bodystmt kEND { + if (!$5) $5 = NEW_NIL(); $$ = NEW_DEFN($2, $4, $5, NOEX_PRIVATE); fixpos($$, $4); local_pop(); diff --git a/string.c b/string.c index 7416561e28..aac1f2bf6c 100644 --- a/string.c +++ b/string.c @@ -1386,7 +1386,7 @@ rb_str_succ(orig) int c = -1; long n = 0; - str = rb_str_new5(orig,RSTRING(orig)->ptr, RSTRING(orig)->len); + str = rb_str_new5(orig, RSTRING(orig)->ptr, RSTRING(orig)->len); OBJ_INFECT(str, orig); if (RSTRING(str)->len == 0) return str; @@ -1729,6 +1729,7 @@ rb_str_aset(str, indx, val) idx += RSTRING(str)->len; } if (FIXNUM_P(val)) { + rb_str_modify(str); if (RSTRING(str)->len == idx) { RSTRING(str)->len += 1; RESIZE_CAPA(str, RSTRING(str)->len); diff --git a/test/ruby/beginmainend.rb b/test/ruby/beginmainend.rb index f096b96fbc..646140dd22 100644 --- a/test/ruby/beginmainend.rb +++ b/test/ruby/beginmainend.rb @@ -28,11 +28,6 @@ END { puts local_for_end2 # e2 } -END { - raise - puts "should not be dumped" -} - eval <