summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-07-15 17:31:51 +0900
committerYukihiro Matsumoto <[email protected]>2012-07-15 17:31:51 +0900
commita9247f723abf401fcf940fffaa984b516cc61052 (patch)
tree2436f16313ae90b2fb413409d73f19ab6a7bca25
parent3705bfb02011fb4d7e81cd91876527299ae2c9bb (diff)
downloadmruby-a9247f723abf401fcf940fffaa984b516cc61052.tar.gz
mruby-a9247f723abf401fcf940fffaa984b516cc61052.zip
condition updated to preven printf from sprintf redefinition
-rw-r--r--mrblib/print.rb10
1 files 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