diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-03-07 02:05:08 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-03-07 02:05:08 +0000 |
commit | 6645b928266cf7f8139f58b6b260e82f291d8446 (patch) | |
tree | 79b669fd89b447f950a4faced7ceebcba65b8f8e | |
parent | 57b3ed4cda8882429590f761f9d545eee88823a3 (diff) | |
download | ruby-6645b928266cf7f8139f58b6b260e82f291d8446.tar.gz |
* object.c (inspect_obj): unintended space removal.
[ruby-dev:25810]
* eval.c (rb_exec_recursive): should not use NODE in disclosed
context. [ruby-dev:25812]
* io.c (rb_f_open): need not to check if to_open value is a
T_FILE. [ruby-dev:25812]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | .cvsignore | 1 | ||||
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | eval.c | 84 | ||||
-rw-r--r-- | io.c | 3 | ||||
-rw-r--r-- | lib/cgi/session.rb | 4 | ||||
-rw-r--r-- | lib/pp.rb | 24 | ||||
-rw-r--r-- | object.c | 2 | ||||
-rw-r--r-- | test/soap/header/server.cgi | 8 |
8 files changed, 95 insertions, 42 deletions
diff --git a/.cvsignore b/.cvsignore index 0c885edbf7..62afb836b0 100644 --- a/.cvsignore +++ b/.cvsignore @@ -10,6 +10,7 @@ COPYING.LIB ChangeLog.pre-alpha ChangeLog.pre1_1 +ChangeLog-1.8.0 Makefile README.fat-patch README.v6 @@ -1,3 +1,14 @@ +Mon Mar 7 10:28:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org> + + * object.c (inspect_obj): unintended space removal. + [ruby-dev:25810] + + * eval.c (rb_exec_recursive): should not use NODE in disclosed + context. [ruby-dev:25812] + + * io.c (rb_f_open): need not to check if to_open value is a + T_FILE. [ruby-dev:25812] + Mon Mar 7 01:21:01 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * ext/tk/tkutil/tkutil.c: follow the change of st.c (committed @@ -12991,49 +12991,83 @@ rb_throw(tag, val) rb_f_throw(2, argv); } -VALUE -rb_exec_recursive(func, obj, arg) - VALUE (*func)(ANYARGS); /* VALUE obj, VALUE arg, int flag */ - VALUE obj, arg; +static VALUE +recursive_check(obj) + VALUE obj; { - VALUE list = rb_thread_local_aref(rb_thread_current(), recursive_key); - int found = Qfalse; + VALUE hash = rb_thread_local_aref(rb_thread_current(), recursive_key); + + if (NIL_P(hash) || TYPE(hash) != T_HASH) { + return Qfalse; + } + else { + VALUE list = rb_hash_aref(hash, ID2SYM(ruby_frame->this_func)); - if (NIL_P(list) || TYPE(list) != T_NODE) { + if (NIL_P(list)) return Qfalse; + return rb_ary_includes(list, rb_obj_id(obj)); + } +} + +static void +recursive_push(obj) + VALUE obj; +{ + VALUE hash = rb_thread_local_aref(rb_thread_current(), recursive_key); + VALUE list, sym; + + sym = ID2SYM(ruby_frame->this_func); + if (NIL_P(hash) || TYPE(hash) != T_HASH) { + hash = rb_hash_new(); + rb_thread_local_aset(rb_thread_current(), recursive_key, hash); list = Qnil; } else { - NODE *tmp = (NODE*)list; - - while (!NIL_P(tmp)) { - if (tmp->nd_cfnc == func && tmp->nd_tval == obj) { - found = Qtrue; - break; - } - tmp = tmp->nd_next; - } + list = rb_hash_aref(hash, sym); + } + if (NIL_P(list)) { + list = rb_ary_new(); + rb_hash_aset(hash, sym, list); + } + rb_ary_push(list, rb_obj_id(obj)); +} + +static void +recursive_pop() +{ + VALUE hash = rb_thread_local_aref(rb_thread_current(), recursive_key); + VALUE list, sym; + + sym = ID2SYM(ruby_frame->this_func); + if (NIL_P(hash) || TYPE(hash) != T_HASH) { + rb_bug("invalid inspect_tbl hash"); + } + list = rb_hash_aref(hash, sym); + if (NIL_P(list) || TYPE(list) != T_ARRAY) { + rb_bug("invalid inspect_tbl list"); } - if (found) { + rb_ary_pop(list); +} + +VALUE +rb_exec_recursive(func, obj, arg) + VALUE (*func)(ANYARGS); /* VALUE obj, VALUE arg, int flag */ + VALUE obj, arg; +{ + if (recursive_check(obj)) { return (*func)(obj, arg, Qtrue); } else { - NODE *node = rb_node_newnode(NODE_MEMO, (VALUE)func, obj, list); + recursive_push(obj); VALUE result; int state; - rb_thread_local_aset(rb_thread_current(), recursive_key, (VALUE)node); PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = (*func)(obj, arg, Qfalse); } POP_TAG(); + recursive_pop(); if (state) JUMP_TAG(state); - - /* remove pushed tag */ - list = rb_thread_local_aref(rb_thread_current(), recursive_key); - node = (NODE*)list; - - rb_thread_local_aset(rb_thread_current(), recursive_key, (VALUE)node->nd_next); return result; } } @@ -3277,9 +3277,6 @@ rb_f_open(argc, argv) if (rb_respond_to(argv[0], to_open)) { VALUE io = rb_funcall2(argv[0], to_open, argc-1, argv+1); - if (TYPE(io) != T_FILE) { - rb_raise(rb_eTypeError, "to_open should return IO value"); - } if (rb_block_given_p()) { return rb_ensure(rb_yield, io, io_close, io); } diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb index 8741799390..2bb6571bf6 100644 --- a/lib/cgi/session.rb +++ b/lib/cgi/session.rb @@ -155,8 +155,8 @@ class CGI # class Session - #:nodoc: - class NoSession < RuntimeError; end + class NoSession < RuntimeError #:nodoc: + end # The id of this session. attr_reader :session_id, :new_session @@ -95,19 +95,29 @@ class PP < PrettyPrint def guard_inspect_key if Thread.current[InspectKey] == nil - Thread.current[InspectKey] = [] + Thread.current[InspectKey] = {inspect: []} end - save = Thread.current[InspectKey] + save = Thread.current[InspectKey][:inspect] begin - Thread.current[InspectKey] = [] + Thread.current[InspectKey][:inspect] = [] yield ensure - Thread.current[InspectKey] = save + Thread.current[InspectKey][:inspect] = save end end + def check_inspect_key(id) + Thread.current[InspectKey][:inspect].include?(id) + end + def push_inspect_key(id) + Thread.current[InspectKey][:inspect] << id + end + def pop_inspect_key + Thread.current[InspectKey][:inspect].pop + end + # Adds +obj+ to the pretty printing buffer # using Object#pretty_print or Object#pretty_print_cycle. # @@ -116,16 +126,16 @@ class PP < PrettyPrint def pp(obj) id = obj.__id__ - if Thread.current[InspectKey].include? id + if check_inspect_key(id) group {obj.pretty_print_cycle self} return end begin - Thread.current[InspectKey] << id + push_inspect_key(id) group {obj.pretty_print self} ensure - Thread.current[InspectKey].pop unless PP.sharing_detection + pop_inspect_key unless PP.sharing_detection end end @@ -350,7 +350,7 @@ inspect_obj(obj, str, recur) int recur; { if (recur) { - rb_str_cat2(str, "..."); + rb_str_cat2(str, " ..."); } else { st_foreach_safe(ROBJECT(obj)->iv_tbl, inspect_i, str); diff --git a/test/soap/header/server.cgi b/test/soap/header/server.cgi index f9739d0d15..a4326828cc 100644 --- a/test/soap/header/server.cgi +++ b/test/soap/header/server.cgi @@ -85,18 +85,18 @@ class AuthHeaderPortServer < SOAP::RPC::CGIStub end def on_simple_inbound(my_header, mu) - auth = false + auth_p = false userid = my_header["userid"] passwd = my_header["passwd"] if login(userid, passwd) - auth = true + auth_p = true elsif sessionid = my_header["sessionid"] if userid = auth(sessionid) destroy_session(sessionid) - auth = true + auth_p = true end end - raise RuntimeError.new("authentication failed") unless auth + raise RuntimeError.new("authentication failed") unless auth_p @userid = userid @sessionid = create_session(userid) end |