summaryrefslogtreecommitdiff
path: root/error.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 /error.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 'error.c')
-rw-r--r--error.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/error.c b/error.c
index edd86f0..0c7d2bc 100644
--- a/error.c
+++ b/error.c
@@ -28,8 +28,9 @@ int ruby_nerrs;
static void
err_snprintf(buf, len, fmt, args)
- char *buf, *fmt;
+ char *buf;
long len;
+ const char *fmt;
va_list args;
{
long n;
@@ -400,6 +401,22 @@ exc_set_backtrace(exc, 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
exit_status(exc)
VALUE exc;
{
@@ -530,6 +547,7 @@ Init_Exception()
rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1);
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_eFatal = rb_define_class("fatal", rb_eException);