From a9247f723abf401fcf940fffaa984b516cc61052 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Sun, 15 Jul 2012 17:31:51 +0900 Subject: condition updated to preven printf from sprintf redefinition --- mrblib/print.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mrblib/print.rb b/mrblib/print.rb index 3ebd77ee6..c4ce74d6b 100644 --- a/mrblib/print.rb +++ b/mrblib/print.rb @@ -51,11 +51,13 @@ module Kernel ## # 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 -- cgit v1.2.3