summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--MANIFEST1
-rw-r--r--error.c29
-rw-r--r--eval.c1
-rw-r--r--gc.c2
-rw-r--r--lib/delegate.rb2
6 files changed, 32 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index c2738d0a65..8af4911d0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Wed May 21 17:44:16 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (syserr_initialize): prohibit specifying errno for
+ subclasses of SystemCallError. in addition, if initialize is
+ called for SystenCallError instance, its class be changed.
+ [ruby-dev:20257]
+
+ * gc.c (run_final): to protect thread context switch, finalizers
+ are wrapped in DEFER_INTS/ENABLE_INTS.
+
Wed May 21 13:26:08 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* lib/optparse.rb: get rid of warnings.
diff --git a/MANIFEST b/MANIFEST
index f6121203f6..d7bb8dfbdf 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -184,6 +184,7 @@ lib/observer.rb
lib/open-uri.rb
lib/open3.rb
lib/optparse.rb
+lib/optparse/date.rb
lib/optparse/shellwords.rb
lib/optparse/time.rb
lib/optparse/uri.rb
diff --git a/error.c b/error.c
index 26dec201cd..a90167cf2e 100644
--- a/error.c
+++ b/error.c
@@ -541,21 +541,29 @@ syserr_initialize(argc, argv, self)
#endif
char *err;
char *buf;
- VALUE error, mesg;
+ VALUE mesg, error;
VALUE klass = rb_obj_class(self);
- rb_scan_args(argc, argv, klass == rb_eSystemCallError ? "11" : "02",
- &mesg, &error);
- if (argc == 1 && FIXNUM_P(mesg)) {
- error = mesg;
- mesg = Qnil;
+ if (klass == rb_eSystemCallError) {
+ rb_scan_args(argc, argv, "11", &mesg, &error);
+ if (argc == 1 && FIXNUM_P(mesg)) {
+ error = mesg; mesg = Qnil;
+ }
+ if (!NIL_P(error) && st_lookup(syserr_tbl, NUM2LONG(error), &klass)) {
+ /* change class */
+ if (TYPE(self) != T_OBJECT) { /* insurance to avoid type crash */
+ rb_raise(rb_eTypeError, "invalid instance type");
+ }
+ RBASIC(self)->klass = klass;
+ }
}
- if (klass != rb_eSystemCallError && NIL_P(error)) {
+ else {
+ rb_scan_args(argc, argv, "01", &mesg);
error = rb_const_get_at(klass, rb_intern("Errno"));
}
- err = strerror(NUM2LONG(error));
- if (!err) err = "Unknown error";
- if (RTEST(mesg)) {
+ if (!NIL_P(error)) err = strerror(NUM2LONG(error));
+ else err = "unknown error";
+ if (!NIL_P(mesg)) {
StringValue(mesg);
buf = ALLOCA_N(char, strlen(err)+RSTRING(mesg)->len+4);
sprintf(buf, "%s - %s", err, RSTRING(mesg)->ptr);
@@ -564,7 +572,6 @@ syserr_initialize(argc, argv, self)
else {
mesg = rb_str_new2(err);
}
-
exc_initialize(1, &mesg, self);
rb_iv_set(self, "errno", error);
return self;
diff --git a/eval.c b/eval.c
index f7bc8d2c1f..3b8986aa8d 100644
--- a/eval.c
+++ b/eval.c
@@ -7982,7 +7982,6 @@ rb_thread_save_context(th)
th->stk_pos = (rb_gc_stack_start<pos)?rb_gc_stack_start
:rb_gc_stack_start - len;
if (len > th->stk_max) {
- rb_gc();
REALLOC_N(th->stk_ptr, VALUE, len);
th->stk_max = len;
}
diff --git a/gc.c b/gc.c
index 8a71ece020..8fe85689fa 100644
--- a/gc.c
+++ b/gc.c
@@ -1522,6 +1522,7 @@ run_final(obj)
int status;
VALUE args[2], table;
+ DEFER_INTS;
args[1] = rb_ary_new3(1, rb_obj_id(obj)); /* make obj into id */
for (i=0; i<RARRAY(finalizers)->len; i++) {
args[0] = RARRAY(finalizers)->ptr[i];
@@ -1533,6 +1534,7 @@ run_final(obj)
rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
}
}
+ ENABLE_INTS;
}
void
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 88d2256a2f..651164e274 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -77,7 +77,7 @@ SimpleDelegater = SimpleDelegator
def DelegateClass(superclass)
klass = Class.new
methods = superclass.public_instance_methods(true)
- methods -= ::Kernel.public_instance_methods
+ methods -= ::Kernel.public_instance_methods(false)
methods |= ["to_s","to_a","inspect","==","=~","==="]
klass.module_eval <<-EOS
def initialize(obj)