summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-print/mrblib/print.rb
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:22 +0000
commitc21c3b0befeb46a51b6bf3758ffa30813bea0ff0 (patch)
tree9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-print/mrblib/print.rb
parentAdding upstream version 1.43.2. (diff)
downloadnetdata-c21c3b0befeb46a51b6bf3758ffa30813bea0ff0.tar.xz
netdata-c21c3b0befeb46a51b6bf3758ffa30813bea0ff0.zip
Adding upstream version 1.44.3.upstream/1.44.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-print/mrblib/print.rb')
-rw-r--r--web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-print/mrblib/print.rb64
1 files changed, 64 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-print/mrblib/print.rb b/web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-print/mrblib/print.rb
new file mode 100644
index 000000000..38a10661b
--- /dev/null
+++ b/web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-print/mrblib/print.rb
@@ -0,0 +1,64 @@
+##
+# Kernel
+#
+# ISO 15.3.1
+module Kernel
+ ##
+ # Invoke method +print+ on STDOUT and passing +*args+
+ #
+ # ISO 15.3.1.2.10
+ def print(*args)
+ i = 0
+ len = args.size
+ while i < len
+ __printstr__ args[i].to_s
+ i += 1
+ end
+ end
+
+ ##
+ # Invoke method +puts+ on STDOUT and passing +*args*+
+ #
+ # ISO 15.3.1.2.11
+ def puts(*args)
+ i = 0
+ len = args.size
+ while i < len
+ s = args[i].to_s
+ __printstr__ s
+ __printstr__ "\n" if (s[-1] != "\n")
+ i += 1
+ end
+ __printstr__ "\n" if len == 0
+ nil
+ end
+
+ ##
+ # Print human readable object description
+ #
+ # ISO 15.3.1.3.34
+ def p(*args)
+ i = 0
+ len = args.size
+ while i < len
+ __printstr__ args[i].inspect
+ __printstr__ "\n"
+ i += 1
+ end
+ args[0]
+ end
+
+ unless Kernel.respond_to?(:sprintf)
+ def printf(*args)
+ raise NotImplementedError.new('printf not available')
+ end
+ def sprintf(*args)
+ raise NotImplementedError.new('sprintf not available')
+ end
+ else
+ def printf(*args)
+ __printstr__(sprintf(*args))
+ nil
+ end
+ end
+end