summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--eval.c69
-rw-r--r--intern.h1
-rw-r--r--lib/cgi/session.rb4
-rw-r--r--lib/jcode.rb5
-rw-r--r--object.c29
-rw-r--r--parse.y1
-rw-r--r--string.c3
-rw-r--r--test/ruby/beginmainend.rb5
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 <matz@ruby-lang.org>
+
+ * 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 <usa@ruby-lang.org>
* win32/win32.c (CreateChild): search executable file if no program
@@ -28,6 +42,10 @@ Sat Nov 27 21:43:39 2004 Tanaka Akira <akr@m17n.org>
(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 <ksibilev@bellsouth.net>
+
+ * lib/cgi/session.rb (CGI::Session::initialize): [ruby-core:03832]
+
Sat Nov 27 09:41:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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;i<n;i++) {
- argv[i] = va_arg(ar, VALUE);
+ argv[i] = va_arg(*ar, VALUE);
}
- va_end(ar);
+ va_end(*ar);
}
else {
argv = 0;
@@ -5822,6 +5818,55 @@ rb_funcall(recv, mid, n, va_alist)
}
VALUE
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_funcall(VALUE recv, ID mid, int n, ...)
+#else
+rb_funcall(recv, mid, n, va_alist)
+ VALUE recv;
+ ID mid;
+ int n;
+ va_dcl
+#endif
+{
+ va_list ar;
+ va_init_list(ar, n);
+
+ return vafuncall(recv, mid, n, &ar);
+}
+
+VALUE
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_funcall_rescue(VALUE recv, ID mid, int n, ...)
+#else
+rb_funcall_rescue(recv, mid, n, va_alist)
+ VALUE recv;
+ ID mid;
+ int n;
+ va_dcl
+#endif
+{
+ VALUE result = Qnil; /* OK */
+ int status;
+ va_list ar;
+
+ va_init_list(ar, n);
+
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ result = vafuncall(recv, mid, n, &ar);
+ }
+ POP_TAG();
+ switch (status) {
+ case 0:
+ return result;
+ case TAG_RAISE:
+ return Qundef;
+ default:
+ JUMP_TAG(status);
+ }
+}
+
+VALUE
rb_funcall2(recv, mid, argc, argv)
VALUE recv;
ID mid;
diff --git a/intern.h b/intern.h
index f97afade46..4894c51655 100644
--- a/intern.h
+++ b/intern.h
@@ -217,6 +217,7 @@ VALUE rb_thread_main _((void));
VALUE rb_thread_local_aref _((VALUE, ID));
VALUE rb_thread_local_aset _((VALUE, ID, VALUE));
void rb_thread_atfork _((void));
+VALUE rb_funcall_rescue __((VALUE, ID, int, ...));
/* file.c */
int eaccess _((const char*, int));
VALUE rb_file_s_expand_path _((int, VALUE *));
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 0342f84d84..1c493546f6 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -246,7 +246,7 @@ class CGI
id = option['session_id']
unless id
if option['new_session']
- id = Session::create_new_id
+ id = create_new_id
end
end
unless id
@@ -261,7 +261,7 @@ class CGI
if option.key?('new_session') and not option['new_session']
raise ArgumentError, "session_key `%s' should be supplied"%session_key
end
- id = Session::create_new_id
+ id = create_new_id
end
end
@session_id = id
diff --git a/lib/jcode.rb b/lib/jcode.rb
index 8cd770be26..efb21af331 100644
--- a/lib/jcode.rb
+++ b/lib/jcode.rb
@@ -90,7 +90,10 @@ class String
end
def succ
- (str = self.dup).succ! or str
+ str = self.dup
+ p [self.object_id, str.object_id]
+ str.succ! or str
+# (str = self.dup).succ! or str
end
private
diff --git a/object.c b/object.c
index 5fd722b338..1a54739d05 100644
--- a/object.c
+++ b/object.c
@@ -2036,10 +2036,9 @@ convert_type(val, tname, method, raise)
const char *tname, *method;
int raise;
{
- ID m;
+ VALUE result = rb_funcall_rescue(val, rb_intern(method), 0);
- m = rb_intern(method);
- if (!rb_respond_to(val, m)) {
+ if (result == Qundef) {
if (raise) {
rb_raise(rb_eTypeError, "cannot convert %s into %s",
NIL_P(val) ? "nil" :
@@ -2049,10 +2048,11 @@ convert_type(val, tname, method, raise)
tname);
}
else {
+ ruby_errinfo = Qnil;
return Qnil;
}
}
- return rb_funcall(val, m, 0);
+ return result;
}
VALUE
@@ -2116,6 +2116,8 @@ VALUE
rb_Integer(val)
VALUE val;
{
+ VALUE tmp;
+
switch (TYPE(val)) {
case T_FLOAT:
if (RFLOAT(val)->value <= (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 <<EOE
BEGIN {
puts "b3"