summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-11 01:34:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-11 01:34:42 +0000
commitfefba781bc0c4ba675d62bd29ecb0a2c4c5d134d (patch)
treec2fe603d4ff2584bfd67bbaa7fa05cc10b1f9963
parent5f3470b3a018fbe47480900330dd1a12e745ad08 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--process.c51
2 files changed, 30 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index ea756b04a6..3e1de62240 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* enc/trans/iso-8859-16-tbl.rb: add ISO-8859-16 converter.
diff --git a/process.c b/process.c
index 05ee2b2dfe..b3bdc8d8c8 100644
--- a/process.c
+++ b/process.c
@@ -2795,6 +2795,29 @@ rb_f_fork(VALUE obj)
#define rb_f_fork rb_f_notimplement
#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:
* Process.exit!(status=false)
@@ -2814,17 +2837,7 @@ rb_f_exit_bang(int argc, VALUE *argv, VALUE obj)
rb_secure(4);
if (argc > 0 && rb_scan_args(argc, argv, "01", &status) == 1) {
- switch (status) {
- case Qtrue:
- istatus = EXIT_SUCCESS;
- break;
- case Qfalse:
- istatus = EXIT_FAILURE;
- break;
- default:
- istatus = NUM2INT(status);
- break;
- }
+ istatus = exit_status_code(status);
}
else {
istatus = EXIT_FAILURE;
@@ -2898,21 +2911,7 @@ rb_f_exit(int argc, VALUE *argv)
rb_secure(4);
if (argc > 0 && rb_scan_args(argc, argv, "01", &status) == 1) {
- 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;
- }
+ istatus = exit_status_code(status);
}
else {
istatus = EXIT_SUCCESS;