* string.c (rb_str_upto): method result must be checked. [ruby-dev:24504]

* eval.c (error_print): ditto.  [ruby-dev:24519]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2004-10-18 23:47:32 +00:00
parent f2549e0bf7
commit 39324f819f
3 changed files with 64 additions and 56 deletions

View File

@ -1,3 +1,9 @@
Tue Oct 19 08:47:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_upto): method result must be checked. [ruby-dev:24504]
* eval.c (error_print): ditto. [ruby-dev:24519]
Mon Oct 18 23:37:05 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (r_object0): check inheritance by the internal function.

61
eval.c
View File

@ -733,9 +733,9 @@ struct RVarmap *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); \
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; \
} while (0)
@ -983,15 +983,15 @@ static void scope_dup _((struct SCOPE *));
#define POP_SCOPE() \
if (ruby_scope->flags & SCOPE_DONT_RECYCLE) {\
if (_old) scope_dup(_old); \
if (_old) scope_dup(_old); \
} \
if (!(ruby_scope->flags & SCOPE_MALLOC)) {\
ruby_scope->local_vars = 0; \
ruby_scope->local_tbl = 0; \
if (!(ruby_scope->flags & SCOPE_DONT_RECYCLE) && \
ruby_scope != top_scope) { \
ruby_scope != top_scope) { \
rb_gc_force_recycle((VALUE)ruby_scope);\
} \
} \
} \
ruby_scope->flags |= SCOPE_NOSTACK; \
ruby_scope = _old; \
@ -1031,7 +1031,7 @@ void
ruby_set_current_source()
{
if (ruby_current_node) {
ruby_sourcefile = ruby_current_node->nd_file;
ruby_sourcefile = ruby_current_node->nd_file;
ruby_sourceline = nd_line(ruby_current_node);
}
}
@ -1130,6 +1130,7 @@ error_print()
eclass = CLASS_OF(ruby_errinfo);
if (EXEC_TAG() == 0) {
e = rb_funcall(ruby_errinfo, rb_intern("message"), 0, 0);
StringValue(e);
einfo = RSTRING(e)->ptr;
elen = RSTRING(e)->len;
}
@ -1712,7 +1713,7 @@ rb_eval_cmd(cmd, arg, level)
val = eval(ruby_top_self, cmd, Qnil, 0, 0);
}
if (ruby_scope->flags & SCOPE_DONT_RECYCLE)
scope_dup(saved_scope);
scope_dup(saved_scope);
ruby_scope = saved_scope;
ruby_safe_level = safe;
POP_TAG();
@ -2093,25 +2094,25 @@ copy_node_scope(node, rval)
}\
else if (nd_type(n) == NODE_ARRAY) {\
argc=alen;\
if (argc > 0) {\
int i;\
if (argc > 0) {\
int i;\
n = anode;\
argv = TMP_ALLOC(argc);\
for (i=0;i<argc;i++) {\
argv[i] = rb_eval(self,n->nd_head);\
n=n->nd_next;\
}\
}\
else {\
}\
else {\
argc = 0;\
argv = 0;\
}\
}\
}\
else {\
VALUE args = rb_eval(self,n);\
VALUE args = rb_eval(self,n);\
if (TYPE(args) != T_ARRAY)\
args = rb_ary_to_ary(args);\
argc = RARRAY(args)->len;\
argc = RARRAY(args)->len;\
argv = ALLOCA_N(VALUE, argc);\
MEMCPY(argv, RARRAY(args)->ptr, VALUE, argc);\
}\
@ -2124,7 +2125,7 @@ copy_node_scope(node, rval)
int tmp_iter = ruby_iter->iter;\
if (tmp_iter == ITER_PRE) {\
ruby_block = ruby_block->outer;\
tmp_iter = ITER_NOT;\
tmp_iter = ITER_NOT;\
}\
PUSH_ITER(tmp_iter)
@ -2150,13 +2151,13 @@ arg_defined(self, node, buf, type)
if (!node) return type; /* no args */
if (nd_type(node) == NODE_ARRAY) {
argc=node->nd_alen;
if (argc > 0) {
if (argc > 0) {
for (i=0;i<argc;i++) {
if (!is_defined(self, node->nd_head, buf, 0))
return 0;
node = node->nd_next;
}
}
}
}
else if (!is_defined(self, node, buf, 0)) {
return 0;
@ -2687,7 +2688,7 @@ rb_eval(self, n)
/* nodes for speed-up(literal match) */
case NODE_MATCH3:
{
{
VALUE r = rb_eval(self,node->nd_recv);
VALUE l = rb_eval(self,node->nd_value);
if (TYPE(l) == T_STRING) {
@ -3000,7 +3001,7 @@ rb_eval(self, n)
break;
case NODE_RESCUE:
{
{
volatile VALUE e_info = ruby_errinfo;
volatile int rescuing = 0;
@ -3051,7 +3052,7 @@ rb_eval(self, n)
goto again;
}
}
break;
break;
case NODE_ENSURE:
PUSH_TAG(PROT_NONE);
@ -3609,8 +3610,8 @@ rb_eval(self, n)
nd_set_type(node, NODE_LIT);
node->nd_lit = result;
break;
case NODE_LIT:
/* other thread may replace NODE_DREGX_ONCE to NODE_LIT */
case NODE_LIT:
/* other thread may replace NODE_DREGX_ONCE to NODE_LIT */
goto again;
case NODE_DXSTR:
result = rb_funcall(self, '`', 1, str);
@ -3747,8 +3748,8 @@ rb_eval(self, n)
rb_raise(rb_eTypeError, "no outer class/module");
}
if (node->nd_super) {
super = rb_eval(self, node->nd_super);
rb_check_inheritable(super);
super = rb_eval(self, node->nd_super);
rb_check_inheritable(super);
}
else {
super = 0;
@ -4754,7 +4755,7 @@ rb_yield_0(val, self, klass, flags, avalue)
ruby_cref = (NODE*)old_cref;
ruby_wrapper = old_wrapper;
if (ruby_scope->flags & SCOPE_DONT_RECYCLE)
scope_dup(old_scope);
scope_dup(old_scope);
ruby_scope = old_scope;
scope_vmode = old_vmode;
switch (state) {
@ -8934,7 +8935,7 @@ method_arity(method)
case NODE_IVAR:
return INT2FIX(0);
case NODE_BMETHOD:
return proc_arity(body->nd_cval);
return proc_arity(body->nd_cval);
default:
body = body->nd_next; /* skip NODE_SCOPE */
if (nd_type(body) == NODE_BLOCK)
@ -10270,9 +10271,9 @@ rb_thread_schedule()
th->wait_for = 0;
th->select_value = 0;
found = 1;
intersect_fds(&readfds, &th->readfds, max);
intersect_fds(&writefds, &th->writefds, max);
intersect_fds(&exceptfds, &th->exceptfds, max);
intersect_fds(&readfds, &th->readfds, max);
intersect_fds(&writefds, &th->writefds, max);
intersect_fds(&exceptfds, &th->exceptfds, max);
}
}
END_FOREACH_FROM(curr, th);

View File

@ -1418,6 +1418,7 @@ rb_str_upto(beg, end, excl)
rb_yield(current);
if (!excl && rb_str_equal(current, end)) break;
current = rb_funcall(current, succ, 0, 0);
StringValue(current);
if (excl && rb_str_equal(current, end)) break;
if (RSTRING(current)->len > RSTRING(end)->len)
break;
@ -2064,7 +2065,7 @@ str_gsub(argc, argv, str, bang)
bp += len;
memcpy(bp, RSTRING(val)->ptr, RSTRING(val)->len);
bp += RSTRING(val)->len;
offset = END(0);
offset = END(0);
if (BEG(0) == END(0)) {
/*
* Always consume at least one character of the input string