1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merges r24229 and r24233 from trunk into ruby_1_9_1.

--
 * lib/irb.rb, lib/irb/init.rb, lib/irb/ext/save-history.rb: add
   IRB::irb_at_exit. no use finalizer saving history. [ruby-dev-38563]
--
 * lib/irb.rb: forget svn commit.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@24294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yugui 2009-07-26 15:33:29 +00:00
parent 4adce79fa2
commit 62cc5d4e01
5 changed files with 52 additions and 19 deletions

View file

@ -1,3 +1,12 @@
Wed Jul 22 02:33:57 2009 Keiju Ishitsuka <keiju@emperor2.pendome>
* lib/irb.rb: forget svn commit.
Wed Jul 22 00:34:39 2009 Keiju Ishitsuka <keiju@ruby-lang.org>
* lib/irb.rb, lib/irb/init.rb, lib/irb/ext/save-history.rb: add
IRB::irb_at_exit. no use finalizer saving history. [ruby-dev-38563]
Tue Jul 21 20:41:20 2009 Keiju Ishitsuka <keiju@emperor2.pendome>
* lib/tracer.rb: no show lines unkonwn line number. [ruby-core:22096],

View file

@ -64,13 +64,21 @@ module IRB
trap("SIGINT") do
irb.signal_handle
end
catch(:IRB_EXIT) do
irb.eval_input
begin
catch(:IRB_EXIT) do
irb.eval_input
end
ensure
irb_at_exit
end
# print "\n"
end
def IRB.irb_at_exit
@CONF[:AT_EXIT].each{|hook| hook.call}
end
def IRB.irb_exit(irb, ret)
throw :IRB_EXIT, ret
end

View file

@ -49,23 +49,24 @@ module IRB
module HistorySavingAbility
include Readline
def HistorySavingAbility.create_finalizer
proc do
if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
if history_file = IRB.conf[:HISTORY_FILE]
history_file = File.expand_path(history_file)
end
history_file = IRB.rc_file("_history") unless history_file
open(history_file, 'w' ) do |f|
hist = HISTORY.to_a
f.puts(hist[-num..-1] || hist)
end
end
end
end
# def HistorySavingAbility.create_finalizer
# proc do
# if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
# if hf = IRB.conf[:HISTORY_FILE]
# file = File.expand_path(hf)
# end
# file = IRB.rc_file("_history") unless file
# open(file, 'w' ) do |f|
# hist = HISTORY.to_a
# f.puts(hist[-num..-1] || hist)
# end
# end
# end
# end
def HistorySavingAbility.extended(obj)
ObjectSpace.define_finalizer(obj, HistorySavingAbility.create_finalizer)
# ObjectSpace.define_finalizer(obj, HistorySavingAbility.create_finalizer)
IRB.conf[:AT_EXIT].push proc{obj.save_history}
obj.load_history
obj
end
@ -81,6 +82,19 @@ module IRB
end
end
end
def save_history
if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
if history_file = IRB.conf[:HISTORY_FILE]
history_file = File.expand_path(history_file)
end
history_file = IRB.rc_file("_history") unless history_file
open(history_file, 'w' ) do |f|
hist = HISTORY.to_a
f.puts(hist[-num..-1] || hist)
end
end
end
end
end

View file

@ -113,6 +113,8 @@ module IRB
# @CONF[:LC_MESSAGES] = "en"
@CONF[:LC_MESSAGES] = Locale.new
@CONF[:AT_EXIT] = []
@CONF[:DEBUG_LEVEL] = 1
end

View file

@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.1"
#define RUBY_PATCHLEVEL 251
#define RUBY_PATCHLEVEL 252
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1