From 99fb5f48711dc3267dc008060e9f5b97434c5121 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 27 Nov 2003 15:34:53 +0000 Subject: * eval.c (rb_f_exit), process.c (rb_f_exit_bang): treat true as success, false as failure. [ruby-dev:22067] * eval.c (rb_f_abort, rb_thread_switch), process.c (rb_f_system): use ANSI macro instead of hard coded value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- process.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'process.c') diff --git a/process.c b/process.c index 17ec62fc11..cbee4ffd38 100644 --- a/process.c +++ b/process.c @@ -30,6 +30,9 @@ #include #include +#ifndef EXIT_SUCCESS +#define EXIT_SUCCESS 0 +#endif #ifndef EXIT_FAILURE #define EXIT_FAILURE 1 #endif @@ -878,7 +881,17 @@ rb_f_exit_bang(argc, argv, obj) rb_secure(4); if (rb_scan_args(argc, argv, "01", &status) == 1) { - istatus = NUM2INT(status); + switch (status) { + case T_TRUE: + istatus = EXIT_SUCCESS; + break; + case T_FALSE: + istatus = EXIT_FAILURE; + break; + default: + istatus = NUM2INT(status); + break; + } } else { istatus = EXIT_FAILURE; @@ -930,9 +943,9 @@ rb_f_system(argc, argv) int argc; VALUE *argv; { + int status; #if defined(__EMX__) VALUE cmd; - int status; fflush(stdout); fflush(stderr); @@ -952,12 +965,8 @@ rb_f_system(argc, argv) SafeStringValue(cmd); status = do_spawn(RSTRING(cmd)->ptr); last_status_set(status, 0); - - if (status == 0) return Qtrue; - return Qfalse; #elif defined(__human68k__) || defined(__DJGPP__) || defined(_WIN32) volatile VALUE prog = 0; - int status; fflush(stdout); fflush(stderr); @@ -990,10 +999,8 @@ rb_f_system(argc, argv) #else last_status_set(status == -1 ? 127 : status, 0); #endif - return status == 0 ? Qtrue : Qfalse; #elif defined(__VMS) VALUE cmd; - int status; if (argc == 0) { rb_last_status = Qnil; @@ -1011,9 +1018,6 @@ rb_f_system(argc, argv) SafeStringValue(cmd); status = system(RSTRING(cmd)->ptr); last_status_set((status & 0xff) << 8, 0); - - if (status == 0) return Qtrue; - return Qfalse; #else volatile VALUE prog = 0; int pid; @@ -1064,10 +1068,11 @@ rb_f_system(argc, argv) rb_syswait(pid); } - if (NUM2INT(rb_last_status) == 0) - return Qtrue; - return Qfalse; + status = NUM2INT(rb_last_status); #endif + + if (status == EXIT_SUCCESS) return Qtrue; + return Qfalse; } static VALUE -- cgit v1.2.3