Project

General

Profile

Bug #5728 ยป system-exit-bool.patch

akr (Akira Tanaka), 12/11/2011 02:24 AM

View differences:

error.c (working copy)
743 743

  
744 744
/*
745 745
 * call-seq:
746
 *   SystemExit.new              -> system_exit
747
 *   SystemExit.new(status)      -> system_exit
748
 *   SystemExit.new(status, msg) -> system_exit
749
 *   SystemExit.new(msg)         -> system_exit
746
 *   SystemExit.new                  -> system_exit
747
 *   SystemExit.new(status)          -> system_exit
748
 *   SystemExit.new(status, message) -> system_exit
749
 *   SystemExit.new(msg)             -> system_exit
750
 *
751
 * Create a new +SystemExit+ exception with the given _status_ and _message_.
752
 * If _status_ is not given, EXIT_SUCCESS is used.
753
 *
754
 * _status_ should be +true+, +false+ or an integer.
755
 * +true+ means EXIT_SUCCESS and +false+ means EXIT_FAILURE.
756
 *
757
 * _message_ should be a string.
750 758
 *
751
 * Create a new +SystemExit+ exception with the given status and message.
752
 * If status is not given, EXIT_SUCCESS is used.
753 759
 */
754 760

  
755 761
static VALUE
756 762
exit_initialize(int argc, VALUE *argv, VALUE exc)
757 763
{
758 764
    VALUE status = INT2FIX(EXIT_SUCCESS);
759
    if (argc > 0 && FIXNUM_P(argv[0])) {
760
	status = *argv++;
765
    if (argc > 0 && (FIXNUM_P(argv[0]) || argv[0] == Qtrue || argv[0] == Qfalse)) {
766
        if (argv[0] == Qtrue)
767
            status = INT2FIX(EXIT_SUCCESS);
768
        else if (argv[0] == Qfalse)
769
            status = INT2FIX(EXIT_FAILURE);
770
        else
771
            status = *argv++;
761 772
	--argc;
762 773
    }
763 774
    rb_call_super(argc, argv);