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 | 2f2252291f854169cc8611ee30e8ab2a5a70074a (patch) | |
| tree | 79b669fd89b447f950a4faced7ceebcba65b8f8e /lib/pp.rb | |
| parent | fbe2cb41aacf91d61d452995994a350c290e9aef (diff) | |
| download | ruby-2f2252291f854169cc8611ee30e8ab2a5a70074a.tar.gz ruby-2f2252291f854169cc8611ee30e8ab2a5a70074a.tar.xz ruby-2f2252291f854169cc8611ee30e8ab2a5a70074a.zip | |
* 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
Diffstat (limited to 'lib/pp.rb')
| -rw-r--r-- | lib/pp.rb | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -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 |
