mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
resolve ctrl-c problem.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
71364fe215
commit
840278d9cf
5 changed files with 66 additions and 27 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Thu May 17 05:23:52 2001 Keiju Ishitsuka <keiju@ishitsuka.com>
|
||||||
|
* lib/irb.rb lib/irb/multi-irb.rb lib/irb/ruby-lex.rb lib/irb/version.rb
|
||||||
|
resolve ctrl-c problem
|
||||||
|
|
||||||
Tue May 15 17:46:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue May 15 17:46:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (rb_ary_and): should not push frozen key string.
|
* array.c (rb_ary_and): should not push frozen key string.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# irb.rb - irb main module
|
# irb.rb - irb main module
|
||||||
# $Release Version: 0.7.3 $
|
# $Release Version: 0.7.4 $
|
||||||
# $Revision$
|
# $Revision$
|
||||||
# $Date$
|
# $Date$
|
||||||
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
||||||
|
@ -209,8 +209,7 @@ module IRB
|
||||||
case @signal_status
|
case @signal_status
|
||||||
when :IN_INPUT
|
when :IN_INPUT
|
||||||
print "^C\n"
|
print "^C\n"
|
||||||
@scanner.initialize_input
|
raise RubyLex::TerminateLineInput
|
||||||
print @context.io.prompt
|
|
||||||
when :IN_EVAL
|
when :IN_EVAL
|
||||||
IRB.irb_abort(self)
|
IRB.irb_abort(self)
|
||||||
when :IN_LOAD
|
when :IN_LOAD
|
||||||
|
|
|
@ -31,7 +31,7 @@ module IRB
|
||||||
|
|
||||||
def thread(key)
|
def thread(key)
|
||||||
th, irb = search(key)
|
th, irb = search(key)
|
||||||
irb
|
th
|
||||||
end
|
end
|
||||||
|
|
||||||
def irb(key)
|
def irb(key)
|
||||||
|
@ -58,6 +58,7 @@ module IRB
|
||||||
@current_job = irb
|
@current_job = irb
|
||||||
th.run
|
th.run
|
||||||
Thread.stop
|
Thread.stop
|
||||||
|
p "X"
|
||||||
@current_job = irb(Thread.current)
|
@current_job = irb(Thread.current)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ module IRB
|
||||||
when Integer
|
when Integer
|
||||||
@jobs[key]
|
@jobs[key]
|
||||||
when Irb
|
when Irb
|
||||||
@jobs.find{|k, v| v.equal?(irb)}
|
@jobs.find{|k, v| v.equal?(key)}
|
||||||
when Thread
|
when Thread
|
||||||
@jobs.assoc(key)
|
@jobs.assoc(key)
|
||||||
else
|
else
|
||||||
|
@ -156,6 +157,7 @@ module IRB
|
||||||
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
|
||||||
begin
|
begin
|
||||||
system_exit = false
|
system_exit = false
|
||||||
catch(:IRB_EXIT) do
|
catch(:IRB_EXIT) do
|
||||||
|
@ -200,8 +202,32 @@ module IRB
|
||||||
@JobManager.insert(@CONF[:MAIN_CONTEXT].irb)
|
@JobManager.insert(@CONF[:MAIN_CONTEXT].irb)
|
||||||
@JobManager.current_job = @CONF[:MAIN_CONTEXT].irb
|
@JobManager.current_job = @CONF[:MAIN_CONTEXT].irb
|
||||||
|
|
||||||
|
class Irb
|
||||||
|
def signal_handle
|
||||||
|
unless @context.ignore_sigint?
|
||||||
|
print "\nabort!!\n" if @context.verbose?
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
case @signal_status
|
||||||
|
when :IN_INPUT
|
||||||
|
print "^C\n"
|
||||||
|
IRB.JobManager.thread(self).raise RubyLex::TerminateLineInput
|
||||||
|
when :IN_EVAL
|
||||||
|
IRB.irb_abort(self)
|
||||||
|
when :IN_LOAD
|
||||||
|
IRB.irb_abort(self, LoadAbort)
|
||||||
|
when :IN_IRB
|
||||||
|
# ignore (JP: $B2?$b$7$J$$(B.)
|
||||||
|
else
|
||||||
|
# ignore (JP: $B$=$NB>$N>l9g$b2?$b$7$J$$(B.)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
trap("SIGINT") do
|
trap("SIGINT") do
|
||||||
@JobManager.current_job.signal_handle
|
@JobManager.current_job.signal_handle
|
||||||
|
Thread.stop
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,6 +24,8 @@ class RubyLex
|
||||||
def_exception(:TkReading2TokenDuplicateError,
|
def_exception(:TkReading2TokenDuplicateError,
|
||||||
"key duplicate(token_n='%s', key='%s')")
|
"key duplicate(token_n='%s', key='%s')")
|
||||||
def_exception(:SyntaxError, "%s")
|
def_exception(:SyntaxError, "%s")
|
||||||
|
|
||||||
|
def_exception(:TerminateLineInput, "Terminate Line Input")
|
||||||
|
|
||||||
include RubyToken
|
include RubyToken
|
||||||
|
|
||||||
|
@ -211,27 +213,35 @@ class RubyLex
|
||||||
|
|
||||||
def each_top_level_statement
|
def each_top_level_statement
|
||||||
initialize_input
|
initialize_input
|
||||||
loop do
|
catch(:TERM_INPUT) do
|
||||||
@continue = false
|
loop do
|
||||||
prompt
|
begin
|
||||||
unless l = lex
|
@continue = false
|
||||||
break if @line == ''
|
prompt
|
||||||
else
|
unless l = lex
|
||||||
# p l
|
throw :TERM_INPUT if @line == ''
|
||||||
@line.concat l
|
else
|
||||||
if @ltype or @continue or @indent > 0
|
#p l
|
||||||
next
|
@line.concat l
|
||||||
|
if @ltype or @continue or @indent > 0
|
||||||
|
next
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if @line != "\n"
|
||||||
|
yield @line, @exp_line_no
|
||||||
|
end
|
||||||
|
break unless l
|
||||||
|
@line = ''
|
||||||
|
@exp_line_no = @line_no
|
||||||
|
|
||||||
|
@indent = 0
|
||||||
|
prompt
|
||||||
|
rescue TerminateLineInput
|
||||||
|
initialize_input
|
||||||
|
prompt
|
||||||
|
get_readed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if @line != "\n"
|
|
||||||
yield @line, @exp_line_no
|
|
||||||
end
|
|
||||||
break unless l
|
|
||||||
@line = ''
|
|
||||||
@exp_line_no = @line_no
|
|
||||||
|
|
||||||
@indent = 0
|
|
||||||
prompt
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# irb/version.rb - irb version definition file
|
# irb/version.rb - irb version definition file
|
||||||
# $Release Version: 0.7.3$
|
# $Release Version: 0.7.4$
|
||||||
# $Revision$
|
# $Revision$
|
||||||
# $Date$
|
# $Date$
|
||||||
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
||||||
|
@ -11,6 +11,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
module IRB
|
module IRB
|
||||||
@RELEASE_VERSION = "0.7.3"
|
@RELEASE_VERSION = "0.7.4"
|
||||||
@LAST_UPDATE_DATE = "01/04/16"
|
@LAST_UPDATE_DATE = "01/05/08"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue