diff --git a/ChangeLog b/ChangeLog index 77e46c87c0..3aeb07a55f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri May 30 22:28:03 2008 Yusuke Endoh + + * signal.c (esignal_signo): fix SignalException#signo which returned + nil absolutely. + + * signal.c (esignal_init): always prepend "SIG" to a string that is + returned by SignalException#signm. + Fri May 30 22:17:39 2008 Yusuke Endoh * test/ruby/test_argf.rb: rename a conflicting method name. diff --git a/signal.c b/signal.c index 65e35a062f..0915b6a063 100644 --- a/signal.c +++ b/signal.c @@ -253,9 +253,7 @@ esignal_init(int argc, VALUE *argv, VALUE self) if (!signo) { rb_raise(rb_eArgError, "unsupported name `SIG%s'", signm); } - if (SYMBOL_P(sig)) { - sig = rb_str_new2(signm); - } + sig = rb_sprintf("SIG%s", signm); } rb_call_super(1, &sig); rb_iv_set(self, "signo", INT2NUM(signo)); @@ -263,6 +261,19 @@ esignal_init(int argc, VALUE *argv, VALUE self) return self; } +/* + * call-seq: + * signal_exception.signo => num + * + * Returns a signal number. + */ + +static VALUE +esignal_signo(VALUE self) +{ + return rb_iv_get(self, "signo"); +} + static VALUE interrupt_init(int argc, VALUE *argv, VALUE self) { @@ -1070,7 +1081,7 @@ Init_signal(void) rb_define_module_function(mSignal, "list", sig_list, 0); rb_define_method(rb_eSignal, "initialize", esignal_init, -1); - rb_attr(rb_eSignal, rb_intern("signo"), 1, 0, 0); + rb_define_method(rb_eSignal, "signo", esignal_signo, 0); rb_alias(rb_eSignal, rb_intern("signm"), rb_intern("message")); rb_define_method(rb_eInterrupt, "initialize", interrupt_init, -1);