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

* file.c (path_check_1): forgot to initialize 'p'.

* mkconfig.rb: use String#dump to generate Ruby string literal.

* range.c (range_eql): should override 'eql?'

* array.c (rb_ary_hash): should override 'hash' too.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-11-08 09:21:59 +00:00
parent dc98adf839
commit cf4451e8c2
6 changed files with 83 additions and 47 deletions

View file

@ -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> Tue Nov 6 14:38:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (security): always give warning for insecure PATH. * process.c (security): always give warning for insecure PATH.

View file

@ -107,14 +107,19 @@ $(LIBRUBY_SO): $(OBJS) dmyext.@OBJEXT@ miniruby$(EXEEXT)
install: rbconfig.rb install: rbconfig.rb
@MINIRUBY@ $(srcdir)/instruby.rb $(DESTDIR) @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@ @rm -f ext/extinit.c ext/extinit.@OBJEXT@ dmyext.@OBJEXT@
@-@MINIRUBY@ -Cext extmk.rb clean 2> /dev/null || true @-@MINIRUBY@ -Cext extmk.rb clean 2> /dev/null || true
@rm -f $(PROGRAM) miniruby$(EXEEXT) @rm -f $(PROGRAM) miniruby$(EXEEXT)
distclean:; @-@MINIRUBY@ -Cext extmk.rb distclean 2> /dev/null || true distclean-ext:
$(MAKE) clean @-@MINIRUBY@ -Cext extmk.rb distclean 2> /dev/null || true
@rm -f Makefile ext/extmk.rb config.h
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 ext/config.cache config.cache config.log config.status
@rm -f *~ core *.core gmon.out y.tab.c y.output ruby.imp @rm -f *~ core *.core gmon.out y.tab.c y.output ruby.imp

61
eval.c
View file

@ -594,17 +594,15 @@ new_blktag()
} }
struct RVarmap *ruby_dyna_vars; struct RVarmap *ruby_dyna_vars;
#define PUSH_VARS() { \ #define PUSH_VARS() { \
struct RVarmap * volatile _old; \ struct RVarmap * volatile _old; \
_old = ruby_dyna_vars; \ _old = ruby_dyna_vars; \
ruby_dyna_vars = 0; ruby_dyna_vars = 0;
#define POP_VARS() \ #define POP_VARS() \
if (_old && (ruby_scope->flags & SCOPE_DONT_RECYCLE)) {\ if (_old && (ruby_scope->flags & SCOPE_DONT_RECYCLE)) \
if (RBASIC(_old)->flags) /* unless it's already recycled */ \ FL_SET(_old, DVAR_DONT_RECYCLE); \
FL_SET(_old, DVAR_DONT_RECYCLE); \ ruby_dyna_vars = _old; \
}\
ruby_dyna_vars = _old; \
} }
#define DVAR_DONT_RECYCLE FL_USER2 #define DVAR_DONT_RECYCLE FL_USER2
@ -1351,10 +1349,8 @@ rb_eval_cmd(cmd, arg)
volatile int safe = ruby_safe_level; volatile int safe = ruby_safe_level;
if (TYPE(cmd) != T_STRING) { if (TYPE(cmd) != T_STRING) {
PUSH_ITER(ITER_NOT); return rb_funcall2(cmd, rb_intern("call"),
val = rb_funcall2(cmd, rb_intern("call"), RARRAY(arg)->len, RARRAY(arg)->ptr); RARRAY(arg)->len, RARRAY(arg)->ptr);
POP_ITER();
return val;
} }
saved_scope = ruby_scope; saved_scope = ruby_scope;
@ -2740,7 +2736,7 @@ rb_eval(self, n)
val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval)); val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval));
} }
argv[argc-1] = val; argv[argc-1] = val;
rb_funcall2(recv, aset, argc, argv); val = rb_funcall2(recv, aset, argc, argv);
result = val; result = val;
} }
break; break;
@ -3645,8 +3641,8 @@ rb_yield_0(val, self, klass, pcall)
int state; int state;
static unsigned serial = 1; static unsigned serial = 1;
if (!rb_block_given_p()) { if (!(rb_block_given_p() || rb_f_block_given_p())) {
rb_raise(rb_eLocalJumpError, "no block given"); rb_raise(rb_eLocalJumpError, "yield called out of block");
} }
PUSH_VARS(); PUSH_VARS();
@ -3925,7 +3921,7 @@ assign(self, lhs, val, pcall)
VALUE VALUE
rb_iterate(it_proc, data1, bl_proc, data2) rb_iterate(it_proc, data1, bl_proc, data2)
VALUE (*it_proc) _((VALUE)), (*bl_proc)(ANYARGS); VALUE (*it_proc)(), (*bl_proc)();
VALUE data1, data2; VALUE data1, data2;
{ {
int state; int state;
@ -3999,10 +3995,10 @@ handle_rescue(self, node)
VALUE VALUE
#ifdef HAVE_STDARG_PROTOTYPES #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 #else
rb_rescue2(b_proc, data1, r_proc, data2, va_alist) 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; VALUE data1, data2;
va_dcl va_dcl
#endif #endif
@ -4093,9 +4089,8 @@ rb_protect(proc, data, state)
VALUE VALUE
rb_ensure(b_proc, data1, e_proc, data2) rb_ensure(b_proc, data1, e_proc, data2)
VALUE (*b_proc)(); VALUE (*b_proc)();
VALUE data1;
VALUE (*e_proc)(); VALUE (*e_proc)();
VALUE data2; VALUE data1, data2;
{ {
int state; int state;
volatile VALUE result = Qnil; volatile VALUE result = Qnil;
@ -5054,9 +5049,6 @@ rb_f_eval(argc, argv, self)
rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline); rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline);
if (ruby_safe_level >= 4) { if (ruby_safe_level >= 4) {
StringValue(src); StringValue(src);
if (!NIL_P(scope) && !OBJ_TAINTED(scope)) {
rb_raise(rb_eSecurityError, "Insecure: can't modify trusted binding");
}
} }
else { else {
SafeStringValue(src); SafeStringValue(src);
@ -5098,7 +5090,6 @@ exec_under(func, under, args)
PUSH_CLASS(); PUSH_CLASS();
ruby_class = under; ruby_class = under;
PUSH_FRAME(); PUSH_FRAME();
ruby_frame->self = _frame.prev->self;
ruby_frame->last_func = _frame.prev->last_func; ruby_frame->last_func = _frame.prev->last_func;
ruby_frame->last_class = _frame.prev->last_class; ruby_frame->last_class = _frame.prev->last_class;
ruby_frame->argc = _frame.prev->argc; ruby_frame->argc = _frame.prev->argc;
@ -5194,7 +5185,7 @@ yield_under(under, self)
return exec_under(yield_under_i, under, self); return exec_under(yield_under_i, under, self);
} }
static VALUE VALUE
specific_eval(argc, argv, klass, self) specific_eval(argc, argv, klass, self)
int argc; int argc;
VALUE *argv; VALUE *argv;
@ -5968,19 +5959,11 @@ rb_f_at_exit()
void void
rb_exec_end_proc() rb_exec_end_proc()
{ {
struct end_proc_data *link, *save; struct end_proc_data *link;
int status; 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; link = end_procs;
while (link != save) { while (link) {
rb_protect((VALUE(*)_((VALUE)))link->func, link->data, &status); rb_protect((VALUE(*)_((VALUE)))link->func, link->data, &status);
if (status) { if (status) {
error_handle(status); error_handle(status);
@ -6954,14 +6937,14 @@ static VALUE
method_proc(method) method_proc(method)
VALUE method; VALUE method;
{ {
return rb_iterate((VALUE(*)_((VALUE)))mproc, 0, bmcall, method); return rb_iterate(mproc, 0, bmcall, method);
} }
static VALUE static VALUE
umethod_proc(method) umethod_proc(method)
VALUE method; VALUE method;
{ {
return rb_iterate((VALUE(*)_((VALUE)))mproc, 0, umcall, method); return rb_iterate(mproc, 0, umcall, method);
} }
static VALUE static VALUE
@ -9080,7 +9063,7 @@ rb_catch(tag, proc, data)
VALUE (*proc)(); VALUE (*proc)();
VALUE data; 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 static VALUE

4
file.c
View file

@ -2237,7 +2237,7 @@ path_check_1(path)
{ {
struct stat st; struct stat st;
char *p0 = RSTRING(path)->ptr; char *p0 = RSTRING(path)->ptr;
char *p, *s; char *p = 0, *s;
if (!is_absolute_path(p0)) { if (!is_absolute_path(p0)) {
char *buf = my_getcwd(); char *buf = my_getcwd();
@ -2281,8 +2281,8 @@ rb_path_check(path)
if (!path_check_1(rb_str_new(p0, p - p0))) { if (!path_check_1(rb_str_new(p0, p - p0))) {
return 0; /* not safe */ return 0; /* not safe */
} }
if (p0 > pend) break;
p0 = p + 1; p0 = p + 1;
if (p0 > pend) break;
p = strchr(p0, sep); p = strchr(p0, sep);
if (!p) p = pend; if (!p) p = pend;
} }

View file

@ -39,9 +39,9 @@ File.foreach "config.status" do |line|
next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name
next if $so_name and /^RUBY_SO_NAME$/ =~ name next if $so_name and /^RUBY_SO_NAME$/ =~ name
v = " CONFIG[\"" + name + "\"] = " + v = " CONFIG[\"" + name + "\"] = " +
val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?(\w+)\}?/) { val.sub(/^\s*(.*)\s*$/, '\1').gsub(/\$\{?(\w+)\}?/) {
"$(#{$1})" "$(#{$1})"
} + "\n" }.dump + "\n"
if fast[name] if fast[name]
v_fast << v v_fast << v
else else

34
range.c
View file

@ -200,6 +200,38 @@ range_eqq(range, obj)
return Qfalse; return Qfalse;
} }
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 static VALUE
range_each(range) range_each(range)
VALUE range; VALUE range;
@ -524,6 +556,8 @@ Init_Range()
rb_define_method(rb_cRange, "initialize", range_initialize, -1); rb_define_method(rb_cRange, "initialize", range_initialize, -1);
rb_define_method(rb_cRange, "==", range_eq, 1); rb_define_method(rb_cRange, "==", range_eq, 1);
rb_define_method(rb_cRange, "===", range_eqq, 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, "each", range_each, 0);
rb_define_method(rb_cRange, "step", range_step, -1); rb_define_method(rb_cRange, "step", range_step, -1);
rb_define_method(rb_cRange, "first", range_first, 0); rb_define_method(rb_cRange, "first", range_first, 0);