diff --git a/ChangeLog b/ChangeLog index 0d95f0a0b6..555aab01ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Nov 28 00:34:44 2003 Nobuyoshi Nakada + + * 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. + Thu Nov 27 22:05:48 2003 Akinori MUSHA * eval.c, gc.c: FreeBSD/ia64 currently does not have a way for a @@ -8,8 +16,8 @@ Thu Nov 27 22:05:48 2003 Akinori MUSHA Thu Nov 27 17:36:42 2003 Hidetoshi NAGAI * ext/tk/lib/tkafter.rb: bug fix on TkTimer#cancel_on_exception=(mode). - TkTimer#wait recieves the exception of the callback. - The exception is kept on @return_value. + TkTimer#wait recieves the exception of the callback. + The exception is kept on @return_value. Thu Nov 27 16:58:48 2003 WATANABE Hirofumi @@ -77,7 +85,7 @@ Tue Nov 25 16:41:33 2003 NAKAMURA, Hiroshi Tue Nov 25 16:24:42 2003 NAKAMURA, Hiroshi * lib/soap/**/*.rb, lib/wsdl/**/*.rb, lib/xsd/**/*.rb: changed license; - GPL2 -> Ruby's. + GPL2 -> Ruby's. * lib/soap/rpc/driver.rb, lib/soap/wsdlDriver.rb, lib/soap/streamHandler.rb: add interface to streamhandler. diff --git a/eval.c b/eval.c index 217c5c7f49..5cfee877ec 100644 --- a/eval.c +++ b/eval.c @@ -3895,7 +3895,17 @@ rb_f_exit(argc, argv) 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_SUCCESS; @@ -3922,7 +3932,7 @@ rb_f_abort(argc, argv) rb_scan_args(argc, argv, "1", &mesg); StringValue(argv[0]); rb_io_puts(argc, argv, rb_stderr); - terminate_process(1, RSTRING(argv[0])->ptr, RSTRING(argv[0])->len); + terminate_process(EXIT_FAILURE, RSTRING(argv[0])->ptr, RSTRING(argv[0])->len); } return Qnil; /* not reached */ } @@ -8407,7 +8417,7 @@ rb_thread_switch(n) ruby_errinfo = th_raise_argv[0]; ruby_current_node = th_raise_node; error_print(); - terminate_process(1, 0, 0); + terminate_process(EXIT_FAILURE, 0, 0); break; case RESTORE_NORMAL: default: diff --git a/lib/test/unit/ui/gtk/testrunner.rb b/lib/test/unit/ui/gtk/testrunner.rb index 7582c489a5..d6ce527fe9 100644 --- a/lib/test/unit/ui/gtk/testrunner.rb +++ b/lib/test/unit/ui/gtk/testrunner.rb @@ -94,7 +94,7 @@ module Test retry rescue end - abort if @red + exit !@red end def stop(*) # :nodoc: diff --git a/lib/test/unit/ui/gtk2/testrunner.rb b/lib/test/unit/ui/gtk2/testrunner.rb index ee78f91ac8..1efc7dd758 100644 --- a/lib/test/unit/ui/gtk2/testrunner.rb +++ b/lib/test/unit/ui/gtk2/testrunner.rb @@ -406,7 +406,7 @@ module Test retry rescue end - abort if @red + exit !@red end # def start_ui private :start_ui diff --git a/lib/test/unit/ui/tk/testrunner.rb b/lib/test/unit/ui/tk/testrunner.rb index 19c39a22f8..3c3e0f554f 100644 --- a/lib/test/unit/ui/tk/testrunner.rb +++ b/lib/test/unit/ui/tk/testrunner.rb @@ -102,7 +102,7 @@ module Test retry rescue end - abort if @red + exit !@red end def stop # :nodoc: 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