summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-23 15:28:04 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-23 15:28:04 +0000
commit54956f6bd1c42500d1cf427a98f6d35cacbae83d (patch)
tree48b2b99f65e4c4bf3611e38198e691c2df6a17e0
parent1ae16961956c2459c0f29b676c5da9cb9cc875bf (diff)
add tag v1_8_7_299v1_8_7_299
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_7_299@28412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--marshal.c142
-rw-r--r--test/optparse/test_summary.rb6
-rw-r--r--test/ruby/test_marshal.rb28
-rw-r--r--version.h8
5 files changed, 88 insertions, 106 deletions
diff --git a/ChangeLog b/ChangeLog
index 83b7176bea..a91fd690ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Wed Jun 23 22:22:42 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * test/optparse/test_summary.rb: fixed superclass so that it run
+ solely.
+
+Wed Jun 23 21:54:17 2010 URABE Shyouhei <shyouhei@ruby-lang.org>
+
+ * marshal.c, test/ruby/test_marshal.rb: Revert r25230. This test
+ is troublesome.
+
Mon Jun 21 18:12:15 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/openssl/extconf.rb: check some functions added at OpenSSL 1.0.0.
diff --git a/marshal.c b/marshal.c
index 0112257c32..35e0d60374 100644
--- a/marshal.c
+++ b/marshal.c
@@ -85,10 +85,12 @@ static ID s_dump_data, s_load_data, s_alloc, s_call;
static ID s_getc, s_read, s_write, s_binmode;
struct dump_arg {
+ VALUE obj;
VALUE str, dest;
st_table *symbols;
st_table *data;
int taint;
+ VALUE wrapper;
};
struct dump_call_arg {
@@ -102,32 +104,22 @@ check_dump_arg(arg, sym)
struct dump_arg *arg;
ID sym;
{
- if (!arg->symbols) {
+ if (!DATA_PTR(arg->wrapper)) {
rb_raise(rb_eRuntimeError, "Marshal.dump reentered at %s",
rb_id2name(sym));
}
}
-static void clear_dump_arg _((struct dump_arg *arg));
-
static void
mark_dump_arg(ptr)
void *ptr;
{
struct dump_arg *p = ptr;
- if (!p->symbols)
+ if (!ptr)
return;
rb_mark_set(p->data);
}
-static void
-free_dump_arg(ptr)
- void *ptr;
-{
- clear_dump_arg(ptr);
- xfree(ptr);
-}
-
static VALUE
class2path(klass)
VALUE klass;
@@ -707,17 +699,32 @@ w_object(obj, arg, limit)
}
}
-static void
-clear_dump_arg(arg)
+static VALUE
+dump(arg)
+ struct dump_call_arg *arg;
+{
+ w_object(arg->obj, arg->arg, arg->limit);
+ if (arg->arg->dest) {
+ rb_io_write(arg->arg->dest, arg->arg->str);
+ rb_str_resize(arg->arg->str, 0);
+ }
+ return 0;
+}
+
+static VALUE
+dump_ensure(arg)
struct dump_arg *arg;
{
- if (!arg->symbols) return;
+ if (!DATA_PTR(arg->wrapper)) return 0;
st_free_table(arg->symbols);
- arg->symbols = 0;
st_free_table(arg->data);
+ DATA_PTR(arg->wrapper) = 0;
+ arg->wrapper = 0;
if (arg->taint) {
OBJ_TAINT(arg->str);
}
+
+ return 0;
}
/*
@@ -753,8 +760,8 @@ marshal_dump(argc, argv)
{
VALUE obj, port, a1, a2;
int limit = -1;
- struct dump_arg *arg;
- VALUE wrapper;
+ struct dump_arg arg;
+ struct dump_call_arg c_arg;
port = Qnil;
rb_scan_args(argc, argv, "12", &obj, &a1, &a2);
@@ -768,40 +775,37 @@ marshal_dump(argc, argv)
else if (NIL_P(a1)) goto type_error;
else port = a1;
}
- wrapper = Data_Make_Struct(rb_cData, struct dump_arg, mark_dump_arg, free_dump_arg, arg);
- arg->dest = 0;
- arg->symbols = st_init_numtable();
- arg->data = st_init_numtable();
- arg->taint = Qfalse;
- arg->str = rb_str_buf_new(0);
- RBASIC(arg->str)->klass = 0;
+ arg.dest = 0;
+ arg.symbols = st_init_numtable();
+ arg.data = st_init_numtable();
+ arg.taint = Qfalse;
+ arg.str = rb_str_buf_new(0);
+ RBASIC(arg.str)->klass = 0;
+ arg.wrapper = Data_Wrap_Struct(rb_cData, mark_dump_arg, 0, &arg);
if (!NIL_P(port)) {
if (!rb_respond_to(port, s_write)) {
type_error:
rb_raise(rb_eTypeError, "instance of IO needed");
}
- arg->dest = port;
+ arg.dest = port;
if (rb_respond_to(port, s_binmode)) {
rb_funcall2(port, s_binmode, 0, 0);
- check_dump_arg(arg, s_binmode);
+ check_dump_arg(&arg, s_binmode);
}
}
else {
- port = arg->str;
+ port = arg.str;
}
- w_byte(MARSHAL_MAJOR, arg);
- w_byte(MARSHAL_MINOR, arg);
+ c_arg.obj = obj;
+ c_arg.arg = &arg;
+ c_arg.limit = limit;
- w_object(obj, arg, limit);
- if (arg->dest) {
- rb_io_write(arg->dest, arg->str);
- rb_str_resize(arg->str, 0);
- }
+ w_byte(MARSHAL_MAJOR, &arg);
+ w_byte(MARSHAL_MINOR, &arg);
- RBASIC(arg->str)->klass = rb_cString;
- clear_dump_arg(arg);
- RB_GC_GUARD(wrapper);
+ rb_ensure(dump, (VALUE)&c_arg, dump_ensure, (VALUE)&arg);
+ RBASIC(arg.str)->klass = rb_cString;
return port;
}
@@ -813,6 +817,7 @@ struct load_arg {
st_table *data;
VALUE proc;
int taint;
+ VALUE wrapper;
};
static void
@@ -820,31 +825,22 @@ check_load_arg(arg, sym)
struct load_arg *arg;
ID sym;
{
- if (!arg->symbols) {
+ if (!DATA_PTR(arg->wrapper)) {
rb_raise(rb_eRuntimeError, "Marshal.load reentered at %s",
rb_id2name(sym));
}
}
-static void clear_load_arg _((struct load_arg *arg));
-
static void
mark_load_arg(ptr)
void *ptr;
{
struct load_arg *p = ptr;
- if (!p->symbols)
+ if (!ptr)
return;
rb_mark_tbl(p->data);
}
-static void
-free_load_arg(void *ptr)
-{
- clear_load_arg(ptr);
- xfree(ptr);
-}
-
static VALUE r_object _((struct load_arg *arg));
static int
@@ -1419,14 +1415,23 @@ r_object(arg)
return r_object0(arg, arg->proc, 0, Qnil);
}
-static void
-clear_load_arg(arg)
+static VALUE
+load(arg)
struct load_arg *arg;
{
- if (!arg->symbols) return;
+ return r_object(arg);
+}
+
+static VALUE
+load_ensure(arg)
+ struct load_arg *arg;
+{
+ if (!DATA_PTR(arg->wrapper)) return 0;
st_free_table(arg->symbols);
- arg->symbols = 0;
st_free_table(arg->data);
+ DATA_PTR(arg->wrapper) = 0;
+ arg->wrapper = 0;
+ return 0;
}
/*
@@ -1447,8 +1452,8 @@ marshal_load(argc, argv)
{
VALUE port, proc;
int major, minor, taint = Qfalse;
- VALUE v, wrapper;
- struct load_arg *arg;
+ VALUE v;
+ struct load_arg arg;
rb_scan_args(argc, argv, "11", &port, &proc);
v = rb_check_string_type(port);
@@ -1465,18 +1470,17 @@ marshal_load(argc, argv)
else {
rb_raise(rb_eTypeError, "instance of IO needed");
}
- wrapper = Data_Make_Struct(rb_cData, struct load_arg, mark_load_arg, free_load_arg, arg);
- arg->src = port;
- arg->offset = 0;
- arg->symbols = st_init_numtable();
- arg->data = st_init_numtable();
- arg->proc = 0;
- arg->taint = taint;
-
- major = r_byte(arg);
- minor = r_byte(arg);
+ arg.src = port;
+ arg.offset = 0;
+ arg.symbols = st_init_numtable();
+ arg.data = st_init_numtable();
+ arg.proc = 0;
+ arg.wrapper = Data_Wrap_Struct(rb_cData, mark_load_arg, 0, &arg);
+ arg.taint = taint;
+
+ major = r_byte(&arg);
+ minor = r_byte(&arg);
if (major != MARSHAL_MAJOR || minor > MARSHAL_MINOR) {
- clear_load_arg(arg);
rb_raise(rb_eTypeError, "incompatible marshal file format (can't be read)\n\
\tformat version %d.%d required; %d.%d given",
MARSHAL_MAJOR, MARSHAL_MINOR, major, minor);
@@ -1487,10 +1491,8 @@ marshal_load(argc, argv)
MARSHAL_MAJOR, MARSHAL_MINOR, major, minor);
}
- if (!NIL_P(proc)) arg->proc = proc;
- v = r_object(arg);
- clear_load_arg(arg);
- RB_GC_GUARD(wrapper);
+ if (!NIL_P(proc)) arg.proc = proc;
+ v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg);
return v;
}
diff --git a/test/optparse/test_summary.rb b/test/optparse/test_summary.rb
index 12744a8a7b..bd533e6444 100644
--- a/test/optparse/test_summary.rb
+++ b/test/optparse/test_summary.rb
@@ -1,8 +1,6 @@
-require 'test/unit'
-require 'optparse'
+require 'test_optparse'
-class TestOptionParser < Test::Unit::TestCase; end
-class TestOptionParser::SummaryTest < Test::Unit::TestCase
+class TestOptionParser::SummaryTest < TestOptionParser
def test_short_clash
r = nil
o = OptionParser.new do |opts|
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index d40c9da4d4..5ae521e4f6 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -72,34 +72,6 @@ class TestMarshal < Test::Unit::TestCase
assert_equal("marshal data too short", e.message)
end
- class DumpTest
- def marshal_dump
- loop { Thread.pass }
- end
- end
-
- class LoadTest
- def marshal_dump
- nil
- end
- def marshal_load(obj)
- loop { Thread.pass }
- end
- end
-
- def test_context_switch
- o = DumpTest.new
- Thread.new { Marshal.dump(o) }
- GC.start
- assert(true, '[ruby-dev:39425]')
-
- o = LoadTest.new
- m = Marshal.dump(o)
- Thread.new { Marshal.load(m) }
- GC.start
- assert(true, '[ruby-dev:39425]')
- end
-
def test_taint
x = Object.new
x.taint
diff --git a/version.h b/version.h
index 607d9cbbb2..33ed4c3149 100644
--- a/version.h
+++ b/version.h
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2010-06-21"
+#define RUBY_RELEASE_DATE "2010-06-23"
#define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20100621
-#define RUBY_PATCHLEVEL 297
+#define RUBY_RELEASE_CODE 20100623
+#define RUBY_PATCHLEVEL 299
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_YEAR 2010
#define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 21
+#define RUBY_RELEASE_DAY 23
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];