Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

condition updated to preven printf from sprintf redefinition

  • Loading branch information...
commit a9247f723abf401fcf940fffaa984b516cc61052 1 parent 3705bfb
@matz matz authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.