From 94f00da846fef6bb48e54426294c0376dbf20c19 Mon Sep 17 00:00:00 2001 From: Mamoru Tasaka Date: Oct 25 2009 15:08:29 +0000 Subject: - Patch so that irb saves its history (bug 518584, ruby issue 1556) --- diff --git a/ruby-1.8head-irb-save-history.patch b/ruby-1.8head-irb-save-history.patch new file mode 100644 index 0000000..9349016 --- /dev/null +++ b/ruby-1.8head-irb-save-history.patch @@ -0,0 +1,111 @@ +Thu Jul 23 15:04:20 2009 Keiju Ishitsuka + +ruby* lib/irb.rb, lib/irb/init.rb, lib/irb/ext/save-history.rb: add +ruby IRB::irb_at_exit. no use finalizer saving history. [ruby-dev-38563] + +Index: lib/irb/ext/save-history.rb +=================================================================== +--- lib/irb/ext/save-history.rb (revision 24225) ++++ lib/irb/ext/save-history.rb (revision 24254) +@@ -50,23 +50,24 @@ + module HistorySavingAbility + include Readline + +- 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.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 +@@ -80,6 +81,19 @@ + 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 + +Index: lib/irb/init.rb +=================================================================== +--- lib/irb/init.rb (revision 24225) ++++ lib/irb/init.rb (revision 24254) +@@ -114,6 +114,8 @@ + # @CONF[:LC_MESSAGES] = "en" + @CONF[:LC_MESSAGES] = Locale.new + ++ @CONF[:AT_EXIT] = [] ++ + @CONF[:DEBUG_LEVEL] = 1 + end + +Index: lib/irb.rb +=================================================================== +--- lib/irb.rb (revision 24225) ++++ lib/irb.rb (revision 24254) +@@ -65,13 +65,21 @@ + 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 diff --git a/ruby.spec b/ruby.spec index da6cb31..7b60150 100644 --- a/ruby.spec +++ b/ruby.spec @@ -16,7 +16,7 @@ Name: ruby Version: %{rubyver}%{?dotpatchlevel} -Release: 2%{?dist} +Release: 3%{?dist} License: Ruby or GPLv2 URL: http://www.ruby-lang.org/ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -51,6 +51,8 @@ Patch28: ruby-1.8.6-p287-remove-ssl-rand-range.patch Patch29: ruby-always-use-i386.patch Patch30: ruby-openssl-1.0.patch Patch31: ruby-1.8.6-p369-ri-gem_multipath.patch +# Patch from ruby_1_8 branch +Patch32: ruby-1.8head-irb-save-history.patch Summary: An interpreter of object-oriented scripting language Group: Development/Languages @@ -182,6 +184,7 @@ pushd %{name}-%{arcver} %patch29 -p1 %patch30 -p2 %patch31 -p1 +%patch32 -p0 popd %build @@ -548,6 +551,9 @@ rm -rf $RPM_BUILD_ROOT %{_emacs_sitestartdir}/ruby-mode-init.el %changelog +* Sun Oct 25 2009 Mamoru Tasaka - 1.8.6.383-3 +- Patch so that irb saves its history (bug 518584, ruby issue 1556) + * Sat Oct 24 2009 Mamoru Tasaka - 1.8.6.383-2 - Update to 1.8.6 patchlevel 383 (bug 520063)