* process.c (rb_exit_status_code): extract from rb_f_exit_bang and

rb_f_exit.  assume 0 to be success in Kernel#exit! too.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-12-11 01:34:42 +00:00
Родитель 5f3470b3a0
Коммит fefba781bc
2 изменённых файлов: 30 добавлений и 26 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sun Dec 11 10:34:39 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (rb_exit_status_code): extract from rb_f_exit_bang and
rb_f_exit. assume 0 to be success in Kernel#exit! too.
Fri Dec 9 19:24:31 2011 NARUSE, Yui <naruse@ruby-lang.org> Fri Dec 9 19:24:31 2011 NARUSE, Yui <naruse@ruby-lang.org>
* enc/trans/iso-8859-16-tbl.rb: add ISO-8859-16 converter. * enc/trans/iso-8859-16-tbl.rb: add ISO-8859-16 converter.

Просмотреть файл

@ -2795,6 +2795,29 @@ rb_f_fork(VALUE obj)
#define rb_f_fork rb_f_notimplement #define rb_f_fork rb_f_notimplement
#endif #endif
static int
exit_status_code(VALUE status)
{
int istatus;
switch (status) {
case Qtrue:
istatus = EXIT_SUCCESS;
break;
case Qfalse:
istatus = EXIT_FAILURE;
break;
default:
istatus = NUM2INT(status);
#if EXIT_SUCCESS != 0
if (istatus == 0)
istatus = EXIT_SUCCESS;
#endif
break;
}
return istatus;
}
/* /*
* call-seq: * call-seq:
* Process.exit!(status=false) * Process.exit!(status=false)
@ -2814,17 +2837,7 @@ rb_f_exit_bang(int argc, VALUE *argv, VALUE obj)
rb_secure(4); rb_secure(4);
if (argc > 0 && rb_scan_args(argc, argv, "01", &status) == 1) { if (argc > 0 && rb_scan_args(argc, argv, "01", &status) == 1) {
switch (status) { istatus = exit_status_code(status);
case Qtrue:
istatus = EXIT_SUCCESS;
break;
case Qfalse:
istatus = EXIT_FAILURE;
break;
default:
istatus = NUM2INT(status);
break;
}
} }
else { else {
istatus = EXIT_FAILURE; istatus = EXIT_FAILURE;
@ -2898,21 +2911,7 @@ rb_f_exit(int argc, VALUE *argv)
rb_secure(4); rb_secure(4);
if (argc > 0 && rb_scan_args(argc, argv, "01", &status) == 1) { if (argc > 0 && rb_scan_args(argc, argv, "01", &status) == 1) {
switch (status) { istatus = exit_status_code(status);
case Qtrue:
istatus = EXIT_SUCCESS;
break;
case Qfalse:
istatus = EXIT_FAILURE;
break;
default:
istatus = NUM2INT(status);
#if EXIT_SUCCESS != 0
if (istatus == 0)
istatus = EXIT_SUCCESS;
#endif
break;
}
} }
else { else {
istatus = EXIT_SUCCESS; istatus = EXIT_SUCCESS;