ruby: fix weird freeze when printing large strings to the console on linux64

develop
jj 2016-10-21 17:00:02 +02:00
parent f586692ed6
commit 97f29229cd
1 changed files with 12 additions and 2 deletions

@ -2,14 +2,24 @@
module Kernel
def puts(*a)
a.flatten.each { |l|
DFHack.print_str(l.to_s.chomp + "\n")
# XXX looks like print_str crashes with strings longer than 4096... maybe not nullterminated ?
# this workaround fixes it
s = l.to_s.chomp + "\n"
while s.length > 0
DFHack.print_str(s[0, 4000])
s[0, 4000] = ''
end
}
nil
end
def puts_err(*a)
a.flatten.each { |l|
DFHack.print_err(l.to_s.chomp + "\n")
s = l.to_s.chomp + "\n"
while s.length > 0
DFHack.print_err(s[0, 4000])
s[0, 4000] = ''
end
}
nil
end