2022-05-24 10:31:21 -04:00
|
|
|
##
|
|
|
|
# Binding to [libkernaux](https://github.com/tailix/libkernaux) - auxiliary
|
|
|
|
# library for kernel development.
|
|
|
|
#
|
2022-01-30 00:12:40 -05:00
|
|
|
module KernAux
|
|
|
|
DEFAULT_ASSERT_CB = @assert_cb = lambda { |file, line, msg|
|
|
|
|
raise AssertError, "#{file}:#{line}:#{msg}"
|
|
|
|
}
|
|
|
|
|
2022-05-24 10:31:21 -04:00
|
|
|
SPRINTF1_BUFFER_SIZE = 10_000
|
|
|
|
|
|
|
|
def self.sprintf(*args)
|
|
|
|
args.map do |arg|
|
|
|
|
if arg.is_a? Array
|
|
|
|
sprintf1(*arg)
|
|
|
|
else
|
|
|
|
arg
|
|
|
|
end
|
|
|
|
end.join.freeze
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.sprintf1(format, *args)
|
|
|
|
snprintf1(SPRINTF1_BUFFER_SIZE, format, *args).first
|
|
|
|
end
|
|
|
|
|
2022-01-30 00:12:40 -05:00
|
|
|
class Error < RuntimeError; end
|
|
|
|
class AssertError < Error; end
|
|
|
|
end
|