Browse files

condition updated to preven printf from sprintf redefinition

  • Loading branch information...
1 parent 3705bfb commit a9247f723abf401fcf940fffaa984b516cc61052 @matz matz committed Jul 15, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 mrblib/print.rb
View
10 mrblib/print.rb
@@ -51,11 +51,13 @@ def p(*args)
##
# Invoke method +sprintf+ and pass +*args+ to it.
# Pass return value to +print+ of STDOUT.
- def printf(*args)
- if Kernel.respond_to?(:sprintf)
+ if Kernel.respond_to?(:sprintf) and Kernel.respond_to?(:__printstr__)
+ def printf(*args)
__printstr__(sprintf(*args))
- else
- raise NotImplementedError.new('sprintf not available')
+ end
+ else
+ def printf(*args)
+ raise NotImplementedError.new('printf not available')
end
end

0 comments on commit a9247f7

Please sign in to comment.