mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* error.c (exit_initialize): add SystemExit#initialize to set
instance variable status. (ruby-bugs-ja:PR#362) Now accepts status as optional first argument. * eval.c (error_handle): now SystemExit have status always. * eval.c (system_exit): just instantiate SystemExit without raise. * eval.c (rb_thread_start_0): initialize SystemExit properly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dc260404fe
commit
5bf245eeb9
3 changed files with 40 additions and 9 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
Wed Nov 27 06:43:26 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
|
* error.c (exit_initialize): add SystemExit#initialize to set
|
||||||
|
instance variable status. (ruby-bugs-ja:PR#362)
|
||||||
|
|
||||||
|
* eval.c (error_handle): now SystemExit have status always.
|
||||||
|
|
||||||
|
* eval.c (system_exit): just instantiate SystemExit without raise.
|
||||||
|
|
||||||
|
* eval.c (rb_thread_start_0): initialize SystemExit properly.
|
||||||
|
|
||||||
Mon Nov 25 19:55:38 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
Mon Nov 25 19:55:38 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* ext/extmk.rb (extmake): return true if not dynamic and not static.
|
* ext/extmk.rb (extmake): return true if not dynamic and not static.
|
||||||
|
|
20
error.c
20
error.c
|
@ -28,8 +28,9 @@ int ruby_nerrs;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
err_snprintf(buf, len, fmt, args)
|
err_snprintf(buf, len, fmt, args)
|
||||||
char *buf, *fmt;
|
char *buf;
|
||||||
long len;
|
long len;
|
||||||
|
const char *fmt;
|
||||||
va_list args;
|
va_list args;
|
||||||
{
|
{
|
||||||
long n;
|
long n;
|
||||||
|
@ -399,6 +400,22 @@ exc_set_backtrace(exc, bt)
|
||||||
return rb_iv_set(exc, "bt", check_backtrace(bt));
|
return rb_iv_set(exc, "bt", check_backtrace(bt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
exit_initialize(argc, argv, exc)
|
||||||
|
int argc;
|
||||||
|
VALUE *argv;
|
||||||
|
VALUE exc;
|
||||||
|
{
|
||||||
|
VALUE status = INT2NUM(0);
|
||||||
|
if (argc > 0 && FIXNUM_P(argv[0])) {
|
||||||
|
status = *argv++;
|
||||||
|
--argc;
|
||||||
|
}
|
||||||
|
exc_initialize(argc, argv, exc);
|
||||||
|
rb_iv_set(exc, "status", status);
|
||||||
|
return exc;
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
exit_status(exc)
|
exit_status(exc)
|
||||||
VALUE exc;
|
VALUE exc;
|
||||||
|
@ -530,6 +547,7 @@ Init_Exception()
|
||||||
rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1);
|
rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1);
|
||||||
|
|
||||||
rb_eSystemExit = rb_define_class("SystemExit", rb_eException);
|
rb_eSystemExit = rb_define_class("SystemExit", rb_eException);
|
||||||
|
rb_define_method(rb_eSystemExit, "initialize", exit_initialize, -1);
|
||||||
rb_define_method(rb_eSystemExit, "status", exit_status, 0);
|
rb_define_method(rb_eSystemExit, "status", exit_status, 0);
|
||||||
|
|
||||||
rb_eFatal = rb_define_class("fatal", rb_eException);
|
rb_eFatal = rb_define_class("fatal", rb_eException);
|
||||||
|
|
18
eval.c
18
eval.c
|
@ -1181,7 +1181,7 @@ error_handle(ex)
|
||||||
case TAG_FATAL:
|
case TAG_FATAL:
|
||||||
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
|
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
|
||||||
VALUE st = rb_iv_get(ruby_errinfo, "status");
|
VALUE st = rb_iv_get(ruby_errinfo, "status");
|
||||||
ex = NIL_P(st) ? 1 : NUM2INT(st);
|
ex = NUM2INT(st);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error_print();
|
error_print();
|
||||||
|
@ -3562,17 +3562,19 @@ rb_mod_protected_method_defined(mod, mid)
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
NORETURN(static void terminate_process _((int, const char*, long)));
|
#define terminate_process(status, mesg, mlen) rb_exc_raise(system_exit(status, mesg, mlen))
|
||||||
static void
|
|
||||||
terminate_process(status, mesg, mlen)
|
static VALUE
|
||||||
|
system_exit(status, mesg, mlen)
|
||||||
int status;
|
int status;
|
||||||
const char *mesg;
|
const char *mesg;
|
||||||
long mlen;
|
long mlen;
|
||||||
{
|
{
|
||||||
VALUE exit = rb_exc_new(rb_eSystemExit, mesg, mlen);
|
VALUE args[2];
|
||||||
|
args[0] = INT2NUM(status);
|
||||||
|
args[1] = rb_str_new(mesg, mlen);
|
||||||
|
|
||||||
rb_iv_set(exit, "status", INT2NUM(status));
|
return rb_class_new_instance(2, args, rb_eSystemExit);
|
||||||
rb_exc_raise(exit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -8869,7 +8871,7 @@ rb_thread_start_0(fn, arg, th_arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (th->safe < 4 && (thread_abort || th->abort || RTEST(ruby_debug))) {
|
else if (th->safe < 4 && (thread_abort || th->abort || RTEST(ruby_debug))) {
|
||||||
VALUE err = rb_exc_new(rb_eSystemExit, 0, 0);
|
VALUE err = system_exit(1, 0, 0);
|
||||||
error_print();
|
error_print();
|
||||||
/* exit on main_thread */
|
/* exit on main_thread */
|
||||||
rb_thread_raise(1, &err, main_thread);
|
rb_thread_raise(1, &err, main_thread);
|
||||||
|
|
Loading…
Reference in a new issue