* lib/irb/ext/multi-irb.rb: fixed indent.

* lib/irb/output-method.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2014-08-10 01:05:08 +00:00
Родитель f9a81499ff
Коммит 0b7979a8fd
2 изменённых файлов: 72 добавлений и 72 удалений

Просмотреть файл

@ -84,9 +84,9 @@ module IRB
# See Thread#exit for more information.
def kill(*keys)
for key in keys
th, _ = search(key)
IRB.fail IrbAlreadyDead unless th.alive?
th.exit
th, _ = search(key)
IRB.fail IrbAlreadyDead unless th.alive?
th.exit
end
end
@ -106,15 +106,15 @@ module IRB
# Raises a NoSuchJob exception if no job can be found with the given +key+.
def search(key)
job = case key
when Integer
@jobs[key]
when Irb
@jobs.find{|k, v| v.equal?(key)}
when Thread
@jobs.assoc(key)
else
@jobs.find{|k, v| v.context.main.equal?(key)}
end
when Integer
@jobs[key]
when Irb
@jobs.find{|k, v| v.equal?(key)}
when Thread
@jobs.assoc(key)
else
@jobs.find{|k, v| v.context.main.equal?(key)}
end
IRB.fail NoSuchJob, key if job.nil?
job
end
@ -123,21 +123,21 @@ module IRB
def delete(key)
case key
when Integer
IRB.fail NoSuchJob, key unless @jobs[key]
@jobs[key] = nil
IRB.fail NoSuchJob, key unless @jobs[key]
@jobs[key] = nil
else
catch(:EXISTS) do
@jobs.each_index do
|i|
if @jobs[i] and (@jobs[i][0] == key ||
@jobs[i][1] == key ||
@jobs[i][1].context.main.equal?(key))
@jobs[i] = nil
throw :EXISTS
end
end
IRB.fail NoSuchJob, key
end
catch(:EXISTS) do
@jobs.each_index do
|i|
if @jobs[i] and (@jobs[i][0] == key ||
@jobs[i][1] == key ||
@jobs[i][1].context.main.equal?(key))
@jobs[i] = nil
throw :EXISTS
end
end
IRB.fail NoSuchJob, key
end
end
until assoc = @jobs.pop; end unless @jobs.empty?
@jobs.push assoc
@ -147,25 +147,25 @@ module IRB
def inspect
ary = []
@jobs.each_index do
|i|
th, irb = @jobs[i]
next if th.nil?
|i|
th, irb = @jobs[i]
next if th.nil?
if th.alive?
if th.stop?
t_status = "stop"
else
t_status = "running"
end
else
t_status = "exited"
end
ary.push format("#%d->%s on %s (%s: %s)",
i,
irb.context.irb_name,
irb.context.main,
th,
t_status)
if th.alive?
if th.stop?
t_status = "stop"
else
t_status = "running"
end
else
t_status = "exited"
end
ary.push format("#%d->%s on %s (%s: %s)",
i,
irb.context.irb_name,
irb.context.main,
th,
t_status)
end
ary.join("\n")
end
@ -192,39 +192,39 @@ module IRB
parent_thread = Thread.current
Thread.start do
begin
irb = Irb.new(workspace, file)
irb = Irb.new(workspace, file)
rescue
print "Subirb can't start with context(self): ", workspace.main.inspect, "\n"
print "return to main irb\n"
Thread.pass
Thread.main.wakeup
Thread.exit
print "Subirb can't start with context(self): ", workspace.main.inspect, "\n"
print "return to main irb\n"
Thread.pass
Thread.main.wakeup
Thread.exit
end
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
@JobManager.insert(irb)
@JobManager.current_job = irb
begin
system_exit = false
catch(:IRB_EXIT) do
irb.eval_input
end
system_exit = false
catch(:IRB_EXIT) do
irb.eval_input
end
rescue SystemExit
system_exit = true
raise
#fail
system_exit = true
raise
#fail
ensure
unless system_exit
@JobManager.delete(irb)
if @JobManager.current_job == irb
if parent_thread.alive?
@JobManager.current_job = @JobManager.irb(parent_thread)
parent_thread.run
else
@JobManager.current_job = @JobManager.main_irb
@JobManager.main_thread.run
end
end
end
unless system_exit
@JobManager.delete(irb)
if @JobManager.current_job == irb
if parent_thread.alive?
@JobManager.current_job = @JobManager.irb(parent_thread)
parent_thread.run
else
@JobManager.current_job = @JobManager.main_irb
@JobManager.main_thread.run
end
end
end
end
end
Thread.stop

Просмотреть файл

@ -35,7 +35,7 @@ module IRB
# #parse_printf_format
def printf(format, *opts)
if /(%*)%I/ =~ format
format, opts = parse_printf_format(format, opts)
format, opts = parse_printf_format(format, opts)
end
print sprintf(format, *opts)
end
@ -58,8 +58,8 @@ module IRB
# character.
def puts(*objs)
for obj in objs
print(*obj)
print "\n"
print(*obj)
print "\n"
end
end