1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (str_new4): should not preserve FL_TAINT status in the

internal shared string. [ruby-dev:21601]

* string.c (rb_str_new4): ditto.

* eval.c: use EXIT_SUCCESS and EXIT_FAILURE for exit values.

* process.c: ditto. [ruby-dev:38521]

* lib/debug.rb (debug_command): should enter emacs mode when
  assigned any value to the environment variable "EMACS".
  On Meadow, (getenv "EMACS") is "meadow".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-10-13 13:05:24 +00:00
parent b6f1c0e284
commit 1184373d86
6 changed files with 63 additions and 39 deletions

View file

@ -1,3 +1,20 @@
Mon Oct 13 20:49:51 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_new4): should not preserve FL_TAINT status in the
internal shared string. [ruby-dev:21601]
* string.c (rb_str_new4): ditto.
* eval.c: use EXIT_SUCCESS and EXIT_FAILURE for exit values.
* process.c: ditto. [ruby-dev:38521]
Mon Oct 13 19:51:02 2003 Koji Arai <jca02266@nifty.ne.jp>
* lib/debug.rb (debug_command): should enter emacs mode when
assigned any value to the environment variable "EMACS".
On Meadow, (getenv "EMACS") is "meadow".
Sun Oct 12 14:45:03 2003 WATANABE Hirofumi <eban@ruby-lang.org> Sun Oct 12 14:45:03 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* ext/win32ole/extconf.rb: check "windows.h", not "windows". * ext/win32ole/extconf.rb: check "windows.h", not "windows".

50
eval.c
View file

@ -18,6 +18,16 @@
#include "util.h" #include "util.h"
#include "rubysig.h" #include "rubysig.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
#include <stdio.h> #include <stdio.h>
#include <setjmp.h> #include <setjmp.h>
#include "st.h" #include "st.h"
@ -1181,7 +1191,7 @@ ruby_init()
POP_TAG(); POP_TAG();
if (state) { if (state) {
error_print(); error_print();
exit(1); exit(EXIT_FAILURE);
} }
POP_SCOPE(); POP_SCOPE();
ruby_scope = top_scope; ruby_scope = top_scope;
@ -1219,37 +1229,33 @@ static int
error_handle(ex) error_handle(ex)
int ex; int ex;
{ {
if (thread_set_raised()) return 1; int status = EXIT_FAILURE;
if (thread_set_raised()) return EXIT_FAILURE;
switch (ex & TAG_MASK) { switch (ex & TAG_MASK) {
case 0: case 0:
ex = 0; status = EXIT_SUCCESS;
break; break;
case TAG_RETURN: case TAG_RETURN:
error_pos(); error_pos();
warn_print(": unexpected return\n"); warn_print(": unexpected return\n");
ex = 1;
break; break;
case TAG_NEXT: case TAG_NEXT:
error_pos(); error_pos();
warn_print(": unexpected next\n"); warn_print(": unexpected next\n");
ex = 1;
break; break;
case TAG_BREAK: case TAG_BREAK:
error_pos(); error_pos();
warn_print(": unexpected break\n"); warn_print(": unexpected break\n");
ex = 1;
break; break;
case TAG_REDO: case TAG_REDO:
error_pos(); error_pos();
warn_print(": unexpected redo\n"); warn_print(": unexpected redo\n");
ex = 1;
break; break;
case TAG_RETRY: case TAG_RETRY:
error_pos(); error_pos();
warn_print(": retry outside of rescue clause\n"); warn_print(": retry outside of rescue clause\n");
ex = 1;
break; break;
case TAG_THROW: case TAG_THROW:
if (prot_tag && prot_tag->frame && prot_tag->frame->node) { if (prot_tag && prot_tag->frame && prot_tag->frame->node) {
@ -1261,17 +1267,15 @@ error_handle(ex)
error_pos(); error_pos();
warn_printf(": unexpected throw\n"); warn_printf(": unexpected throw\n");
} }
ex = 1;
break; break;
case TAG_RAISE: case TAG_RAISE:
case TAG_FATAL: case TAG_FATAL:
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) { if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
VALUE st = rb_iv_get(ruby_errinfo, "status"); VALUE st = rb_iv_get(ruby_errinfo, "status");
ex = NUM2INT(st); status = NUM2INT(st);
} }
else { else {
error_print(); error_print();
ex = 1;
} }
break; break;
default: default:
@ -1279,7 +1283,7 @@ error_handle(ex)
break; break;
} }
thread_reset_raised(); thread_reset_raised();
return ex; return status;
} }
void void
@ -1304,9 +1308,9 @@ ruby_options(argc, argv)
void rb_exec_end_proc _((void)); void rb_exec_end_proc _((void));
static void static int
ruby_finalize_0(exp) ruby_finalize_0(exp)
int *exp; int exp;
{ {
ruby_errinfo = 0; ruby_errinfo = 0;
PUSH_TAG(PROT_NONE); PUSH_TAG(PROT_NONE);
@ -1316,12 +1320,13 @@ ruby_finalize_0(exp)
POP_TAG(); POP_TAG();
rb_exec_end_proc(); rb_exec_end_proc();
rb_gc_call_finalizer_at_exit(); rb_gc_call_finalizer_at_exit();
if (exp && ruby_errinfo && rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
VALUE st = rb_iv_get(ruby_errinfo, "status");
*exp = NUM2INT(st);
}
trace_func = 0; trace_func = 0;
tracing = 0; tracing = 0;
if (ruby_errinfo && rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
VALUE st = rb_iv_get(ruby_errinfo, "status");
return NUM2INT(st);
}
return EXIT_SUCCESS;
} }
void void
@ -1350,8 +1355,7 @@ ruby_cleanup(ex)
ex = error_handle(ex); ex = error_handle(ex);
POP_TAG(); POP_TAG();
ruby_finalize_0(&ex); return ruby_finalize_0(ex);
return ex;
} }
int int
@ -3846,7 +3850,7 @@ rb_f_exit(argc, argv)
istatus = NUM2INT(status); istatus = NUM2INT(status);
} }
else { else {
istatus = 0; istatus = EXIT_SUCCESS;
} }
rb_exit(istatus); rb_exit(istatus);
return Qnil; /* not reached */ return Qnil; /* not reached */
@ -3862,7 +3866,7 @@ rb_f_abort(argc, argv)
if (!NIL_P(ruby_errinfo)) { if (!NIL_P(ruby_errinfo)) {
error_print(); error_print();
} }
rb_exit(1); rb_exit(EXIT_FAILURE);
} }
else { else {
VALUE mesg; VALUE mesg;
@ -9110,7 +9114,7 @@ rb_thread_kill(thread)
} }
if (th->status == THREAD_TO_KILL || th->status == THREAD_KILLED) if (th->status == THREAD_TO_KILL || th->status == THREAD_KILLED)
return thread; return thread;
if (th == th->next || th == main_thread) rb_exit(0); if (th == th->next || th == main_thread) rb_exit(EXIT_SUCCESS);
rb_thread_ready(th); rb_thread_ready(th);
th->status = THREAD_TO_KILL; th->status = THREAD_TO_KILL;

View file

@ -261,7 +261,7 @@ class Context
binding_file = file binding_file = file
binding_line = line binding_line = line
previous_line = nil previous_line = nil
if (ENV['EMACS'] == 't') if ENV['EMACS']
stdout.printf "\032\032%s:%d:\n", binding_file, binding_line stdout.printf "\032\032%s:%d:\n", binding_file, binding_line
else else
stdout.printf "%s:%d:%s", binding_file, binding_line, stdout.printf "%s:%d:%s", binding_file, binding_line,

View file

@ -17,6 +17,9 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -27,6 +30,10 @@
#include <time.h> #include <time.h>
#include <ctype.h> #include <ctype.h>
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
struct timeval rb_time_interval _((VALUE)); struct timeval rb_time_interval _((VALUE));
#ifdef HAVE_SYS_WAIT_H #ifdef HAVE_SYS_WAIT_H
@ -874,7 +881,7 @@ rb_f_exit_bang(argc, argv, obj)
istatus = NUM2INT(status); istatus = NUM2INT(status);
} }
else { else {
istatus = -1; istatus = EXIT_FAILURE;
} }
_exit(istatus); _exit(istatus);

View file

@ -152,7 +152,6 @@ str_new4(klass, str)
FL_SET(str, ELTS_SHARED); FL_SET(str, ELTS_SHARED);
RSTRING(str)->aux.shared = str2; RSTRING(str)->aux.shared = str2;
} }
OBJ_INFECT(str2, str);
return str2; return str2;
} }
@ -177,7 +176,6 @@ rb_str_new4(orig)
} }
else if (FL_TEST(orig, STR_ASSOC)) { else if (FL_TEST(orig, STR_ASSOC)) {
str = str_new(klass, RSTRING(orig)->ptr, RSTRING(orig)->len); str = str_new(klass, RSTRING(orig)->ptr, RSTRING(orig)->len);
OBJ_INFECT(str, orig);
} }
else { else {
str = str_new4(klass, orig); str = str_new4(klass, orig);
@ -527,20 +525,15 @@ rb_str_substr(str, beg, len)
if (len == 0) return rb_str_new5(str,0,0); if (len == 0) return rb_str_new5(str,0,0);
if (len > sizeof(struct RString)/2 && if (len > sizeof(struct RString)/2 &&
beg + len == RSTRING(str)->len && beg + len == RSTRING(str)->len && !FL_TEST(str, STR_ASSOC)) {
!FL_TEST(str, STR_ASSOC)) { str2 = rb_str_new3(rb_str_new4(str));
if (FL_TEST(str, ELTS_SHARED) && RSTRING(str)->aux.shared)
str = RSTRING(str)->aux.shared;
else
str = str_new4(rb_obj_class(str), str);
str2 = rb_str_new3(str);
RSTRING(str2)->ptr += RSTRING(str2)->len - len; RSTRING(str2)->ptr += RSTRING(str2)->len - len;
RSTRING(str2)->len = len; RSTRING(str2)->len = len;
} }
else { else {
str2 = rb_str_new5(str, RSTRING(str)->ptr+beg, len); str2 = rb_str_new5(str, RSTRING(str)->ptr+beg, len);
OBJ_INFECT(str2, str);
} }
OBJ_INFECT(str2, str);
return str2; return str2;
} }

View file

@ -1,10 +1,13 @@
module EnvUtil module EnvUtil
def rubybin def rubybin
if File.exist? "miniruby" or File.exist? "miniruby.exe" miniruby = "miniruby"
"./miniruby" 3.times do
else if File.exist? miniruby or File.exist? miniruby+".exe"
"ruby" return File.expand_path(miniruby)
end
miniruby = "../"+miniruby
end end
"ruby"
end end
module_function :rubybin module_function :rubybin
end end