summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--enum.c4
-rw-r--r--eval.c18
-rw-r--r--gc.c4
-rw-r--r--lib/cgi.rb6
-rw-r--r--lib/singleton.rb10
-rw-r--r--ruby.h1
-rw-r--r--string.c2
8 files changed, 41 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 30b84fd..24669e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Fri Aug 22 17:07:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (inject_i): use rb_yield_values.
+
+ * enum.c (each_with_index_i): ditto.
+
+ * eval.c (rb_yield_splat): new function to call "yield *values".
+
+ * string.c (rb_str_scan): use rb_yield_splat().
+
Fri Aug 22 06:13:22 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
* ext/syck/rubyext.c: refactoring of the transfer method
diff --git a/enum.c b/enum.c
index 71b2e7e..ac27757 100644
--- a/enum.c
+++ b/enum.c
@@ -187,7 +187,7 @@ inject_i(i, memo)
memo->u1.value = i;
}
else {
- memo->u1.value = rb_yield(rb_assoc_new(memo->u1.value, i));
+ memo->u1.value = rb_yield_values(2, memo->u1.value, i);
}
return Qnil;
}
@@ -499,7 +499,7 @@ each_with_index_i(val, memo)
VALUE val;
NODE *memo;
{
- rb_yield(rb_assoc_new(val, INT2FIX(memo->u3.cnt)));
+ rb_yield_values(val, INT2FIX(memo->u3.cnt));
memo->u3.cnt++;
return Qnil;
}
diff --git a/eval.c b/eval.c
index 6612bac..a82d294 100644
--- a/eval.c
+++ b/eval.c
@@ -4230,7 +4230,7 @@ VALUE
#ifdef HAVE_STDARG_PROTOTYPES
rb_yield_values(int n, ...)
#else
-rb_yield_values(int n, va_alist)
+rb_yield_values(n, va_alist)
int n;
va_dcl
#endif
@@ -4250,6 +4250,16 @@ rb_yield_values(int n, va_alist)
return rb_yield_0(ary, 0, 0, Qfalse, Qtrue);
}
+VALUE
+rb_yield_splat(values)
+ VALUE values;
+{
+ if (RARRAY(value)->len == 0) {
+ return rb_yield_0(Qundef, 0, 0, Qfalse, Qfalse);
+ }
+ return rb_yield_0(values, 0, 0, Qfalse, Qtrue);
+}
+
static VALUE
rb_f_loop()
{
@@ -9375,7 +9385,7 @@ rb_thread_start_0(fn, arg, th_arg)
{
volatile rb_thread_t th = th_arg;
volatile VALUE thread = th->thread;
- struct BLOCK* saved_block = 0;
+ volatile struct BLOCK* saved_block = 0;
enum thread_status status;
int state;
@@ -9434,12 +9444,12 @@ rb_thread_start_0(fn, arg, th_arg)
rb_thread_remove(th);
while (saved_block) {
- struct BLOCK *tmp = saved_block;
+ volatile struct BLOCK *tmp = saved_block;
if (tmp->frame.argc > 0)
free(tmp->frame.argv);
saved_block = tmp->prev;
- free(tmp);
+ free((void*)tmp);
}
if (state && status != THREAD_TO_KILL && !NIL_P(ruby_errinfo)) {
diff --git a/gc.c b/gc.c
index 1024c1a..613ad6d 100644
--- a/gc.c
+++ b/gc.c
@@ -1636,10 +1636,10 @@ id2ref(obj, id)
}
ptr = id ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */
- if (!is_pointer_to_heap((void *)ptr)) {
+ if (!is_pointer_to_heap((void *)ptr)|| BUILTIN_TYPE(ptr) >= T_BLKTAG) {
rb_raise(rb_eRangeError, "0x%lx is not id value", p0);
}
- if (RBASIC(ptr)->klass == 0) {
+ if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0) {
rb_raise(rb_eRangeError, "0x%lx is recycled object", p0);
}
return (VALUE)ptr;
diff --git a/lib/cgi.rb b/lib/cgi.rb
index ee315cc..27dd83d 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -973,7 +973,7 @@ class CGI
bufsize = 10 * 1024
# start multipart/form-data
- stdinput.binmode
+ stdinput.binmode if defined? stdinput.binmode
boundary_size = boundary.size + EOL.size
content_length -= boundary_size
status = stdinput.read(boundary_size)
@@ -997,7 +997,7 @@ class CGI
body = Tempfile.new("CGI")
end
end
- body.binmode
+ body.binmode if defined? body.binmode
until head and /#{boundary}(?:#{EOL}|--)/n.match(buf)
@@ -1123,7 +1123,7 @@ class CGI
env_table['QUERY_STRING'] or ""
end
when "POST"
- stdinput.binmode
+ stdinput.binmode if defined? stdinput.binmode
stdinput.read(Integer(env_table['CONTENT_LENGTH'])) or ''
else
read_from_cmdline
diff --git a/lib/singleton.rb b/lib/singleton.rb
index 30990b7..2954bfa 100644
--- a/lib/singleton.rb
+++ b/lib/singleton.rb
@@ -95,7 +95,10 @@ class << Singleton
@__instance__ = new
ensure
if @__instance__
- def self.instance; @__instance__ end
+ class <<self
+ remove_method :instance
+ def instance; @__instance__ end
+ end
else
@__instance__ = nil # failed instance creation
end
@@ -109,7 +112,10 @@ class << Singleton
@__instance__ = new
ensure
if @__instance__
- def self.instance; @__instance__ end
+ class <<self
+ remove_method :instance
+ def instance; @__instance__ end
+ end
else
@__instance__ = nil
end
diff --git a/ruby.h b/ruby.h
index cb617c4..16ef17e 100644
--- a/ruby.h
+++ b/ruby.h
@@ -537,6 +537,7 @@ void rb_warn __((const char*, ...)); /* reports always */
VALUE rb_each _((VALUE));
VALUE rb_yield _((VALUE));
VALUE rb_yield_values __((int n, ...));
+VALUE rb_yield_splat _((VALUE));
int rb_block_given_p _((void));
VALUE rb_iterate _((VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE));
VALUE rb_rescue _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
diff --git a/string.c b/string.c
index 248813e..f5be455 100644
--- a/string.c
+++ b/string.c
@@ -3066,7 +3066,7 @@ rb_str_scan(str, pat)
while (!NIL_P(result = scan_once(str, pat, &start))) {
match = rb_backref_get();
rb_match_busy(match);
- rb_yield(result);
+ rb_yield_splat(result);
rb_backref_set(match); /* restore $~ value */
}
rb_backref_set(match);