* 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
parent f9a81499ff
commit 0b7979a8fd
2 changed files with 72 additions and 72 deletions

View File

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

View File

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