aboutsummaryrefslogtreecommitdiffstats
path: root/lib/pp.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-07 02:05:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-07 02:05:08 +0000
commit6645b928266cf7f8139f58b6b260e82f291d8446 (patch)
tree79b669fd89b447f950a4faced7ceebcba65b8f8e /lib/pp.rb
parent57b3ed4cda8882429590f761f9d545eee88823a3 (diff)
downloadruby-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
Diffstat (limited to 'lib/pp.rb')
-rw-r--r--lib/pp.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/pp.rb b/lib/pp.rb
index 3fd3aeab3a..3826a12f79 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