mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
564c80b10a
commit
062351e6bb
6 changed files with 32 additions and 13 deletions
10
ChangeLog
10
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.
|
||||
|
|
1
MANIFEST
1
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
|
||||
|
|
29
error.c
29
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;
|
||||
|
|
1
eval.c
1
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;
|
||||
}
|
||||
|
|
2
gc.c
2
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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue