summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--Makefile.in13
-rw-r--r--eval.c61
-rw-r--r--file.c4
-rw-r--r--mkconfig.rb4
-rw-r--r--range.c34
6 files changed, 83 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index e24aca0bd2..c0a981309e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Thu Nov 8 18:21:02 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (path_check_1): forgot to initialize 'p'.
+
+Thu Nov 8 14:52:15 2001 Tanaka Akira <akr@m17n.org>
+
+ * mkconfig.rb: use String#dump to generate Ruby string literal.
+
+Thu Nov 8 15:46:54 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_eql): should override 'eql?'
+
+ * array.c (rb_ary_hash): should override 'hash' too.
+
Tue Nov 6 14:38:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (security): always give warning for insecure PATH.
diff --git a/Makefile.in b/Makefile.in
index bd197ded87..a8d1ad79cd 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -107,14 +107,19 @@ $(LIBRUBY_SO): $(OBJS) dmyext.@OBJEXT@ miniruby$(EXEEXT)
install: rbconfig.rb
@MINIRUBY@ $(srcdir)/instruby.rb $(DESTDIR)
-clean:; @rm -f $(OBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES) $(MAINOBJ) rbconfig.rb
+clean-ext:; @-@MINIRUBY@ -Cext extmk.rb clean 2> /dev/null || true
+
+clean: clean-ext
+ @rm -f $(OBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES)
@rm -f ext/extinit.c ext/extinit.@OBJEXT@ dmyext.@OBJEXT@
@-@MINIRUBY@ -Cext extmk.rb clean 2> /dev/null || true
@rm -f $(PROGRAM) miniruby$(EXEEXT)
-distclean:; @-@MINIRUBY@ -Cext extmk.rb distclean 2> /dev/null || true
- $(MAKE) clean
- @rm -f Makefile ext/extmk.rb config.h
+distclean-ext:
+ @-@MINIRUBY@ -Cext extmk.rb distclean 2> /dev/null || true
+
+distclean: distclean-ext clean
+ @rm -f Makefile ext/extmk.rb config.h rbconfig.rb
@rm -f ext/config.cache config.cache config.log config.status
@rm -f *~ core *.core gmon.out y.tab.c y.output ruby.imp
diff --git a/eval.c b/eval.c
index e9e11e89a7..36e090c787 100644
--- a/eval.c
+++ b/eval.c
@@ -594,17 +594,15 @@ new_blktag()
}
struct RVarmap *ruby_dyna_vars;
-#define PUSH_VARS() { \
- struct RVarmap * volatile _old; \
- _old = ruby_dyna_vars; \
+#define PUSH_VARS() { \
+ struct RVarmap * volatile _old; \
+ _old = ruby_dyna_vars; \
ruby_dyna_vars = 0;
-#define POP_VARS() \
- if (_old && (ruby_scope->flags & SCOPE_DONT_RECYCLE)) {\
- if (RBASIC(_old)->flags) /* unless it's already recycled */ \
- FL_SET(_old, DVAR_DONT_RECYCLE); \
- }\
- ruby_dyna_vars = _old; \
+#define POP_VARS() \
+ if (_old && (ruby_scope->flags & SCOPE_DONT_RECYCLE)) \
+ FL_SET(_old, DVAR_DONT_RECYCLE); \
+ ruby_dyna_vars = _old; \
}
#define DVAR_DONT_RECYCLE FL_USER2
@@ -1351,10 +1349,8 @@ rb_eval_cmd(cmd, arg)
volatile int safe = ruby_safe_level;
if (TYPE(cmd) != T_STRING) {
- PUSH_ITER(ITER_NOT);
- val = rb_funcall2(cmd, rb_intern("call"), RARRAY(arg)->len, RARRAY(arg)->ptr);
- POP_ITER();
- return val;
+ return rb_funcall2(cmd, rb_intern("call"),
+ RARRAY(arg)->len, RARRAY(arg)->ptr);
}
saved_scope = ruby_scope;
@@ -2740,7 +2736,7 @@ rb_eval(self, n)
val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval));
}
argv[argc-1] = val;
- rb_funcall2(recv, aset, argc, argv);
+ val = rb_funcall2(recv, aset, argc, argv);
result = val;
}
break;
@@ -3645,8 +3641,8 @@ rb_yield_0(val, self, klass, pcall)
int state;
static unsigned serial = 1;
- if (!rb_block_given_p()) {
- rb_raise(rb_eLocalJumpError, "no block given");
+ if (!(rb_block_given_p() || rb_f_block_given_p())) {
+ rb_raise(rb_eLocalJumpError, "yield called out of block");
}
PUSH_VARS();
@@ -3925,7 +3921,7 @@ assign(self, lhs, val, pcall)
VALUE
rb_iterate(it_proc, data1, bl_proc, data2)
- VALUE (*it_proc) _((VALUE)), (*bl_proc)(ANYARGS);
+ VALUE (*it_proc)(), (*bl_proc)();
VALUE data1, data2;
{
int state;
@@ -3999,10 +3995,10 @@ handle_rescue(self, node)
VALUE
#ifdef HAVE_STDARG_PROTOTYPES
-rb_rescue2(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*r_proc)(ANYARGS), VALUE data2, ...)
+rb_rescue2(VALUE (*b_proc)(), VALUE data1, VALUE (*r_proc)(), VALUE data2, ...)
#else
rb_rescue2(b_proc, data1, r_proc, data2, va_alist)
- VALUE (*b_proc)(ANYARGS), (*r_proc)(ANYARGS);
+ VALUE (*b_proc)(), (*r_proc)();
VALUE data1, data2;
va_dcl
#endif
@@ -4093,9 +4089,8 @@ rb_protect(proc, data, state)
VALUE
rb_ensure(b_proc, data1, e_proc, data2)
VALUE (*b_proc)();
- VALUE data1;
VALUE (*e_proc)();
- VALUE data2;
+ VALUE data1, data2;
{
int state;
volatile VALUE result = Qnil;
@@ -5054,9 +5049,6 @@ rb_f_eval(argc, argv, self)
rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline);
if (ruby_safe_level >= 4) {
StringValue(src);
- if (!NIL_P(scope) && !OBJ_TAINTED(scope)) {
- rb_raise(rb_eSecurityError, "Insecure: can't modify trusted binding");
- }
}
else {
SafeStringValue(src);
@@ -5098,7 +5090,6 @@ exec_under(func, under, args)
PUSH_CLASS();
ruby_class = under;
PUSH_FRAME();
- ruby_frame->self = _frame.prev->self;
ruby_frame->last_func = _frame.prev->last_func;
ruby_frame->last_class = _frame.prev->last_class;
ruby_frame->argc = _frame.prev->argc;
@@ -5194,7 +5185,7 @@ yield_under(under, self)
return exec_under(yield_under_i, under, self);
}
-static VALUE
+VALUE
specific_eval(argc, argv, klass, self)
int argc;
VALUE *argv;
@@ -5968,19 +5959,11 @@ rb_f_at_exit()
void
rb_exec_end_proc()
{
- struct end_proc_data *link, *save;
+ struct end_proc_data *link;
int status;
- save = link = end_procs;
- while (link) {
- rb_protect((VALUE(*)_((VALUE)))link->func, link->data, &status);
- if (status) {
- error_handle(status);
- }
- link = link->next;
- }
link = end_procs;
- while (link != save) {
+ while (link) {
rb_protect((VALUE(*)_((VALUE)))link->func, link->data, &status);
if (status) {
error_handle(status);
@@ -6954,14 +6937,14 @@ static VALUE
method_proc(method)
VALUE method;
{
- return rb_iterate((VALUE(*)_((VALUE)))mproc, 0, bmcall, method);
+ return rb_iterate(mproc, 0, bmcall, method);
}
static VALUE
umethod_proc(method)
VALUE method;
{
- return rb_iterate((VALUE(*)_((VALUE)))mproc, 0, umcall, method);
+ return rb_iterate(mproc, 0, umcall, method);
}
static VALUE
@@ -9080,7 +9063,7 @@ rb_catch(tag, proc, data)
VALUE (*proc)();
VALUE data;
{
- return rb_iterate((VALUE(*)_((VALUE)))catch_i, rb_intern(tag), proc, data);
+ return rb_iterate(catch_i, rb_intern(tag), proc, data);
}
static VALUE
diff --git a/file.c b/file.c
index 24d3de2ab8..bcce2008a5 100644
--- a/file.c
+++ b/file.c
@@ -2237,7 +2237,7 @@ path_check_1(path)
{
struct stat st;
char *p0 = RSTRING(path)->ptr;
- char *p, *s;
+ char *p = 0, *s;
if (!is_absolute_path(p0)) {
char *buf = my_getcwd();
@@ -2281,8 +2281,8 @@ rb_path_check(path)
if (!path_check_1(rb_str_new(p0, p - p0))) {
return 0; /* not safe */
}
- if (p0 > pend) break;
p0 = p + 1;
+ if (p0 > pend) break;
p = strchr(p0, sep);
if (!p) p = pend;
}
diff --git a/mkconfig.rb b/mkconfig.rb
index 5107ef69d7..05b5916997 100644
--- a/mkconfig.rb
+++ b/mkconfig.rb
@@ -39,9 +39,9 @@ File.foreach "config.status" do |line|
next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name
next if $so_name and /^RUBY_SO_NAME$/ =~ name
v = " CONFIG[\"" + name + "\"] = " +
- val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?(\w+)\}?/) {
+ val.sub(/^\s*(.*)\s*$/, '\1').gsub(/\$\{?(\w+)\}?/) {
"$(#{$1})"
- } + "\n"
+ }.dump + "\n"
if fast[name]
v_fast << v
else
diff --git a/range.c b/range.c
index 9f6581f14b..abfebf5032 100644
--- a/range.c
+++ b/range.c
@@ -201,6 +201,38 @@ range_eqq(range, obj)
}
static VALUE
+range_eql(range, obj)
+ VALUE range, obj;
+{
+ if (range == obj) return Qtrue;
+ if (!rb_obj_is_kind_of(obj, rb_cRange)) return Qfalse;
+
+ if (!rb_eql(rb_ivar_get(range, id_beg), rb_ivar_get(obj, id_beg)))
+ return Qfalse;
+ if (!rb_eql(rb_ivar_get(range, id_end), rb_ivar_get(obj, id_end)))
+ return Qfalse;
+
+ if (EXCL(range) != EXCL(obj)) return Qfalse;
+
+ return Qtrue;
+}
+
+static VALUE
+range_hash(range, obj)
+ VALUE range, obj;
+{
+ long hash = EXCL(range);
+ VALUE v;
+
+ v = rb_hash(rb_ivar_get(range, id_beg));
+ hash ^= v << 1;
+ v = rb_hash(rb_ivar_get(range, id_end));
+ hash ^= v << 9;
+
+ return INT2FIX(hash);
+}
+
+static VALUE
range_each(range)
VALUE range;
{
@@ -524,6 +556,8 @@ Init_Range()
rb_define_method(rb_cRange, "initialize", range_initialize, -1);
rb_define_method(rb_cRange, "==", range_eq, 1);
rb_define_method(rb_cRange, "===", range_eqq, 1);
+ rb_define_method(rb_cRange, "eql?", range_eql, 1);
+ rb_define_method(rb_cRange, "hash", range_hash, 0);
rb_define_method(rb_cRange, "each", range_each, 0);
rb_define_method(rb_cRange, "step", range_step, -1);
rb_define_method(rb_cRange, "first", range_first, 0);