Merge branch 'master-MC1.8' of github.com:MightyPirates/OpenComputers into OC1.5-MC1.8

This commit is contained in:
Florian Nücke 2015-05-01 11:53:13 +02:00
commit 0a0830d40e
4 changed files with 20 additions and 24 deletions

View File

@ -12,8 +12,8 @@ else
for i = 1, #args do for i = 1, #args do
local file, reason = io.open(shell.resolve(args[i])) local file, reason = io.open(shell.resolve(args[i]))
if not file then if not file then
io.stderr:write(reason) io.stderr:write(tostring(reason) .. "\n")
return os.exit(false)
end end
repeat repeat
local line = file:read("*L") local line = file:read("*L")

View File

@ -17,9 +17,6 @@ function memoryStream:close()
end end
function memoryStream:seek() function memoryStream:seek()
if self.closed then
error("attempt to use a closed stream")
end
return nil, "bad file descriptor" return nil, "bad file descriptor"
end end
@ -28,7 +25,7 @@ function memoryStream:read(n)
if self.buffer == "" and self.redirect.read then if self.buffer == "" and self.redirect.read then
return self.redirect.read:read(n) return self.redirect.read:read(n)
else else
error("attempt to use a closed stream") return nil -- eof
end end
end end
if self.buffer == "" then if self.buffer == "" then

View File

@ -23,20 +23,17 @@ end
-- If there are no arguments, print 'y' and new line, if there is print it. -- If there are no arguments, print 'y' and new line, if there is print it.
if #args == 0 then if #args == 0 then
while ( true ) while pcall(io.write, "y\n") do
do
io.write("y\n")
os.sleep(0) os.sleep(0)
end end
else else
while ( true ) repeat
do local ok = true
for i=1, #args, 1 for i=1, #args, 1 do
do ok = ok and pcall(io.write, args[i], " ")
io.write(args[i], " ")
end end
io.write("\n") pcall(io.write, "\n")
os.sleep(0) os.sleep(0)
end until not ok
end end
return 0 return 0

View File

@ -25,7 +25,7 @@ function buffer.new(mode, stream)
end end
function buffer:close() function buffer:close()
if not self.closed and (self.mode.w or self.mode.a) then if self.mode.w or self.mode.a then
self:flush() self:flush()
end end
self.closed = true self.closed = true
@ -33,14 +33,16 @@ function buffer:close()
end end
function buffer:flush() function buffer:flush()
local result, reason = self.stream:write(self.bufferWrite) if #self.bufferWrite > 0 then
if result then local result, reason = self.stream:write(self.bufferWrite)
self.bufferWrite = "" if result then
else self.bufferWrite = ""
if reason then
return nil, reason
else else
return nil, "bad file descriptor" if reason then
return nil, reason
else
return nil, "bad file descriptor"
end
end end
end end