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

* pack.c (pack_pack): template "m2" or "u2" caused inifinite loop.

* eval.c (ruby_finalize): should enclosed by PUSH_TAG/POP_TAG.

* eval.c (rb_mod_define_method): wrong comparison for blocks.

* gc.c (id2ref): should handle Symbol too.

* gc.c (id2ref): should print original ptr value

* eval.c (rb_iterate): NODE_CFUNC does not protect its data
  (nd_tval), so create new node NODE_IFUNC for iteration C
  function.

* eval.c (rb_yield_0): use NODE_IFUNC.

* gc.c (rb_gc_mark): support NODE_IFUNC.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-01-09 07:29:05 +00:00
parent 32d0e70329
commit 81084557eb
8 changed files with 74 additions and 34 deletions

View file

@ -1,3 +1,31 @@
Sat Jan 6 00:55:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_pack): template "m2" or "u2" caused inifinite loop.
Fri Jan 5 01:02:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (ruby_finalize): should enclosed by PUSH_TAG/POP_TAG.
Sun Dec 31 01:39:16 2000 Guy Decoux <decoux@moulon.inra.fr>
* eval.c (rb_mod_define_method): wrong comparison for blocks.
Sat Dec 30 19:28:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (id2ref): should handle Symbol too.
* gc.c (id2ref): should print original ptr value
Sat Dec 30 03:14:22 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_iterate): NODE_CFUNC does not protect its data
(nd_tval), so create new node NODE_IFUNC for iteration C
function.
* eval.c (rb_yield_0): use NODE_IFUNC.
* gc.c (rb_gc_mark): support NODE_IFUNC.
Fri Dec 29 11:41:55 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (mem_error): prohibit recursive mem_error().

4
dln.c
View file

@ -1166,7 +1166,7 @@ dln_strerror()
}
#if defined(_AIX)
#if defined(_AIX) && ! defined(_IA64)
static void
aix_loaderror(const char *pathname)
{
@ -1310,7 +1310,7 @@ dln_load(file)
}
#endif /* hpux */
#if defined(_AIX)
#if defined(_AIX) && ! defined(_IA64)
#define DLN_DEFINED
{
void (*init_fct)();

36
eval.c
View file

@ -1122,9 +1122,13 @@ void rb_exec_end_proc _((void));
void
ruby_finalize()
{
rb_trap_exit();
rb_exec_end_proc();
rb_gc_call_finalizer_at_exit();
PUSH_TAG(PROT_NONE);
if (EXEC_TAG() == 0) {
rb_trap_exit();
rb_exec_end_proc();
rb_gc_call_finalizer_at_exit();
}
POP_TAG();
}
void
@ -3526,7 +3530,7 @@ rb_yield_0(val, self, klass, acheck)
if (!node) {
result = Qnil;
}
else if (nd_type(node) == NODE_CFUNC) {
else if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
if (val == Qundef) val = rb_ary_new2(0);
result = (*node->nd_cfnc)(val, node->nd_tval, self);
}
@ -3744,7 +3748,7 @@ rb_iterate(it_proc, data1, bl_proc, data2)
{
int state;
volatile VALUE retval = Qnil;
NODE *node = NEW_CFUNC(bl_proc, data2);
NODE *node = NEW_IFUNC(bl_proc, data2);
VALUE self = ruby_top_self;
iter_retry:
@ -5980,7 +5984,7 @@ static VALUE
rb_f_binding(self)
VALUE self;
{
struct BLOCK *data;
struct BLOCK *data, *p;
struct RVarmap *vars;
VALUE bind;
@ -6003,9 +6007,11 @@ rb_f_binding(self)
data->prev = 0;
}
for (vars = data->dyna_vars; vars; vars = vars->next) {
if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
FL_SET(vars, DVAR_DONT_RECYCLE);
for (p = data; p; p = p->prev) {
for (vars = p->dyna_vars; vars; vars = vars->next) {
if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
FL_SET(vars, DVAR_DONT_RECYCLE);
}
}
scope_dup(data->scope);
POP_BLOCK();
@ -6063,7 +6069,7 @@ proc_new(klass)
VALUE klass;
{
volatile VALUE proc;
struct BLOCK *data;
struct BLOCK *data, *p;
struct RVarmap *vars;
if (!rb_block_given_p() && !rb_f_block_given_p()) {
@ -6085,9 +6091,11 @@ proc_new(klass)
}
data->flags |= BLOCK_DYNAMIC;
for (vars = data->dyna_vars; vars; vars = vars->next) {
if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
FL_SET(vars, DVAR_DONT_RECYCLE);
for (p = data; p; p = p->prev) {
for (vars = p->dyna_vars; vars; vars = vars->next) {
if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
FL_SET(vars, DVAR_DONT_RECYCLE);
}
}
scope_dup(data->scope);
proc_save_safe_level(proc);
@ -6630,7 +6638,7 @@ rb_mod_define_method(argc, argv, mod)
if (RDATA(body)->dmark == (RUBY_DATA_FUNC)bm_mark) {
rb_add_method(mod, id, NEW_DMETHOD(method_unbind(body)), NOEX_PUBLIC);
}
else if (RDATA(body)->dmark != (RUBY_DATA_FUNC)blk_mark) {
else if (RDATA(body)->dmark == (RUBY_DATA_FUNC)blk_mark) {
rb_add_method(mod, id, NEW_BMETHOD(body), NOEX_PUBLIC);
}
else {

15
gc.c
View file

@ -315,10 +315,7 @@ rb_data_object_alloc(klass, datap, dmark, dfree)
extern st_table *rb_class_tbl;
VALUE *rb_gc_stack_start = 0;
#if defined(__GNUC__) && __GNUC__ >= 2
__inline__
#endif
static int
static INLINE int
is_pointer_to_heap(ptr)
void *ptr;
{
@ -483,6 +480,7 @@ rb_gc_mark(ptr)
case NODE_OP_ASGN_AND:
rb_gc_mark(obj->as.node.u1.node);
/* fall through */
case NODE_IFUNC:
case NODE_METHOD: /* 2 */
case NODE_NOT:
case NODE_GASGN:
@ -1262,21 +1260,22 @@ static VALUE
id2ref(obj, id)
VALUE obj, id;
{
unsigned long ptr;
unsigned long ptr, p0;
rb_secure(4);
ptr = NUM2UINT(id);
p0 = ptr = NUM2UINT(id);
if (FIXNUM_P(ptr)) return (VALUE)ptr;
if (SYMBOL_P(ptr)) return (VALUE)ptr;
if (ptr == Qtrue) return Qtrue;
if (ptr == Qfalse) return Qfalse;
if (ptr == Qnil) return Qnil;
ptr = id ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */
if (!is_pointer_to_heap(ptr)) {
rb_raise(rb_eRangeError, "0x%x is not id value", ptr);
rb_raise(rb_eRangeError, "0x%x is not id value", p0);
}
if (BUILTIN_TYPE(ptr) == 0) {
rb_raise(rb_eRangeError, "0x%x is recycled object", ptr);
rb_raise(rb_eRangeError, "0x%x is recycled object", p0);
}
return (VALUE)ptr;
}

View file

@ -1,3 +1,4 @@
# Copyright (C) 2001 Yukihiro "Matz" Matsumoto
# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
# Copyright (C) 2000 Information-technology Promotion Agency, Japan
@ -15,14 +16,14 @@ class CGI
}
end
def create_new_id
def Session::create_new_id
require 'md5'
md5 = MD5::new
md5.update(String(Time::now))
md5.update(String(rand(0)))
md5.update(String($$))
md5.update('foobar')
@session_id = md5.hexdigest[0,16]
md5.hexdigest[0,16]
end
private :create_new_id
@ -31,7 +32,7 @@ class CGI
id, = option['session_id']
unless id
if option['new_session']
id = create_new_id
id = Session::create_new_id
end
end
unless id
@ -43,7 +44,7 @@ class CGI
if option.key?('new_session') and not option['new_session']
raise ArgumentError, "session_key `%s' should be supplied"%session_key
end
id = create_new_id
id = Session::create_new_id
end
end
@session_id = id
@ -54,9 +55,9 @@ class CGI
@output_cookies = [
Cookie::new("name" => session_key,
"value" => id,
"path" => if ENV["PATH_INFO"] then
File::dirname(ENV["PATH_INFO"])
elsif ENV["SCRIPT_NAME"] then
"path" => if option['session_path'] then
option['session_path']
elsif ENV["SCRIPT_NAME"] then
File::dirname(ENV["SCRIPT_NAME"])
else
""
@ -134,12 +135,14 @@ class CGI
end
def close
return unless @f.closed?
update
@f.close
end
def delete
path = @f.path
return unless @f.closed?
@f.close
File::unlink path
end

2
node.h
View file

@ -21,6 +21,7 @@ enum node_type {
NODE_METHOD,
NODE_FBODY,
NODE_CFUNC,
NODE_IFUNC,
NODE_SCOPE,
NODE_BLOCK,
NODE_IF,
@ -234,6 +235,7 @@ typedef struct RNode {
#define NEW_DEFN(i,a,d,p) rb_node_newnode(NODE_DEFN,p,i,NEW_RFUNC(a,d))
#define NEW_DEFS(r,i,a,d) rb_node_newnode(NODE_DEFS,r,i,NEW_RFUNC(a,d))
#define NEW_CFUNC(f,c) rb_node_newnode(NODE_CFUNC,f,c,0)
#define NEW_IFUNC(f,c) rb_node_newnode(NODE_IFUNC,f,c,0)
#define NEW_RFUNC(b1,b2) NEW_SCOPE(block_append(b1,b2))
#define NEW_SCOPE(b) rb_node_newnode(NODE_SCOPE,local_tbl(),cur_cref,(b))
#define NEW_BLOCK(a) rb_node_newnode(NODE_BLOCK,a,0,0)

2
pack.c
View file

@ -826,7 +826,7 @@ pack_pack(ary, fmt)
case 'm':
ptr = rb_str2cstr(NEXTFROM, &plen);
if (len <= 1)
if (len <= 2)
len = 45;
else
len = len / 3 * 3;

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.6.2"
#define RUBY_RELEASE_DATE "2000-12-29"
#define RUBY_RELEASE_DATE "2001-01-09"
#define RUBY_VERSION_CODE 162
#define RUBY_RELEASE_CODE 20001229
#define RUBY_RELEASE_CODE 20010109