From 2f2252291f854169cc8611ee30e8ab2a5a70074a Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 7 Mar 2005 02:05:08 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/ruby/trunk@8098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/cgi/session.rb | 4 ++-- lib/pp.rb | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb index 874179939..2bb6571bf 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 diff --git a/lib/pp.rb b/lib/pp.rb index 3fd3aeab3..3826a12f7 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -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 -- cgit