summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-13 13:05:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-13 13:05:24 +0000
commit1184373d867f0e4792b3a6da11acfd2cf4c0b330 (patch)
treec93cdc524880d4142cfe48dcb194207d05a34263
parentb6f1c0e2846acbbc9d694b1207c778e1d6db63e3 (diff)
* 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
-rw-r--r--ChangeLog17
-rw-r--r--eval.c50
-rw-r--r--lib/debug.rb2
-rw-r--r--process.c9
-rw-r--r--string.c13
-rw-r--r--test/ruby/envutil.rb11
6 files changed, 63 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fb704e032..9160c0e48e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* ext/win32ole/extconf.rb: check "windows.h", not "windows".
diff --git a/eval.c b/eval.c
index 048c8de569..b00d304a2a 100644
--- a/eval.c
+++ b/eval.c
@@ -18,6 +18,16 @@
#include "util.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 <setjmp.h>
#include "st.h"
@@ -1181,7 +1191,7 @@ ruby_init()
POP_TAG();
if (state) {
error_print();
- exit(1);
+ exit(EXIT_FAILURE);
}
POP_SCOPE();
ruby_scope = top_scope;
@@ -1219,37 +1229,33 @@ static int
error_handle(ex)
int ex;
{
- if (thread_set_raised()) return 1;
+ int status = EXIT_FAILURE;
+ if (thread_set_raised()) return EXIT_FAILURE;
switch (ex & TAG_MASK) {
case 0:
- ex = 0;
+ status = EXIT_SUCCESS;
break;
case TAG_RETURN:
error_pos();
warn_print(": unexpected return\n");
- ex = 1;
break;
case TAG_NEXT:
error_pos();
warn_print(": unexpected next\n");
- ex = 1;
break;
case TAG_BREAK:
error_pos();
warn_print(": unexpected break\n");
- ex = 1;
break;
case TAG_REDO:
error_pos();
warn_print(": unexpected redo\n");
- ex = 1;
break;
case TAG_RETRY:
error_pos();
warn_print(": retry outside of rescue clause\n");
- ex = 1;
break;
case TAG_THROW:
if (prot_tag && prot_tag->frame && prot_tag->frame->node) {
@@ -1261,17 +1267,15 @@ error_handle(ex)
error_pos();
warn_printf(": unexpected throw\n");
}
- ex = 1;
break;
case TAG_RAISE:
case TAG_FATAL:
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
VALUE st = rb_iv_get(ruby_errinfo, "status");
- ex = NUM2INT(st);
+ status = NUM2INT(st);
}
else {
error_print();
- ex = 1;
}
break;
default:
@@ -1279,7 +1283,7 @@ error_handle(ex)
break;
}
thread_reset_raised();
- return ex;
+ return status;
}
void
@@ -1304,9 +1308,9 @@ ruby_options(argc, argv)
void rb_exec_end_proc _((void));
-static void
+static int
ruby_finalize_0(exp)
- int *exp;
+ int exp;
{
ruby_errinfo = 0;
PUSH_TAG(PROT_NONE);
@@ -1316,12 +1320,13 @@ ruby_finalize_0(exp)
POP_TAG();
rb_exec_end_proc();
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;
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
@@ -1350,8 +1355,7 @@ ruby_cleanup(ex)
ex = error_handle(ex);
POP_TAG();
- ruby_finalize_0(&ex);
- return ex;
+ return ruby_finalize_0(ex);
}
int
@@ -3846,7 +3850,7 @@ rb_f_exit(argc, argv)
istatus = NUM2INT(status);
}
else {
- istatus = 0;
+ istatus = EXIT_SUCCESS;
}
rb_exit(istatus);
return Qnil; /* not reached */
@@ -3862,7 +3866,7 @@ rb_f_abort(argc, argv)
if (!NIL_P(ruby_errinfo)) {
error_print();
}
- rb_exit(1);
+ rb_exit(EXIT_FAILURE);
}
else {
VALUE mesg;
@@ -9110,7 +9114,7 @@ rb_thread_kill(thread)
}
if (th->status == THREAD_TO_KILL || th->status == THREAD_KILLED)
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);
th->status = THREAD_TO_KILL;
diff --git a/lib/debug.rb b/lib/debug.rb
index 58ff8e5f2c..59dcae5e15 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -261,7 +261,7 @@ class Context
binding_file = file
binding_line = line
previous_line = nil
- if (ENV['EMACS'] == 't')
+ if ENV['EMACS']
stdout.printf "\032\032%s:%d:\n", binding_file, binding_line
else
stdout.printf "%s:%d:%s", binding_file, binding_line,
diff --git a/process.c b/process.c
index 24b75855a7..1920da2c44 100644
--- a/process.c
+++ b/process.c
@@ -17,6 +17,9 @@
#include <stdio.h>
#include <errno.h>
#include <signal.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -27,6 +30,10 @@
#include <time.h>
#include <ctype.h>
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
struct timeval rb_time_interval _((VALUE));
#ifdef HAVE_SYS_WAIT_H
@@ -874,7 +881,7 @@ rb_f_exit_bang(argc, argv, obj)
istatus = NUM2INT(status);
}
else {
- istatus = -1;
+ istatus = EXIT_FAILURE;
}
_exit(istatus);
diff --git a/string.c b/string.c
index 67f4f8dcc3..ddf530c998 100644
--- a/string.c
+++ b/string.c
@@ -152,7 +152,6 @@ str_new4(klass, str)
FL_SET(str, ELTS_SHARED);
RSTRING(str)->aux.shared = str2;
}
- OBJ_INFECT(str2, str);
return str2;
}
@@ -177,7 +176,6 @@ rb_str_new4(orig)
}
else if (FL_TEST(orig, STR_ASSOC)) {
str = str_new(klass, RSTRING(orig)->ptr, RSTRING(orig)->len);
- OBJ_INFECT(str, orig);
}
else {
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 > sizeof(struct RString)/2 &&
- beg + len == RSTRING(str)->len &&
- !FL_TEST(str, STR_ASSOC)) {
- 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);
+ beg + len == RSTRING(str)->len && !FL_TEST(str, STR_ASSOC)) {
+ str2 = rb_str_new3(rb_str_new4(str));
RSTRING(str2)->ptr += RSTRING(str2)->len - len;
RSTRING(str2)->len = len;
}
else {
str2 = rb_str_new5(str, RSTRING(str)->ptr+beg, len);
- OBJ_INFECT(str2, str);
}
+ OBJ_INFECT(str2, str);
return str2;
}
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb
index 3f0fed3ad5..186fcae1e6 100644
--- a/test/ruby/envutil.rb
+++ b/test/ruby/envutil.rb
@@ -1,10 +1,13 @@
module EnvUtil
def rubybin
- if File.exist? "miniruby" or File.exist? "miniruby.exe"
- "./miniruby"
- else
- "ruby"
+ miniruby = "miniruby"
+ 3.times do
+ if File.exist? miniruby or File.exist? miniruby+".exe"
+ return File.expand_path(miniruby)
+ end
+ miniruby = "../"+miniruby
end
+ "ruby"
end
module_function :rubybin
end