summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-11-26 22:32:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-11-26 22:32:11 +0000
commit5bf245eeb90bf77bdee86c147789a1288e2648b4 (patch)
tree4c86c5a2a27a370663e90ad078b5195f92cba0e4 /eval.c
parentdc260404fe1287517ce1fca8e41f2f7935ccfe01 (diff)
* 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
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/eval.c b/eval.c
index 60e0d73..40470de 100644
--- a/eval.c
+++ b/eval.c
@@ -1181,7 +1181,7 @@ error_handle(ex)
case TAG_FATAL:
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
VALUE st = rb_iv_get(ruby_errinfo, "status");
- ex = NIL_P(st) ? 1 : NUM2INT(st);
+ ex = NUM2INT(st);
}
else {
error_print();
@@ -3562,17 +3562,19 @@ rb_mod_protected_method_defined(mod, mid)
return Qfalse;
}
-NORETURN(static void terminate_process _((int, const char*, long)));
-static void
-terminate_process(status, mesg, mlen)
+#define terminate_process(status, mesg, mlen) rb_exc_raise(system_exit(status, mesg, mlen))
+
+static VALUE
+system_exit(status, mesg, mlen)
int status;
const char *mesg;
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));
- rb_exc_raise(exit);
+ return rb_class_new_instance(2, args, rb_eSystemExit);
}
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))) {
- VALUE err = rb_exc_new(rb_eSystemExit, 0, 0);
+ VALUE err = system_exit(1, 0, 0);
error_print();
/* exit on main_thread */
rb_thread_raise(1, &err, main_thread);