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

This commit is contained in:
Florian Nücke 2015-05-01 11:51:25 +02:00
commit 5f1c6af0f3
4 changed files with 20 additions and 24 deletions

View File

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

View File

@ -17,9 +17,6 @@ function memoryStream:close()
end
function memoryStream:seek()
if self.closed then
error("attempt to use a closed stream")
end
return nil, "bad file descriptor"
end
@ -28,7 +25,7 @@ function memoryStream:read(n)
if self.buffer == "" and self.redirect.read then
return self.redirect.read:read(n)
else
error("attempt to use a closed stream")
return nil -- eof
end
end
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 #args == 0 then
while ( true )
do
io.write("y\n")
while pcall(io.write, "y\n") do
os.sleep(0)
end
else
while ( true )
do
for i=1, #args, 1
do
io.write(args[i], " ")
repeat
local ok = true
for i=1, #args, 1 do
ok = ok and pcall(io.write, args[i], " ")
end
io.write("\n")
pcall(io.write, "\n")
os.sleep(0)
end
until not ok
end
return 0

View File

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