[前][次][番号順一覧][スレッド一覧]

ruby-changes:21956

From: nobu <ko1@a...>
Date: Sun, 11 Dec 2011 10:34:53 +0900 (JST)
Subject: [ruby-changes:21956] nobu:r34005 (trunk): * process.c (rb_exit_status_code): extract from rb_f_exit_bang and

nobu	2011-12-11 10:34:42 +0900 (Sun, 11 Dec 2011)

  New Revision: 34005

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34005

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/process.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34004)
+++ ChangeLog	(revision 34005)
@@ -1,3 +1,8 @@
+Sun Dec 11 10:34:39 2011  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* enc/trans/iso-8859-16-tbl.rb: add ISO-8859-16 converter.
Index: process.c
===================================================================
--- process.c	(revision 34004)
+++ process.c	(revision 34005)
@@ -2795,6 +2795,29 @@
 #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_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_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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]